Chromium Code Reviews| 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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 179 return; | 179 return; |
| 180 } | 180 } |
| 181 } | 181 } |
| 182 | 182 |
| 183 IPCDevToolsAgentHost::DispatchProtocolMessage(message); | 183 IPCDevToolsAgentHost::DispatchProtocolMessage(message); |
| 184 } | 184 } |
| 185 | 185 |
| 186 void RenderViewDevToolsAgentHost::SendMessageToAgent(IPC::Message* msg) { | 186 void RenderViewDevToolsAgentHost::SendMessageToAgent(IPC::Message* msg) { |
| 187 if (!render_view_host_) | 187 if (!render_view_host_) |
| 188 return; | 188 return; |
| 189 msg->set_routing_id(render_view_host_->GetRoutingID()); | 189 RenderFrameHost* main_frame_host = render_view_host_->GetMainFrame(); |
| 190 render_view_host_->Send(msg); | 190 msg->set_routing_id(main_frame_host->GetRoutingID()); |
| 191 main_frame_host->Send(msg); | |
| 191 } | 192 } |
| 192 | 193 |
| 193 void RenderViewDevToolsAgentHost::OnClientAttached() { | 194 void RenderViewDevToolsAgentHost::OnClientAttached() { |
| 194 if (!render_view_host_) | 195 if (!render_view_host_) |
| 195 return; | 196 return; |
| 196 | 197 |
| 197 InnerOnClientAttached(); | 198 InnerOnClientAttached(); |
| 198 | 199 |
| 199 // TODO(kaznacheev): Move this call back to DevToolsManager when | 200 // TODO(kaznacheev): Move this call back to DevToolsManager when |
| 200 // extensions::ProcessManager no longer relies on this notification. | 201 // extensions::ProcessManager no longer relies on this notification. |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 327 RenderViewCrashed(); | 328 RenderViewCrashed(); |
| 328 break; | 329 break; |
| 329 default: | 330 default: |
| 330 break; | 331 break; |
| 331 } | 332 } |
| 332 } | 333 } |
| 333 | 334 |
| 334 bool RenderViewDevToolsAgentHost::OnMessageReceived( | 335 bool RenderViewDevToolsAgentHost::OnMessageReceived( |
| 335 const IPC::Message& message, | 336 const IPC::Message& message, |
| 336 RenderFrameHost* render_frame_host) { | 337 RenderFrameHost* render_frame_host) { |
| 338 if (!render_view_host_) | |
| 339 return false; | |
| 340 if (render_frame_host != render_view_host_->GetMainFrame()) { | |
|
pfeldman
2014/11/24 13:31:19
Should we migrate this to render_frame_host_ ?
yurys
2014/11/24 14:08:54
Let's do this in a separate change since there is
| |
| 341 return false; | |
| 342 } | |
| 337 return DispatchIPCMessage(message); | 343 return DispatchIPCMessage(message); |
| 338 } | 344 } |
| 339 | 345 |
| 340 bool RenderViewDevToolsAgentHost::OnMessageReceived( | |
| 341 const IPC::Message& message) { | |
| 342 return DispatchIPCMessage(message); | |
| 343 } | |
| 344 | |
| 345 void RenderViewDevToolsAgentHost::DidAttachInterstitialPage() { | 346 void RenderViewDevToolsAgentHost::DidAttachInterstitialPage() { |
| 346 page_handler_->DidAttachInterstitialPage(); | 347 page_handler_->DidAttachInterstitialPage(); |
| 347 | 348 |
| 348 if (!render_view_host_) | 349 if (!render_view_host_) |
| 349 return; | 350 return; |
| 350 // The rvh set in AboutToNavigateRenderFrame turned out to be interstitial. | 351 // The rvh set in AboutToNavigateRenderFrame turned out to be interstitial. |
| 351 // Connect back to the real one. | 352 // Connect back to the real one. |
| 352 WebContents* web_contents = | 353 WebContents* web_contents = |
| 353 WebContents::FromRenderViewHost(render_view_host_); | 354 WebContents::FromRenderViewHost(render_view_host_); |
| 354 if (!web_contents) | 355 if (!web_contents) |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 445 bool RenderViewDevToolsAgentHost::Close() { | 446 bool RenderViewDevToolsAgentHost::Close() { |
| 446 if (render_view_host_) { | 447 if (render_view_host_) { |
| 447 render_view_host_->ClosePage(); | 448 render_view_host_->ClosePage(); |
| 448 return true; | 449 return true; |
| 449 } | 450 } |
| 450 return false; | 451 return false; |
| 451 } | 452 } |
| 452 | 453 |
| 453 void RenderViewDevToolsAgentHost::ConnectRenderViewHost(RenderViewHost* rvh) { | 454 void RenderViewDevToolsAgentHost::ConnectRenderViewHost(RenderViewHost* rvh) { |
| 454 SetRenderViewHost(rvh); | 455 SetRenderViewHost(rvh); |
| 455 if (IsAttached()) | 456 if (IsAttached()) { |
|
pfeldman
2014/11/24 13:31:19
no need
yurys
2014/11/24 14:08:54
Done.
| |
| 456 Reattach(state_); | 457 Reattach(state_); |
| 458 } | |
| 457 } | 459 } |
| 458 | 460 |
| 459 void RenderViewDevToolsAgentHost::DisconnectRenderViewHost() { | 461 void RenderViewDevToolsAgentHost::DisconnectRenderViewHost() { |
| 460 ClientDetachedFromRenderer(); | 462 ClientDetachedFromRenderer(); |
| 461 ClearRenderViewHost(); | 463 ClearRenderViewHost(); |
| 462 } | 464 } |
| 463 | 465 |
| 464 void RenderViewDevToolsAgentHost::RenderViewCrashed() { | 466 void RenderViewDevToolsAgentHost::RenderViewCrashed() { |
| 465 inspector_handler_->TargetCrashed(); | 467 inspector_handler_->TargetCrashed(); |
| 466 } | 468 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 514 } | 516 } |
| 515 | 517 |
| 516 void RenderViewDevToolsAgentHost::DispatchOnInspectorFrontend( | 518 void RenderViewDevToolsAgentHost::DispatchOnInspectorFrontend( |
| 517 const std::string& message) { | 519 const std::string& message) { |
| 518 if (!IsAttached() || !render_view_host_) | 520 if (!IsAttached() || !render_view_host_) |
| 519 return; | 521 return; |
| 520 SendMessageToClient(message); | 522 SendMessageToClient(message); |
| 521 } | 523 } |
| 522 | 524 |
| 523 } // namespace content | 525 } // namespace content |
| OLD | NEW |