pass the current dock state to devtools url when available
This commit is contained in:
parent
aafc48ae2c
commit
e858c0c6d2
3 changed files with 24 additions and 9 deletions
|
@ -34,7 +34,7 @@ class InspectableWebContents {
|
||||||
virtual void SetDelegate(InspectableWebContentsDelegate* delegate) = 0;
|
virtual void SetDelegate(InspectableWebContentsDelegate* delegate) = 0;
|
||||||
virtual InspectableWebContentsDelegate* GetDelegate() const = 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 ShowDevTools() = 0;
|
||||||
virtual void CloseDevTools() = 0;
|
virtual void CloseDevTools() = 0;
|
||||||
virtual bool IsDevToolsViewShowing() = 0;
|
virtual bool IsDevToolsViewShowing() = 0;
|
||||||
|
|
|
@ -116,6 +116,18 @@ GURL GetRemoteBaseURL() {
|
||||||
content::GetWebKitRevision().c_str()));
|
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 -------------------------------------------------------------
|
// ResponseWriter -------------------------------------------------------------
|
||||||
|
|
||||||
class ResponseWriter : public net::URLFetcherResponseWriter {
|
class ResponseWriter : public net::URLFetcherResponseWriter {
|
||||||
|
@ -234,8 +246,13 @@ InspectableWebContentsDelegate* InspectableWebContentsImpl::GetDelegate() const
|
||||||
return delegate_;
|
return delegate_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectableWebContentsImpl::SetCanDock(bool can_dock) {
|
void InspectableWebContentsImpl::SetDockState(const std::string& state) {
|
||||||
can_dock_ = can_dock;
|
if (state == "detach") {
|
||||||
|
can_dock_ = false;
|
||||||
|
} else {
|
||||||
|
can_dock_ = true;
|
||||||
|
dock_state_ = state;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectableWebContentsImpl::ShowDevTools() {
|
void InspectableWebContentsImpl::ShowDevTools() {
|
||||||
|
@ -254,11 +271,8 @@ void InspectableWebContentsImpl::ShowDevTools() {
|
||||||
agent_host_ = content::DevToolsAgentHost::GetOrCreateFor(web_contents_.get());
|
agent_host_ = content::DevToolsAgentHost::GetOrCreateFor(web_contents_.get());
|
||||||
agent_host_->AttachClient(this);
|
agent_host_->AttachClient(this);
|
||||||
|
|
||||||
GURL devtools_url(base::StringPrintf(kChromeUIDevToolsURL,
|
|
||||||
GetRemoteBaseURL().spec().c_str(),
|
|
||||||
can_dock_ ? "true" : ""));
|
|
||||||
devtools_web_contents_->GetController().LoadURL(
|
devtools_web_contents_->GetController().LoadURL(
|
||||||
devtools_url,
|
GetDevToolsURL(can_dock_, dock_state_),
|
||||||
content::Referrer(),
|
content::Referrer(),
|
||||||
ui::PAGE_TRANSITION_AUTO_TOPLEVEL,
|
ui::PAGE_TRANSITION_AUTO_TOPLEVEL,
|
||||||
std::string());
|
std::string());
|
||||||
|
|
|
@ -50,7 +50,7 @@ class InspectableWebContentsImpl :
|
||||||
|
|
||||||
void SetDelegate(InspectableWebContentsDelegate* delegate) override;
|
void SetDelegate(InspectableWebContentsDelegate* delegate) override;
|
||||||
InspectableWebContentsDelegate* GetDelegate() const override;
|
InspectableWebContentsDelegate* GetDelegate() const override;
|
||||||
void SetCanDock(bool can_dock) override;
|
void SetDockState(const std::string& state) override;
|
||||||
void ShowDevTools() override;
|
void ShowDevTools() override;
|
||||||
void CloseDevTools() override;
|
void CloseDevTools() override;
|
||||||
bool IsDevToolsViewShowing() override;
|
bool IsDevToolsViewShowing() override;
|
||||||
|
@ -168,12 +168,13 @@ class InspectableWebContentsImpl :
|
||||||
DevToolsContentsResizingStrategy contents_resizing_strategy_;
|
DevToolsContentsResizingStrategy contents_resizing_strategy_;
|
||||||
gfx::Rect devtools_bounds_;
|
gfx::Rect devtools_bounds_;
|
||||||
bool can_dock_;
|
bool can_dock_;
|
||||||
|
std::string dock_state_;
|
||||||
|
|
||||||
using PendingRequestsMap = std::map<const net::URLFetcher*, DispatchCallback>;
|
using PendingRequestsMap = std::map<const net::URLFetcher*, DispatchCallback>;
|
||||||
PendingRequestsMap pending_requests_;
|
PendingRequestsMap pending_requests_;
|
||||||
InspectableWebContentsDelegate* delegate_; // weak references.
|
InspectableWebContentsDelegate* delegate_; // weak references.
|
||||||
|
|
||||||
PrefService* pref_service_; // weak reference.
|
PrefService* pref_service_; // weak reference.
|
||||||
|
|
||||||
scoped_ptr<content::WebContents> web_contents_;
|
scoped_ptr<content::WebContents> web_contents_;
|
||||||
scoped_ptr<content::WebContents> devtools_web_contents_;
|
scoped_ptr<content::WebContents> devtools_web_contents_;
|
||||||
|
|
Loading…
Reference in a new issue