OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/devtools/render_view_devtools_agent_host.h" | 5 #include "content/browser/devtools/render_view_devtools_agent_host.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "content/browser/child_process_security_policy_impl.h" | 10 #include "content/browser/child_process_security_policy_impl.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
105 RenderViewHost* pending, | 105 RenderViewHost* pending, |
106 RenderViewHost* current) { | 106 RenderViewHost* current) { |
107 WebContents* web_contents = WebContents::FromRenderViewHost(pending); | 107 WebContents* web_contents = WebContents::FromRenderViewHost(pending); |
108 RenderViewDevToolsAgentHost* agent_host = FindAgentHost(web_contents); | 108 RenderViewDevToolsAgentHost* agent_host = FindAgentHost(web_contents); |
109 if (!agent_host) | 109 if (!agent_host) |
110 return; | 110 return; |
111 agent_host->DisconnectRenderViewHost(); | 111 agent_host->DisconnectRenderViewHost(); |
112 agent_host->ConnectRenderViewHost(current); | 112 agent_host->ConnectRenderViewHost(current); |
113 } | 113 } |
114 | 114 |
115 // static | |
116 bool RenderViewDevToolsAgentHost::DispatchIPCMessage( | |
117 RenderViewHost* source, | |
118 const IPC::Message& message) { | |
119 if (g_instances == NULL) | |
120 return false; | |
121 RenderViewDevToolsAgentHost* agent_host = nullptr; | |
122 for (Instances::iterator it = g_instances.Get().begin(); | |
123 it != g_instances.Get().end(); ++it) { | |
124 if (source == (*it)->render_view_host_) { | |
125 agent_host = *it; | |
126 break; | |
127 } | |
128 } | |
129 return agent_host && agent_host->DispatchIPCMessage(message); | |
130 } | |
131 | |
115 RenderViewDevToolsAgentHost::RenderViewDevToolsAgentHost(RenderViewHost* rvh) | 132 RenderViewDevToolsAgentHost::RenderViewDevToolsAgentHost(RenderViewHost* rvh) |
116 : render_view_host_(NULL), | 133 : render_view_host_(NULL), |
117 dom_handler_(new devtools::dom::DOMHandler()), | 134 dom_handler_(new devtools::dom::DOMHandler()), |
118 input_handler_(new devtools::input::InputHandler()), | 135 input_handler_(new devtools::input::InputHandler()), |
119 network_handler_(new devtools::network::NetworkHandler()), | 136 network_handler_(new devtools::network::NetworkHandler()), |
120 page_handler_(new devtools::page::PageHandler()), | 137 page_handler_(new devtools::page::PageHandler()), |
121 power_handler_(new devtools::power::PowerHandler()), | 138 power_handler_(new devtools::power::PowerHandler()), |
122 tracing_handler_(new devtools::tracing::TracingHandler( | 139 tracing_handler_(new devtools::tracing::TracingHandler( |
123 devtools::tracing::TracingHandler::Renderer)), | 140 devtools::tracing::TracingHandler::Renderer)), |
124 handler_impl_(new DevToolsProtocolHandlerImpl()), | 141 handler_impl_(new DevToolsProtocolHandlerImpl()), |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
322 #if defined(OS_ANDROID) | 339 #if defined(OS_ANDROID) |
323 case base::TERMINATION_STATUS_OOM_PROTECTED: | 340 case base::TERMINATION_STATUS_OOM_PROTECTED: |
324 #endif | 341 #endif |
325 RenderViewCrashed(); | 342 RenderViewCrashed(); |
326 break; | 343 break; |
327 default: | 344 default: |
328 break; | 345 break; |
329 } | 346 } |
330 } | 347 } |
331 | 348 |
332 bool RenderViewDevToolsAgentHost::OnMessageReceived( | |
Charlie Reis
2014/11/20 23:11:10
Can all of your messages go through here instead?
yurys
2014/11/21 08:14:14
How can we force all messages go this path and not
Charlie Reis
2014/11/22 00:38:17
I think they have to be sent through RenderFrame{H
yurys
2014/11/24 13:19:30
Done.
| |
333 const IPC::Message& message, | |
334 RenderFrameHost* render_frame_host) { | |
335 return DispatchIPCMessage(message); | |
336 } | |
337 | |
338 bool RenderViewDevToolsAgentHost::OnMessageReceived( | |
339 const IPC::Message& message) { | |
340 return DispatchIPCMessage(message); | |
341 } | |
342 | |
343 void RenderViewDevToolsAgentHost::DidAttachInterstitialPage() { | 349 void RenderViewDevToolsAgentHost::DidAttachInterstitialPage() { |
344 page_handler_->DidAttachInterstitialPage(); | 350 page_handler_->DidAttachInterstitialPage(); |
345 | 351 |
346 if (!render_view_host_) | 352 if (!render_view_host_) |
347 return; | 353 return; |
348 // The rvh set in AboutToNavigateRenderFrame turned out to be interstitial. | 354 // The rvh set in AboutToNavigateRenderFrame turned out to be interstitial. |
349 // Connect back to the real one. | 355 // Connect back to the real one. |
350 WebContents* web_contents = | 356 WebContents* web_contents = |
351 WebContents::FromRenderViewHost(render_view_host_); | 357 WebContents::FromRenderViewHost(render_view_host_); |
352 if (!web_contents) | 358 if (!web_contents) |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
515 } | 521 } |
516 | 522 |
517 void RenderViewDevToolsAgentHost::DispatchOnInspectorFrontend( | 523 void RenderViewDevToolsAgentHost::DispatchOnInspectorFrontend( |
518 const std::string& message) { | 524 const std::string& message) { |
519 if (!IsAttached() || !render_view_host_) | 525 if (!IsAttached() || !render_view_host_) |
520 return; | 526 return; |
521 SendMessageToClient(message); | 527 SendMessageToClient(message); |
522 } | 528 } |
523 | 529 |
524 } // namespace content | 530 } // namespace content |
OLD | NEW |