Fix loading devtools

This commit is contained in:
Cheng Zhao 2014-10-11 19:00:30 +08:00
parent 5bec155c81
commit 733931c7ad
2 changed files with 12 additions and 5 deletions

View file

@ -165,8 +165,9 @@ void InspectableWebContentsImpl::ShowDevTools() {
devtools_web_contents_->SetDelegate(this); devtools_web_contents_->SetDelegate(this);
agent_host_ = content::DevToolsAgentHost::GetOrCreateFor(web_contents_.get()); agent_host_ = content::DevToolsAgentHost::GetOrCreateFor(web_contents_.get());
content::DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor( frontend_host_.reset(content::DevToolsFrontendHost::Create(
agent_host_, this); web_contents_->GetRenderViewHost(), this));
content::DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor(agent_host_, this);
GURL devtools_url(kChromeUIDevToolsURL); GURL devtools_url(kChromeUIDevToolsURL);
devtools_web_contents_->GetController().LoadURL( devtools_web_contents_->GetController().LoadURL(
@ -323,6 +324,12 @@ void InspectableWebContentsImpl::InspectedContentsClosing() {
void InspectableWebContentsImpl::ReplacedWithAnotherClient() { void InspectableWebContentsImpl::ReplacedWithAnotherClient() {
} }
void InspectableWebContentsImpl::AboutToNavigateRenderView(
content::RenderViewHost* render_view_host) {
frontend_host_.reset(content::DevToolsFrontendHost::Create(
render_view_host, this));
}
void InspectableWebContentsImpl::DidFinishLoad(content::RenderFrameHost* render_frame_host, void InspectableWebContentsImpl::DidFinishLoad(content::RenderFrameHost* render_frame_host,
const GURL& validated_url) { const GURL& validated_url) {
if (render_frame_host->GetParent()) if (render_frame_host->GetParent())

View file

@ -102,8 +102,8 @@ class InspectableWebContentsImpl :
virtual void HandleMessageFromDevToolsFrontend(const std::string& message) override; virtual void HandleMessageFromDevToolsFrontend(const std::string& message) override;
virtual void HandleMessageFromDevToolsFrontendToBackend(const std::string& message) override; virtual void HandleMessageFromDevToolsFrontendToBackend(const std::string& message) override;
// content::WebContentsObserver // content::WebContentsObserver:
virtual void AboutToNavigateRenderView(content::RenderViewHost* render_view_host) override;
virtual void DidFinishLoad(content::RenderFrameHost* render_frame_host, virtual void DidFinishLoad(content::RenderFrameHost* render_frame_host,
const GURL& validated_url) OVERRIDE; const GURL& validated_url) OVERRIDE;
virtual void WebContentsDestroyed() OVERRIDE; virtual void WebContentsDestroyed() OVERRIDE;
@ -120,10 +120,10 @@ class InspectableWebContentsImpl :
virtual void CloseContents(content::WebContents* source) OVERRIDE; virtual void CloseContents(content::WebContents* source) OVERRIDE;
scoped_ptr<content::WebContents> web_contents_; scoped_ptr<content::WebContents> web_contents_;
scoped_ptr<content::DevToolsClientHost> frontend_host_;
scoped_ptr<content::WebContents> devtools_web_contents_; scoped_ptr<content::WebContents> devtools_web_contents_;
scoped_ptr<InspectableWebContentsView> view_; scoped_ptr<InspectableWebContentsView> view_;
scoped_refptr<content::DevToolsAgentHost> agent_host_; scoped_refptr<content::DevToolsAgentHost> agent_host_;
scoped_ptr<content::DevToolsFrontendHost> frontend_host_;
DevToolsContentsResizingStrategy contents_resizing_strategy_; DevToolsContentsResizingStrategy contents_resizing_strategy_;
gfx::Rect devtools_bounds_; gfx::Rect devtools_bounds_;