]> khamidou — GitHub mirrors - electron.git/commitdiff
The DevTools window should manage lifetime itself.
authorCheng Zhao <zcbenz@gmail.com>
Mon, 24 Feb 2014 04:17:10 +0000 (12:17 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Mon, 24 Feb 2014 04:17:10 +0000 (12:17 +0800)
browser/devtools_delegate.cc
browser/devtools_delegate.h
browser/native_window.cc
browser/native_window.h

index 77b8923c519b69ecc45aa0ed038fee43e1834972..dc11dd35e12cda1f8e83029370a43fe98e76a58c 100644 (file)
@@ -47,7 +47,7 @@ void DevToolsDelegate::DispatchOnEmbedder(const std::string& message) {
 }
 
 void DevToolsDelegate::InspectedContentsClosing() {
-  owner_window_->CloseImmediately();
+  delete owner_window_;
 }
 
 void DevToolsDelegate::AboutToNavigateRenderView(
@@ -56,4 +56,8 @@ void DevToolsDelegate::AboutToNavigateRenderView(
       owner_window_->GetWebContents()->GetRenderViewHost());
 }
 
+void DevToolsDelegate::OnWindowClosed() {
+  delete owner_window_;
+}
+
 }  // namespace atom
index d281e3b62a7ef45c71c2981db02c7b843fcfbd29..d8a8be529748ed996f9f99f723827b7c4c05a418 100644 (file)
@@ -6,6 +6,7 @@
 #define ATOM_BROWSER_DEVTOOLS_DELEGATE_H_
 
 #include "base/memory/scoped_ptr.h"
+#include "browser/native_window_observer.h"
 #include "content/public/browser/devtools_frontend_host_delegate.h"
 #include "content/public/browser/web_contents_observer.h"
 
@@ -19,7 +20,8 @@ namespace atom {
 class NativeWindow;
 
 class DevToolsDelegate : public content::DevToolsFrontendHostDelegate,
-                         public content::WebContentsObserver {
+                         public content::WebContentsObserver,
+                         public NativeWindowObserver {
  public:
   DevToolsDelegate(NativeWindow* window,
                    content::WebContents* target_web_contents);
@@ -34,6 +36,9 @@ class DevToolsDelegate : public content::DevToolsFrontendHostDelegate,
   virtual void AboutToNavigateRenderView(
       content::RenderViewHost* render_view_host) OVERRIDE;
 
+  // Implementations of NativeWindowObserver.
+  virtual void OnWindowClosed() OVERRIDE;
+
  private:
   NativeWindow* owner_window_;
 
index 3afdea54586c88073d07f94dc7f498dc72378ba9..c54e32d57317cb7896e7a0450ae326bd8640fb9e 100644 (file)
@@ -185,16 +185,14 @@ void NativeWindow::InspectElement(int x, int y) {
   agent->InspectElement(x, y);
 }
 
-scoped_ptr<NativeWindow> NativeWindow::DebugDevTools() {
-  scoped_ptr<NativeWindow> window;
-  if (IsDevToolsOpened()) {
-    base::DictionaryValue options;
-    window.reset(NativeWindow::Create(&options));
-    window->devtools_delegate_.reset(new DevToolsDelegate(
-        window.get(), GetDevToolsWebContents()));
-  }
+void NativeWindow::DebugDevTools() {
+  if (!IsDevToolsOpened())
+    return;
 
-  return window.Pass();
+  base::DictionaryValue options;
+  NativeWindow* window = NativeWindow::Create(&options);
+  window->devtools_delegate_.reset(new DevToolsDelegate(
+      window, GetDevToolsWebContents()));
 }
 
 void NativeWindow::FocusOnWebView() {
index d17f41df846b672fc590362f59d7cbf764b03f11..b1eb6e695b46186b2ce50b8c23527ef41513be90 100644 (file)
@@ -130,7 +130,7 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
   virtual void InspectElement(int x, int y);
 
   // Creates a new window to debug the devtools.
-  virtual scoped_ptr<NativeWindow> DebugDevTools();
+  virtual void DebugDevTools();
 
   virtual void FocusOnWebView();
   virtual void BlurWebView();