Chromium Code Reviews| Index: content/browser/devtools/render_view_devtools_agent_host.cc |
| diff --git a/content/browser/devtools/render_view_devtools_agent_host.cc b/content/browser/devtools/render_view_devtools_agent_host.cc |
| index d58d168bd6fc5ddfbc417ec70b4656b59e2124f6..446fbc501b43ed2868d16507113bc587bee114a0 100644 |
| --- a/content/browser/devtools/render_view_devtools_agent_host.cc |
| +++ b/content/browser/devtools/render_view_devtools_agent_host.cc |
| @@ -53,17 +53,6 @@ static RenderViewDevToolsAgentHost* FindAgentHost(WebContents* web_contents) { |
| return NULL; |
| } |
| -static RenderViewDevToolsAgentHost* FindAgentHost(RenderViewHost* rvh) { |
| - if (g_instances == NULL) |
| - return NULL; |
| - for (Instances::iterator it = g_instances.Get().begin(); |
| - it != g_instances.Get().end(); ++it) { |
| - if (rvh == (*it)->render_view_host()) |
| - return *it; |
| - } |
| - return NULL; |
| -} |
| - |
| } // namespace |
| scoped_refptr<DevToolsAgentHost> |
| @@ -75,42 +64,19 @@ DevToolsAgentHost::GetOrCreateFor(WebContents* web_contents) { |
| } |
| // static |
| -scoped_refptr<DevToolsAgentHost> |
| -DevToolsAgentHost::GetOrCreateFor(RenderViewHost* rvh) { |
| - RenderViewDevToolsAgentHost* result = FindAgentHost(rvh); |
| - if (!result) |
| - result = new RenderViewDevToolsAgentHost(rvh); |
| - return result; |
| -} |
| - |
| -// static |
| -bool DevToolsAgentHost::HasFor(RenderViewHost* rvh) { |
| - return FindAgentHost(rvh) != NULL; |
| +bool DevToolsAgentHost::HasFor(WebContents* web_contents) { |
| + return FindAgentHost(web_contents) != NULL; |
| } |
| // static |
| bool DevToolsAgentHost::IsDebuggerAttached(WebContents* web_contents) { |
| - if (g_instances == NULL) |
| - return false; |
| - DevToolsManager* devtools_manager = DevToolsManager::GetInstance(); |
| - if (!devtools_manager) |
| - return false; |
| - RenderViewHostDelegate* delegate = |
| - static_cast<WebContentsImpl*>(web_contents); |
| - for (Instances::iterator it = g_instances.Get().begin(); |
| - it != g_instances.Get().end(); ++it) { |
| - RenderViewHost* rvh = (*it)->render_view_host_; |
| - if (rvh && rvh->GetDelegate() != delegate) |
| - continue; |
| - if ((*it)->IsAttached()) |
| - return true; |
| - } |
| - return false; |
| + RenderViewDevToolsAgentHost* agent_host = FindAgentHost(web_contents); |
| + return agent_host && agent_host->IsAttached(); |
| } |
| //static |
| -std::vector<RenderViewHost*> DevToolsAgentHost::GetValidRenderViewHosts() { |
| - std::vector<RenderViewHost*> result; |
| +std::vector<WebContents*> DevToolsAgentHost::GetInspectableWebContents() { |
| + std::vector<WebContents*> result; |
| scoped_ptr<RenderWidgetHostIterator> widgets( |
| RenderWidgetHost::GetRenderWidgetHosts()); |
| while (RenderWidgetHost* widget = widgets->GetNextHost()) { |
| @@ -122,22 +88,8 @@ std::vector<RenderViewHost*> DevToolsAgentHost::GetValidRenderViewHosts() { |
| RenderViewHost* rvh = RenderViewHost::From(widget); |
| WebContents* web_contents = WebContents::FromRenderViewHost(rvh); |
| - if (!web_contents) |
| - continue; |
| - |
| - // Don't report a RenderViewHost if it is not the current RenderViewHost |
| - // for some WebContents (this filters out pre-render RVHs and similar). |
| - // However report a RenderViewHost created for an out of process iframe. |
| - // TODO (kaznacheev): Revisit this when it is clear how OOP iframes |
| - // interact with pre-rendering. |
| - // TODO (kaznacheev): GetMainFrame() call is a temporary hack. Iterate over |
| - // all RenderFrameHost instances when multiple OOP frames are supported. |
| - if (rvh != web_contents->GetRenderViewHost() && |
| - !rvh->GetMainFrame()->IsCrossProcessSubframe()) { |
| - continue; |
| - } |
| - |
| - result.push_back(rvh); |
| + if (web_contents) |
| + result.push_back(web_contents); |
|
dgozman
2014/08/06 19:22:20
You will get duplicates here for prerender and nav
pfeldman
2014/08/07 09:03:09
Done.
|
| } |
| return result; |
| } |
| @@ -146,21 +98,14 @@ std::vector<RenderViewHost*> DevToolsAgentHost::GetValidRenderViewHosts() { |
| void RenderViewDevToolsAgentHost::OnCancelPendingNavigation( |
| RenderViewHost* pending, |
| RenderViewHost* current) { |
| - RenderViewDevToolsAgentHost* agent_host = FindAgentHost(pending); |
| + WebContents* web_contents = WebContents::FromRenderViewHost(pending); |
| + RenderViewDevToolsAgentHost* agent_host = FindAgentHost(web_contents); |
| if (!agent_host) |
| return; |
| agent_host->DisconnectRenderViewHost(); |
| agent_host->ConnectRenderViewHost(current); |
| } |
| -// static |
| -bool RenderViewDevToolsAgentHost::DispatchIPCMessage( |
| - RenderViewHost* source, |
| - const IPC::Message& message) { |
| - RenderViewDevToolsAgentHost* agent_host = FindAgentHost(source); |
| - return agent_host && agent_host->DispatchIPCMessage(message); |
| -} |
| - |
| RenderViewDevToolsAgentHost::RenderViewDevToolsAgentHost(RenderViewHost* rvh) |
| : render_view_host_(NULL), |
| overrides_handler_(new RendererOverridesHandler(this)), |
| @@ -179,8 +124,8 @@ RenderViewDevToolsAgentHost::RenderViewDevToolsAgentHost(RenderViewHost* rvh) |
| AddRef(); // Balanced in RenderViewHostDestroyed. |
| } |
| -RenderViewHost* RenderViewDevToolsAgentHost::GetRenderViewHost() { |
| - return render_view_host_; |
| +WebContents* RenderViewDevToolsAgentHost::GetWebContents() { |
| + return web_contents(); |
| } |
| void RenderViewDevToolsAgentHost::DispatchOnInspectorBackend( |
| @@ -363,6 +308,17 @@ void RenderViewDevToolsAgentHost::RenderProcessGone( |
| } |
| } |
| +bool RenderViewDevToolsAgentHost::OnMessageReceived( |
| + const IPC::Message& message, |
| + RenderFrameHost* render_frame_host) { |
| + return DispatchIPCMessage(message); |
| +} |
| + |
| +bool RenderViewDevToolsAgentHost::OnMessageReceived( |
| + const IPC::Message& message) { |
| + return DispatchIPCMessage(message); |
| +} |
| + |
| void RenderViewDevToolsAgentHost::DidAttachInterstitialPage() { |
| if (!render_view_host_) |
| return; |
| @@ -407,6 +363,14 @@ void RenderViewDevToolsAgentHost::ClearRenderViewHost() { |
| render_view_host_ = NULL; |
| } |
| +void RenderViewDevToolsAgentHost::DisconnectWebContents() { |
| + DisconnectRenderViewHost(); |
| +} |
| + |
| +void RenderViewDevToolsAgentHost::ConnectWebContents(WebContents* wc) { |
| + ConnectRenderViewHost(wc->GetRenderViewHost()); |
| +} |
| + |
| void RenderViewDevToolsAgentHost::ConnectRenderViewHost(RenderViewHost* rvh) { |
| SetRenderViewHost(rvh); |
| if (IsAttached()) |