diff --git a/brightray/browser/inspectable_web_contents.h b/brightray/browser/inspectable_web_contents.h index edf26ed117d..01e9c6d2741 100644 --- a/brightray/browser/inspectable_web_contents.h +++ b/brightray/browser/inspectable_web_contents.h @@ -34,7 +34,7 @@ class InspectableWebContents { virtual void SetDelegate(InspectableWebContentsDelegate* delegate) = 0; virtual InspectableWebContentsDelegate* GetDelegate() const = 0; - virtual void SetCanDock(bool can_dock) = 0; + virtual void SetDockState(const std::string& state) = 0; virtual void ShowDevTools() = 0; virtual void CloseDevTools() = 0; virtual bool IsDevToolsViewShowing() = 0; diff --git a/brightray/browser/inspectable_web_contents_impl.cc b/brightray/browser/inspectable_web_contents_impl.cc index 64544058951..819bdba93a5 100644 --- a/brightray/browser/inspectable_web_contents_impl.cc +++ b/brightray/browser/inspectable_web_contents_impl.cc @@ -116,6 +116,18 @@ GURL GetRemoteBaseURL() { content::GetWebKitRevision().c_str())); } +GURL GetDevToolsURL( + bool can_dock, + const std::string& dock_state) { + auto url_string = + base::StringPrintf(kChromeUIDevToolsURL, + GetRemoteBaseURL().spec().c_str(), + can_dock ? "true" : ""); + if (!dock_state.empty()) + url_string += "&settings={\"currentDockState\":\"\\\"" + dock_state + "\\\"\"}&"; + return GURL(url_string); +} + // ResponseWriter ------------------------------------------------------------- class ResponseWriter : public net::URLFetcherResponseWriter { @@ -234,8 +246,13 @@ InspectableWebContentsDelegate* InspectableWebContentsImpl::GetDelegate() const return delegate_; } -void InspectableWebContentsImpl::SetCanDock(bool can_dock) { - can_dock_ = can_dock; +void InspectableWebContentsImpl::SetDockState(const std::string& state) { + if (state == "detach") { + can_dock_ = false; + } else { + can_dock_ = true; + dock_state_ = state; + } } void InspectableWebContentsImpl::ShowDevTools() { @@ -254,11 +271,8 @@ void InspectableWebContentsImpl::ShowDevTools() { agent_host_ = content::DevToolsAgentHost::GetOrCreateFor(web_contents_.get()); agent_host_->AttachClient(this); - GURL devtools_url(base::StringPrintf(kChromeUIDevToolsURL, - GetRemoteBaseURL().spec().c_str(), - can_dock_ ? "true" : "")); devtools_web_contents_->GetController().LoadURL( - devtools_url, + GetDevToolsURL(can_dock_, dock_state_), content::Referrer(), ui::PAGE_TRANSITION_AUTO_TOPLEVEL, std::string()); diff --git a/brightray/browser/inspectable_web_contents_impl.h b/brightray/browser/inspectable_web_contents_impl.h index 518fc853cb1..b6e91a7d0f5 100644 --- a/brightray/browser/inspectable_web_contents_impl.h +++ b/brightray/browser/inspectable_web_contents_impl.h @@ -50,7 +50,7 @@ class InspectableWebContentsImpl : void SetDelegate(InspectableWebContentsDelegate* delegate) override; InspectableWebContentsDelegate* GetDelegate() const override; - void SetCanDock(bool can_dock) override; + void SetDockState(const std::string& state) override; void ShowDevTools() override; void CloseDevTools() override; bool IsDevToolsViewShowing() override; @@ -168,12 +168,13 @@ class InspectableWebContentsImpl : DevToolsContentsResizingStrategy contents_resizing_strategy_; gfx::Rect devtools_bounds_; bool can_dock_; + std::string dock_state_; using PendingRequestsMap = std::map; PendingRequestsMap pending_requests_; InspectableWebContentsDelegate* delegate_; // weak references. - PrefService* pref_service_; // weak reference. + PrefService* pref_service_; // weak reference. scoped_ptr web_contents_; scoped_ptr devtools_web_contents_;