]> khamidou — GitHub mirrors - electron.git/commitdiff
Fix initializing webview
authorCheng Zhao <zcbenz@gmail.com>
Fri, 24 Oct 2014 08:09:18 +0000 (16:09 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Fri, 24 Oct 2014 08:09:18 +0000 (16:09 +0800)
atom/browser/api/atom_api_web_contents.cc
atom/browser/api/atom_api_web_contents.h

index 490ec66c18ff72e81932c8c35d4dbd2e666e5a75..b2a0eef6cde09bd099f8e3746b0c53c6c9a6ed2c 100644 (file)
@@ -14,6 +14,7 @@
 #include "content/public/browser/render_frame_host.h"
 #include "content/public/browser/render_process_host.h"
 #include "content/public/browser/render_view_host.h"
+#include "content/public/browser/render_widget_host_view.h"
 #include "content/public/browser/web_contents.h"
 #include "native_mate/dictionary.h"
 #include "native_mate/object_template_builder.h"
@@ -39,7 +40,7 @@ WebContents::WebContents(content::WebContents* web_contents)
 WebContents::WebContents(const mate::Dictionary& options)
     : guest_instance_id_(-1),
       auto_size_enabled_(false) {
-  options.Get("guestInstances", &guest_instance_id_);
+  options.Get("guestInstanceId", &guest_instance_id_);
 
   content::WebContents::CreateParams params(AtomBrowserContext::Get());
   bool is_guest;
@@ -99,6 +100,15 @@ bool WebContents::OnMessageReceived(const IPC::Message& message) {
 }
 
 void WebContents::RenderViewReady() {
+  if (!is_guest())
+    return;
+
+  content::RenderViewHost* rvh = web_contents()->GetRenderViewHost();
+  if (auto_size_enabled_) {
+    rvh->EnableAutoResize(min_auto_size_, max_auto_size_);
+  } else {
+    rvh->DisableAutoResize(element_size_);
+  }
 }
 
 void WebContents::WebContentsDestroyed() {
index a0e47a6006e2cef767a8c156b7077cca5f6680ea..ee2fcc784d85af5fd5a6969c4f31b3ad4a6e1acc 100644 (file)
@@ -61,6 +61,9 @@ class WebContents : public mate::EventEmitter,
                    const gfx::Size& min_size,
                    const gfx::Size& max_size);
 
+  // Returns whether this is a guest view.
+  bool is_guest() const { return guest_instance_id_ != -1; }
+
   // Returns whether this guest has an associated embedder.
   bool attached() const { return !!embedder_web_contents_; }