Disable the detachment of devtools.
authorCheng Zhao <zcbenz@gmail.com>
Tue, 4 Mar 2014 11:59:25 +0000 (19:59 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Tue, 4 Mar 2014 11:59:25 +0000 (19:59 +0800)
browser/devtools_delegate.cc
browser/devtools_delegate.h
browser/native_window.cc
browser/native_window.h
vendor/brightray

index 37bba54..3886bfe 100644 (file)
@@ -20,6 +20,7 @@ DevToolsDelegate::DevToolsDelegate(NativeWindow* window,
                                    content::WebContents* target_web_contents)
     : content::WebContentsObserver(window->GetWebContents()),
       owner_window_(window),
+      delegate_(NULL),
       embedder_message_dispatcher_(
           new DevToolsEmbedderMessageDispatcher(this)) {
   content::WebContents* web_contents = window->GetWebContents();
@@ -78,7 +79,11 @@ void DevToolsDelegate::MoveWindow(int x, int y) {
 }
 
 void DevToolsDelegate::SetDockSide(const std::string& dock_side) {
-  owner_window_->Close();
+  bool succeed = true;
+  if (delegate_ &&
+      delegate_->DevToolsSetDockSide("attach-back", &succeed) &&
+      succeed)
+    owner_window_->Close();
 }
 
 void DevToolsDelegate::OpenInNewTab(const std::string& url) {
index be0c1b2..54e05a2 100644 (file)
@@ -10,6 +10,7 @@
 #include "content/public/browser/devtools_frontend_host_delegate.h"
 #include "content/public/browser/web_contents_observer.h"
 #include "vendor/brightray/browser/devtools_embedder_message_dispatcher.h"
+#include "vendor/brightray/browser/inspectable_web_contents_delegate.h"
 
 namespace content {
 class DevToolsAgentHost;
@@ -31,6 +32,10 @@ class DevToolsDelegate : public content::DevToolsFrontendHostDelegate,
                    content::WebContents* target_web_contents);
   virtual ~DevToolsDelegate();
 
+  void SetDelegate(brightray::InspectableWebContentsDelegate* delegate) {
+    delegate_ = delegate;
+  }
+
  protected:
   // Implementations of content::DevToolsFrontendHostDelegate.
   virtual void DispatchOnEmbedder(const std::string& message) OVERRIDE;
@@ -66,6 +71,7 @@ class DevToolsDelegate : public content::DevToolsFrontendHostDelegate,
 
  private:
   NativeWindow* owner_window_;
+  brightray::InspectableWebContentsDelegate* delegate_;
 
   scoped_refptr<content::DevToolsAgentHost> devtools_agent_host_;
   scoped_ptr<content::DevToolsClientHost> devtools_client_host_;
index 177cab7..85396ab 100644 (file)
@@ -478,26 +478,18 @@ void NativeWindow::Observe(int type,
 
 bool NativeWindow::DevToolsSetDockSide(const std::string& dock_side,
                                        bool* succeed) {
-  if (dock_side != "undocked") {
-    //  Switch to docked mode.
-    if (devtools_window_) {
-      devtools_window_->Close();
-      devtools_window_.reset();
-    }
+  if (dock_side == "undocked") {
+    *succeed = false;
+    return true;
+  } else {
     return false;
   }
-
-  CloseDevTools();
-  devtools_window_ = Debug(GetWebContents())->GetWeakPtr();
-  return true;
 }
 
-bool NativeWindow::DevToolsShow(const std::string& dock_side) {
-  if (dock_side != "undocked")
-    return false;
-
-  devtools_window_ = Debug(GetWebContents())->GetWeakPtr();
-  return true;
+bool NativeWindow::DevToolsShow(std::string* dock_side) {
+  if (*dock_side == "undocked")
+    *dock_side = "bottom";
+  return false;
 }
 
 void NativeWindow::OnCapturePageDone(const CapturePageCallback& callback,
index 8a0c1cc..af763dd 100644 (file)
@@ -229,7 +229,7 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
   // Implementations of brightray::InspectableWebContentsDelegate.
   virtual bool DevToolsSetDockSide(const std::string& dock_side,
                                    bool* succeed) OVERRIDE;
-  virtual bool DevToolsShow(const std::string& side) OVERRIDE;
+  virtual bool DevToolsShow(std::string* dock_side) OVERRIDE;
 
   // Whether window has standard frame.
   bool has_frame_;
index 8111949..1a8afaa 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 8111949e34a17bbeba9246494326bb891f55df34
+Subproject commit 1a8afaa87129527f2c41570ee563abb507f2337a