Setup devtools frontend.
This commit is contained in:
parent
1f57994e2a
commit
f2bef6c26d
2 changed files with 23 additions and 6 deletions
|
@ -196,21 +196,23 @@ void NativeWindow::DebugDevTools() {
|
||||||
base::DictionaryValue options;
|
base::DictionaryValue options;
|
||||||
NativeWindow* window = NativeWindow::Create(&options);
|
NativeWindow* window = NativeWindow::Create(&options);
|
||||||
|
|
||||||
|
// Receive devtool's web contents.
|
||||||
brightray::InspectableWebContentsImpl* inspectable_web_contents_impl =
|
brightray::InspectableWebContentsImpl* inspectable_web_contents_impl =
|
||||||
static_cast<brightray::InspectableWebContentsImpl*>(
|
static_cast<brightray::InspectableWebContentsImpl*>(
|
||||||
inspectable_web_contents());
|
inspectable_web_contents());
|
||||||
content::WebContents* devtools_web_contents =
|
content::WebContents* devtools_web_contents =
|
||||||
inspectable_web_contents_impl->devtools_web_contents();
|
inspectable_web_contents_impl->devtools_web_contents();
|
||||||
|
|
||||||
content::DevToolsAgentHost* agent_host =
|
// Setup devtools.
|
||||||
content::DevToolsAgentHost::GetOrCreateFor(
|
window->devtools_agent_host_ = content::DevToolsAgentHost::GetOrCreateFor(
|
||||||
devtools_web_contents->GetRenderViewHost());
|
devtools_web_contents->GetRenderViewHost());
|
||||||
content::DevToolsClientHost* frontend_host =
|
window->devtools_client_host_.reset(
|
||||||
content::DevToolsClientHost::CreateDevToolsFrontendHost(
|
content::DevToolsClientHost::CreateDevToolsFrontendHost(
|
||||||
window->GetWebContents(), window);
|
window->GetWebContents(), window));
|
||||||
content::DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor(
|
content::DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor(
|
||||||
agent_host, frontend_host);
|
window->devtools_agent_host_.get(), window->devtools_client_host_.get());
|
||||||
|
|
||||||
|
// Done.
|
||||||
window->InitFromOptions(&options);
|
window->InitFromOptions(&options);
|
||||||
window->GetWebContents()->GetController().LoadURL(
|
window->GetWebContents()->GetController().LoadURL(
|
||||||
GURL("chrome-devtools://devtools/devtools.html"),
|
GURL("chrome-devtools://devtools/devtools.html"),
|
||||||
|
@ -434,6 +436,14 @@ void NativeWindow::RendererResponsive(content::WebContents* source) {
|
||||||
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnRendererResponsive());
|
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnRendererResponsive());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NativeWindow::AboutToNavigateRenderView(
|
||||||
|
content::RenderViewHost* render_view_host) {
|
||||||
|
// Setup devtools frontend if we are devtools window.
|
||||||
|
if (devtools_client_host_)
|
||||||
|
content::DevToolsClientHost::SetupDevToolsFrontendClient(
|
||||||
|
GetWebContents()->GetRenderViewHost());
|
||||||
|
}
|
||||||
|
|
||||||
void NativeWindow::RenderViewDeleted(content::RenderViewHost* rvh) {
|
void NativeWindow::RenderViewDeleted(content::RenderViewHost* rvh) {
|
||||||
FOR_EACH_OBSERVER(NativeWindowObserver, observers_,
|
FOR_EACH_OBSERVER(NativeWindowObserver, observers_,
|
||||||
OnRenderViewDeleted(rvh->GetProcess()->GetID(),
|
OnRenderViewDeleted(rvh->GetProcess()->GetID(),
|
||||||
|
|
|
@ -30,6 +30,8 @@ class InspectableWebContents;
|
||||||
|
|
||||||
namespace content {
|
namespace content {
|
||||||
class BrowserContext;
|
class BrowserContext;
|
||||||
|
class DevToolsAgentHost;
|
||||||
|
class DevToolsClientHost;
|
||||||
class WebContents;
|
class WebContents;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,6 +210,8 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
|
||||||
virtual void RendererResponsive(content::WebContents* source) OVERRIDE;
|
virtual void RendererResponsive(content::WebContents* source) OVERRIDE;
|
||||||
|
|
||||||
// Implementations of content::WebContentsObserver.
|
// Implementations of content::WebContentsObserver.
|
||||||
|
virtual void AboutToNavigateRenderView(
|
||||||
|
content::RenderViewHost* render_view_host) OVERRIDE;
|
||||||
virtual void RenderViewDeleted(content::RenderViewHost*) OVERRIDE;
|
virtual void RenderViewDeleted(content::RenderViewHost*) OVERRIDE;
|
||||||
virtual void RenderProcessGone(base::TerminationStatus status) OVERRIDE;
|
virtual void RenderProcessGone(base::TerminationStatus status) OVERRIDE;
|
||||||
virtual void BeforeUnloadFired(const base::TimeTicks& proceed_time) OVERRIDE;
|
virtual void BeforeUnloadFired(const base::TimeTicks& proceed_time) OVERRIDE;
|
||||||
|
@ -265,6 +269,9 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
|
||||||
scoped_ptr<AtomJavaScriptDialogManager> dialog_manager_;
|
scoped_ptr<AtomJavaScriptDialogManager> dialog_manager_;
|
||||||
scoped_ptr<brightray::InspectableWebContents> inspectable_web_contents_;
|
scoped_ptr<brightray::InspectableWebContents> inspectable_web_contents_;
|
||||||
|
|
||||||
|
scoped_refptr<content::DevToolsAgentHost> devtools_agent_host_;
|
||||||
|
scoped_ptr<content::DevToolsClientHost> devtools_client_host_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(NativeWindow);
|
DISALLOW_COPY_AND_ASSIGN(NativeWindow);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue