Disable the detachment of devtools.

This commit is contained in:
Cheng Zhao 2014-03-04 19:59:25 +08:00
parent 9f86fa1893
commit dc154f3907
5 changed files with 22 additions and 19 deletions

View 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) {

View 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_;

View 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,

View 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_;

2
vendor/brightray vendored

@ -1 +1 @@
Subproject commit 8111949e34a17bbeba9246494326bb891f55df34
Subproject commit 1a8afaa87129527f2c41570ee563abb507f2337a