diff --git a/brightray/browser/inspectable_web_contents.h b/brightray/browser/inspectable_web_contents.h index ea0fc8f13b3a..b0a05d48b387 100644 --- a/brightray/browser/inspectable_web_contents.h +++ b/brightray/browser/inspectable_web_contents.h @@ -22,6 +22,7 @@ class InspectableWebContents { virtual InspectableWebContentsView* GetView() const = 0; virtual content::WebContents* GetWebContents() const = 0; + virtual void SetCanDock(bool can_dock) = 0; virtual void ShowDevTools() = 0; // Close the DevTools completely instead of just hide it. virtual void CloseDevTools() = 0; diff --git a/brightray/browser/inspectable_web_contents_impl.cc b/brightray/browser/inspectable_web_contents_impl.cc index f05e1ac8a8a0..304628045318 100644 --- a/brightray/browser/inspectable_web_contents_impl.cc +++ b/brightray/browser/inspectable_web_contents_impl.cc @@ -36,7 +36,7 @@ const double kPresetZoomFactors[] = { 0.25, 0.333, 0.5, 0.666, 0.75, 0.9, 1.0, const char kDevToolsScheme[] = "chrome-devtools"; const char kDevToolsHost[] = "devtools"; const char kChromeUIDevToolsURL[] = "chrome-devtools://devtools/devtools.html?" - "can_dock=true&" + "can_dock=%s&" "toolbarColor=rgba(223,223,223,1)&" "textColor=rgba(0,0,0,1)&" "experiments=true"; @@ -131,6 +131,7 @@ void InspectableWebContentsImpl::RegisterPrefs(PrefRegistrySimple* registry) { InspectableWebContentsImpl::InspectableWebContentsImpl( content::WebContents* web_contents) : web_contents_(web_contents), + can_dock_(true), delegate_(nullptr) { auto context = static_cast(web_contents_->GetBrowserContext()); auto bounds_dict = context->prefs()->GetDictionary(kDevToolsBoundsPref); @@ -151,6 +152,10 @@ content::WebContents* InspectableWebContentsImpl::GetWebContents() const { return web_contents_.get(); } +void InspectableWebContentsImpl::SetCanDock(bool can_dock) { + can_dock_ = can_dock; +} + void InspectableWebContentsImpl::ShowDevTools() { // Show devtools only after it has done loading, this is to make sure the // SetIsDocked is called *BEFORE* ShowDevTools. @@ -169,7 +174,7 @@ void InspectableWebContentsImpl::ShowDevTools() { web_contents_->GetRenderViewHost(), this)); content::DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor(agent_host_, this); - GURL devtools_url(kChromeUIDevToolsURL); + GURL devtools_url(base::StringPrintf(kChromeUIDevToolsURL, can_dock_ ? "true" : "")); devtools_web_contents_->GetController().LoadURL( devtools_url, content::Referrer(), @@ -315,7 +320,7 @@ void InspectableWebContentsImpl::DispatchOnInspectorFrontend( const std::string& message) { std::string code = "InspectorFrontendAPI.dispatchMessage(" + message + ");"; base::string16 javascript = base::UTF8ToUTF16(code); - web_contents()->GetMainFrame()->ExecuteJavaScript(javascript); + devtools_web_contents()->GetMainFrame()->ExecuteJavaScript(javascript); } void InspectableWebContentsImpl::InspectedContentsClosing() { @@ -336,6 +341,10 @@ void InspectableWebContentsImpl::DidFinishLoad(content::RenderFrameHost* render_ return; view_->ShowDevTools(); + + // If the devtools can dock, "SetIsDocked" will be called by devtools itself. + if (!can_dock_) + SetIsDocked(false); } void InspectableWebContentsImpl::WebContentsDestroyed() { diff --git a/brightray/browser/inspectable_web_contents_impl.h b/brightray/browser/inspectable_web_contents_impl.h index db24bc95daf9..753db492b524 100644 --- a/brightray/browser/inspectable_web_contents_impl.h +++ b/brightray/browser/inspectable_web_contents_impl.h @@ -44,6 +44,7 @@ class InspectableWebContentsImpl : InspectableWebContentsView* GetView() const override; content::WebContents* GetWebContents() const override; + void SetCanDock(bool can_dock) override; void ShowDevTools() override; void CloseDevTools() override; bool IsDevToolsViewShowing() override; @@ -133,6 +134,7 @@ class InspectableWebContentsImpl : DevToolsContentsResizingStrategy contents_resizing_strategy_; gfx::Rect devtools_bounds_; + bool can_dock_; scoped_ptr embedder_message_dispatcher_;