]> khamidou — GitHub mirrors - electron.git/commitdiff
Inherit owner window in devtools
authorCheng Zhao <zcbenz@gmail.com>
Thu, 1 Oct 2015 06:41:01 +0000 (14:41 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Thu, 1 Oct 2015 06:41:01 +0000 (14:41 +0800)
atom/browser/api/atom_api_web_contents.cc
atom/browser/common_web_contents_delegate.cc
atom/browser/common_web_contents_delegate.h

index bbe244da7e887420d5822e387043219d32984ece..f6433ca635cd08d2f1cbcbd88f4d012cc5f65b71 100644 (file)
@@ -506,6 +506,11 @@ void WebContents::DevToolsOpened() {
       isolate(), managed_web_contents()->GetDevToolsWebContents());
   devtools_web_contents_.Reset(isolate(), handle.ToV8());
 
+  // Inherit owner window in devtools.
+  if (owner_window())
+    handle->SetOwnerWindow(managed_web_contents()->GetDevToolsWebContents(),
+                           owner_window());
+
   Emit("devtools-opened");
 }
 
index 518d4f650a63dfff366a2f4ca7299f3c166e2731..8b7a159dd7d68d4035636c530611378de894a86e 100644 (file)
@@ -136,7 +136,11 @@ void CommonWebContentsDelegate::InitWithWebContents(
 }
 
 void CommonWebContentsDelegate::SetOwnerWindow(NativeWindow* owner_window) {
-  content::WebContents* web_contents = GetWebContents();
+  SetOwnerWindow(GetWebContents(), owner_window);
+}
+
+void CommonWebContentsDelegate::SetOwnerWindow(
+    content::WebContents* web_contents, NativeWindow* owner_window) {
   owner_window_ = owner_window->GetWeakPtr();
   NativeWindowRelay* relay = new NativeWindowRelay(owner_window_);
   web_contents->SetUserData(relay->key, relay);
index 3a5be180dcc11a5ca9dcb3bca6d87adcf7dc8dc0..ee18f36660ee04932b74884a1e557833235fd45e 100644 (file)
@@ -34,6 +34,8 @@ class CommonWebContentsDelegate
 
   // Set the window as owner window.
   void SetOwnerWindow(NativeWindow* owner_window);
+  void SetOwnerWindow(content::WebContents* web_contents,
+                      NativeWindow* owner_window);
 
   // Destroy the managed InspectableWebContents object.
   void DestroyWebContents();