Setup devtools in the correct phase.

* RegisterDevToolsClientHostFor should be called right after the agent_host and
  the frontend host are created.
* SetupDevToolsFrontendClient should be called before the devtools window is
  going to start navigation.
This commit is contained in:
Cheng Zhao 2013-05-14 15:17:17 +08:00 committed by Adam Roben
parent 9d29c8eb7c
commit 2cd6dd791e
2 changed files with 5 additions and 1 deletions

View file

@ -74,6 +74,7 @@ void InspectableWebContentsImpl::ShowDevTools() {
agent_host_ = content::DevToolsAgentHost::GetOrCreateFor(web_contents_->GetRenderViewHost());
frontend_host_.reset(content::DevToolsClientHost::CreateDevToolsFrontendHost(devtools_web_contents_.get(), this));
content::DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor(agent_host_, frontend_host_.get());
devtools_web_contents_->GetController().LoadURL(GetDevToolsURL(), content::Referrer(), content::PAGE_TRANSITION_AUTO_TOPLEVEL, std::string());
}
@ -145,8 +146,10 @@ void InspectableWebContentsImpl::InspectedContentsClosing() {
}
void InspectableWebContentsImpl::RenderViewCreated(content::RenderViewHost* render_view_host) {
}
void InspectableWebContentsImpl::AboutToNavigateRenderView(content::RenderViewHost* render_view_host) {
content::DevToolsClientHost::SetupDevToolsFrontendClient(web_contents()->GetRenderViewHost());
content::DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor(agent_host_, frontend_host_.get());
}
void InspectableWebContentsImpl::DidFinishLoad(int64, const GURL&, bool is_main_frame, content::RenderViewHost*) {

View file

@ -70,6 +70,7 @@ private:
// content::WebContentsObserver
virtual void RenderViewCreated(content::RenderViewHost*) OVERRIDE;
virtual void AboutToNavigateRenderView(content::RenderViewHost* render_view_host) OVERRIDE;
virtual void DidFinishLoad(int64 frame_id,
const GURL& validated_url,
bool is_main_frame,