Enable setting devtools to not able to dock
This commit is contained in:
parent
2bbfdea8bb
commit
74025ee985
3 changed files with 15 additions and 3 deletions
|
@ -22,6 +22,7 @@ class InspectableWebContents {
|
||||||
virtual InspectableWebContentsView* GetView() const = 0;
|
virtual InspectableWebContentsView* GetView() const = 0;
|
||||||
virtual content::WebContents* GetWebContents() const = 0;
|
virtual content::WebContents* GetWebContents() const = 0;
|
||||||
|
|
||||||
|
virtual void SetCanDock(bool can_dock) = 0;
|
||||||
virtual void ShowDevTools() = 0;
|
virtual void ShowDevTools() = 0;
|
||||||
// Close the DevTools completely instead of just hide it.
|
// Close the DevTools completely instead of just hide it.
|
||||||
virtual void CloseDevTools() = 0;
|
virtual void CloseDevTools() = 0;
|
||||||
|
|
|
@ -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 kDevToolsScheme[] = "chrome-devtools";
|
||||||
const char kDevToolsHost[] = "devtools";
|
const char kDevToolsHost[] = "devtools";
|
||||||
const char kChromeUIDevToolsURL[] = "chrome-devtools://devtools/devtools.html?"
|
const char kChromeUIDevToolsURL[] = "chrome-devtools://devtools/devtools.html?"
|
||||||
"can_dock=true&"
|
"can_dock=%s&"
|
||||||
"toolbarColor=rgba(223,223,223,1)&"
|
"toolbarColor=rgba(223,223,223,1)&"
|
||||||
"textColor=rgba(0,0,0,1)&"
|
"textColor=rgba(0,0,0,1)&"
|
||||||
"experiments=true";
|
"experiments=true";
|
||||||
|
@ -131,6 +131,7 @@ void InspectableWebContentsImpl::RegisterPrefs(PrefRegistrySimple* registry) {
|
||||||
InspectableWebContentsImpl::InspectableWebContentsImpl(
|
InspectableWebContentsImpl::InspectableWebContentsImpl(
|
||||||
content::WebContents* web_contents)
|
content::WebContents* web_contents)
|
||||||
: web_contents_(web_contents),
|
: web_contents_(web_contents),
|
||||||
|
can_dock_(true),
|
||||||
delegate_(nullptr) {
|
delegate_(nullptr) {
|
||||||
auto context = static_cast<BrowserContext*>(web_contents_->GetBrowserContext());
|
auto context = static_cast<BrowserContext*>(web_contents_->GetBrowserContext());
|
||||||
auto bounds_dict = context->prefs()->GetDictionary(kDevToolsBoundsPref);
|
auto bounds_dict = context->prefs()->GetDictionary(kDevToolsBoundsPref);
|
||||||
|
@ -151,6 +152,10 @@ content::WebContents* InspectableWebContentsImpl::GetWebContents() const {
|
||||||
return web_contents_.get();
|
return web_contents_.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InspectableWebContentsImpl::SetCanDock(bool can_dock) {
|
||||||
|
can_dock_ = can_dock;
|
||||||
|
}
|
||||||
|
|
||||||
void InspectableWebContentsImpl::ShowDevTools() {
|
void InspectableWebContentsImpl::ShowDevTools() {
|
||||||
// Show devtools only after it has done loading, this is to make sure the
|
// Show devtools only after it has done loading, this is to make sure the
|
||||||
// SetIsDocked is called *BEFORE* ShowDevTools.
|
// SetIsDocked is called *BEFORE* ShowDevTools.
|
||||||
|
@ -169,7 +174,7 @@ void InspectableWebContentsImpl::ShowDevTools() {
|
||||||
web_contents_->GetRenderViewHost(), this));
|
web_contents_->GetRenderViewHost(), this));
|
||||||
content::DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor(agent_host_, 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_web_contents_->GetController().LoadURL(
|
||||||
devtools_url,
|
devtools_url,
|
||||||
content::Referrer(),
|
content::Referrer(),
|
||||||
|
@ -315,7 +320,7 @@ void InspectableWebContentsImpl::DispatchOnInspectorFrontend(
|
||||||
const std::string& message) {
|
const std::string& message) {
|
||||||
std::string code = "InspectorFrontendAPI.dispatchMessage(" + message + ");";
|
std::string code = "InspectorFrontendAPI.dispatchMessage(" + message + ");";
|
||||||
base::string16 javascript = base::UTF8ToUTF16(code);
|
base::string16 javascript = base::UTF8ToUTF16(code);
|
||||||
web_contents()->GetMainFrame()->ExecuteJavaScript(javascript);
|
devtools_web_contents()->GetMainFrame()->ExecuteJavaScript(javascript);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectableWebContentsImpl::InspectedContentsClosing() {
|
void InspectableWebContentsImpl::InspectedContentsClosing() {
|
||||||
|
@ -336,6 +341,10 @@ void InspectableWebContentsImpl::DidFinishLoad(content::RenderFrameHost* render_
|
||||||
return;
|
return;
|
||||||
|
|
||||||
view_->ShowDevTools();
|
view_->ShowDevTools();
|
||||||
|
|
||||||
|
// If the devtools can dock, "SetIsDocked" will be called by devtools itself.
|
||||||
|
if (!can_dock_)
|
||||||
|
SetIsDocked(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectableWebContentsImpl::WebContentsDestroyed() {
|
void InspectableWebContentsImpl::WebContentsDestroyed() {
|
||||||
|
|
|
@ -44,6 +44,7 @@ class InspectableWebContentsImpl :
|
||||||
InspectableWebContentsView* GetView() const override;
|
InspectableWebContentsView* GetView() const override;
|
||||||
content::WebContents* GetWebContents() const override;
|
content::WebContents* GetWebContents() const override;
|
||||||
|
|
||||||
|
void SetCanDock(bool can_dock) override;
|
||||||
void ShowDevTools() override;
|
void ShowDevTools() override;
|
||||||
void CloseDevTools() override;
|
void CloseDevTools() override;
|
||||||
bool IsDevToolsViewShowing() override;
|
bool IsDevToolsViewShowing() override;
|
||||||
|
@ -133,6 +134,7 @@ class InspectableWebContentsImpl :
|
||||||
|
|
||||||
DevToolsContentsResizingStrategy contents_resizing_strategy_;
|
DevToolsContentsResizingStrategy contents_resizing_strategy_;
|
||||||
gfx::Rect devtools_bounds_;
|
gfx::Rect devtools_bounds_;
|
||||||
|
bool can_dock_;
|
||||||
|
|
||||||
scoped_ptr<DevToolsEmbedderMessageDispatcher> embedder_message_dispatcher_;
|
scoped_ptr<DevToolsEmbedderMessageDispatcher> embedder_message_dispatcher_;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue