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" |
11 #include "content/browser/devtools/devtools_manager.h" | 11 #include "content/browser/devtools/devtools_manager.h" |
12 #include "content/browser/devtools/devtools_protocol.h" | 12 #include "content/browser/devtools/devtools_protocol.h" |
13 #include "content/browser/devtools/devtools_protocol_constants.h" | |
14 #include "content/browser/devtools/protocol/devtools_protocol_handler_impl.h" | 13 #include "content/browser/devtools/protocol/devtools_protocol_handler_impl.h" |
15 #include "content/browser/devtools/protocol/dom_handler.h" | 14 #include "content/browser/devtools/protocol/dom_handler.h" |
16 #include "content/browser/devtools/protocol/input_handler.h" | 15 #include "content/browser/devtools/protocol/input_handler.h" |
| 16 #include "content/browser/devtools/protocol/inspector_handler.h" |
17 #include "content/browser/devtools/protocol/network_handler.h" | 17 #include "content/browser/devtools/protocol/network_handler.h" |
18 #include "content/browser/devtools/protocol/page_handler.h" | 18 #include "content/browser/devtools/protocol/page_handler.h" |
19 #include "content/browser/devtools/protocol/power_handler.h" | 19 #include "content/browser/devtools/protocol/power_handler.h" |
20 #include "content/browser/devtools/protocol/tracing_handler.h" | 20 #include "content/browser/devtools/protocol/tracing_handler.h" |
21 #include "content/browser/renderer_host/render_process_host_impl.h" | 21 #include "content/browser/renderer_host/render_process_host_impl.h" |
22 #include "content/browser/renderer_host/render_view_host_impl.h" | 22 #include "content/browser/renderer_host/render_view_host_impl.h" |
23 #include "content/browser/site_instance_impl.h" | 23 #include "content/browser/site_instance_impl.h" |
24 #include "content/browser/web_contents/web_contents_impl.h" | 24 #include "content/browser/web_contents/web_contents_impl.h" |
25 #include "content/common/devtools_messages.h" | 25 #include "content/common/devtools_messages.h" |
26 #include "content/common/view_messages.h" | 26 #include "content/common/view_messages.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 if (!agent_host) | 108 if (!agent_host) |
109 return; | 109 return; |
110 agent_host->DisconnectRenderViewHost(); | 110 agent_host->DisconnectRenderViewHost(); |
111 agent_host->ConnectRenderViewHost(current); | 111 agent_host->ConnectRenderViewHost(current); |
112 } | 112 } |
113 | 113 |
114 RenderViewDevToolsAgentHost::RenderViewDevToolsAgentHost(RenderViewHost* rvh) | 114 RenderViewDevToolsAgentHost::RenderViewDevToolsAgentHost(RenderViewHost* rvh) |
115 : render_view_host_(NULL), | 115 : render_view_host_(NULL), |
116 dom_handler_(new devtools::dom::DOMHandler()), | 116 dom_handler_(new devtools::dom::DOMHandler()), |
117 input_handler_(new devtools::input::InputHandler()), | 117 input_handler_(new devtools::input::InputHandler()), |
| 118 inspector_handler_(new devtools::inspector::InspectorHandler()), |
118 network_handler_(new devtools::network::NetworkHandler()), | 119 network_handler_(new devtools::network::NetworkHandler()), |
119 page_handler_(new devtools::page::PageHandler()), | 120 page_handler_(new devtools::page::PageHandler()), |
120 power_handler_(new devtools::power::PowerHandler()), | 121 power_handler_(new devtools::power::PowerHandler()), |
121 tracing_handler_(new devtools::tracing::TracingHandler( | 122 tracing_handler_(new devtools::tracing::TracingHandler( |
122 devtools::tracing::TracingHandler::Renderer)), | 123 devtools::tracing::TracingHandler::Renderer)), |
123 handler_impl_(new DevToolsProtocolHandlerImpl()), | 124 handler_impl_(new DevToolsProtocolHandlerImpl()), |
124 reattaching_(false) { | 125 reattaching_(false) { |
125 handler_impl_->SetDOMHandler(dom_handler_.get()); | 126 handler_impl_->SetDOMHandler(dom_handler_.get()); |
126 handler_impl_->SetInputHandler(input_handler_.get()); | 127 handler_impl_->SetInputHandler(input_handler_.get()); |
| 128 handler_impl_->SetInspectorHandler(inspector_handler_.get()); |
127 handler_impl_->SetNetworkHandler(network_handler_.get()); | 129 handler_impl_->SetNetworkHandler(network_handler_.get()); |
128 handler_impl_->SetPageHandler(page_handler_.get()); | 130 handler_impl_->SetPageHandler(page_handler_.get()); |
129 handler_impl_->SetPowerHandler(power_handler_.get()); | 131 handler_impl_->SetPowerHandler(power_handler_.get()); |
130 handler_impl_->SetTracingHandler(tracing_handler_.get()); | 132 handler_impl_->SetTracingHandler(tracing_handler_.get()); |
131 SetRenderViewHost(rvh); | 133 SetRenderViewHost(rvh); |
132 DevToolsProtocol::Notifier notifier(base::Bind( | 134 DevToolsProtocol::Notifier notifier(base::Bind( |
133 &RenderViewDevToolsAgentHost::DispatchOnInspectorFrontend, | 135 &RenderViewDevToolsAgentHost::DispatchOnInspectorFrontend, |
134 base::Unretained(this))); | 136 base::Unretained(this))); |
135 handler_impl_->SetNotifier(notifier); | 137 handler_impl_->SetNotifier(notifier); |
136 g_instances.Get().push_back(this); | 138 g_instances.Get().push_back(this); |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 if (IsAttached()) | 449 if (IsAttached()) |
448 Reattach(state_); | 450 Reattach(state_); |
449 } | 451 } |
450 | 452 |
451 void RenderViewDevToolsAgentHost::DisconnectRenderViewHost() { | 453 void RenderViewDevToolsAgentHost::DisconnectRenderViewHost() { |
452 ClientDetachedFromRenderer(); | 454 ClientDetachedFromRenderer(); |
453 ClearRenderViewHost(); | 455 ClearRenderViewHost(); |
454 } | 456 } |
455 | 457 |
456 void RenderViewDevToolsAgentHost::RenderViewCrashed() { | 458 void RenderViewDevToolsAgentHost::RenderViewCrashed() { |
457 scoped_refptr<DevToolsProtocol::Notification> notification = | 459 inspector_handler_->TargetCrashed(); |
458 DevToolsProtocol::CreateNotification( | |
459 devtools::Inspector::targetCrashed::kName, NULL); | |
460 SendMessageToClient(notification->Serialize()); | |
461 } | 460 } |
462 | 461 |
463 bool RenderViewDevToolsAgentHost::DispatchIPCMessage( | 462 bool RenderViewDevToolsAgentHost::DispatchIPCMessage( |
464 const IPC::Message& msg) { | 463 const IPC::Message& msg) { |
465 if (!render_view_host_) | 464 if (!render_view_host_) |
466 return false; | 465 return false; |
467 | 466 |
468 bool handled = true; | 467 bool handled = true; |
469 IPC_BEGIN_MESSAGE_MAP(RenderViewDevToolsAgentHost, msg) | 468 IPC_BEGIN_MESSAGE_MAP(RenderViewDevToolsAgentHost, msg) |
470 IPC_MESSAGE_HANDLER(DevToolsClientMsg_DispatchOnInspectorFrontend, | 469 IPC_MESSAGE_HANDLER(DevToolsClientMsg_DispatchOnInspectorFrontend, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 } | 508 } |
510 | 509 |
511 void RenderViewDevToolsAgentHost::DispatchOnInspectorFrontend( | 510 void RenderViewDevToolsAgentHost::DispatchOnInspectorFrontend( |
512 const std::string& message) { | 511 const std::string& message) { |
513 if (!IsAttached() || !render_view_host_) | 512 if (!IsAttached() || !render_view_host_) |
514 return; | 513 return; |
515 SendMessageToClient(message); | 514 SendMessageToClient(message); |
516 } | 515 } |
517 | 516 |
518 } // namespace content | 517 } // namespace content |
OLD | NEW |