| 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 "content/browser/child_process_security_policy_impl.h" | 9 #include "content/browser/child_process_security_policy_impl.h" |
| 10 #include "content/browser/devtools/devtools_manager_impl.h" | 10 #include "content/browser/devtools/devtools_manager_impl.h" |
| 11 #include "content/browser/devtools/devtools_power_handler.h" |
| 11 #include "content/browser/devtools/devtools_protocol.h" | 12 #include "content/browser/devtools/devtools_protocol.h" |
| 12 #include "content/browser/devtools/devtools_protocol_constants.h" | 13 #include "content/browser/devtools/devtools_protocol_constants.h" |
| 13 #include "content/browser/devtools/devtools_tracing_handler.h" | 14 #include "content/browser/devtools/devtools_tracing_handler.h" |
| 14 #include "content/browser/devtools/renderer_overrides_handler.h" | 15 #include "content/browser/devtools/renderer_overrides_handler.h" |
| 15 #include "content/browser/renderer_host/render_process_host_impl.h" | 16 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 16 #include "content/browser/renderer_host/render_view_host_impl.h" | 17 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 17 #include "content/browser/site_instance_impl.h" | 18 #include "content/browser/site_instance_impl.h" |
| 18 #include "content/browser/web_contents/web_contents_impl.h" | 19 #include "content/browser/web_contents/web_contents_impl.h" |
| 19 #include "content/common/devtools_messages.h" | 20 #include "content/common/devtools_messages.h" |
| 20 #include "content/common/view_messages.h" | 21 #include "content/common/view_messages.h" |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 RenderViewHost* source, | 133 RenderViewHost* source, |
| 133 const IPC::Message& message) { | 134 const IPC::Message& message) { |
| 134 RenderViewDevToolsAgentHost* agent_host = FindAgentHost(source); | 135 RenderViewDevToolsAgentHost* agent_host = FindAgentHost(source); |
| 135 return agent_host && agent_host->DispatchIPCMessage(message); | 136 return agent_host && agent_host->DispatchIPCMessage(message); |
| 136 } | 137 } |
| 137 | 138 |
| 138 RenderViewDevToolsAgentHost::RenderViewDevToolsAgentHost( | 139 RenderViewDevToolsAgentHost::RenderViewDevToolsAgentHost( |
| 139 RenderViewHost* rvh) | 140 RenderViewHost* rvh) |
| 140 : render_view_host_(NULL), | 141 : render_view_host_(NULL), |
| 141 overrides_handler_(new RendererOverridesHandler(this)), | 142 overrides_handler_(new RendererOverridesHandler(this)), |
| 142 tracing_handler_(new DevToolsTracingHandler()) | 143 tracing_handler_(new DevToolsTracingHandler()), |
| 144 power_handler_(new DevToolsPowerHandler()) |
| 143 { | 145 { |
| 144 SetRenderViewHost(rvh); | 146 SetRenderViewHost(rvh); |
| 145 DevToolsProtocol::Notifier notifier(base::Bind( | 147 DevToolsProtocol::Notifier notifier(base::Bind( |
| 146 &RenderViewDevToolsAgentHost::OnDispatchOnInspectorFrontend, | 148 &RenderViewDevToolsAgentHost::OnDispatchOnInspectorFrontend, |
| 147 base::Unretained(this))); | 149 base::Unretained(this))); |
| 148 overrides_handler_->SetNotifier(notifier); | 150 overrides_handler_->SetNotifier(notifier); |
| 149 tracing_handler_->SetNotifier(notifier); | 151 tracing_handler_->SetNotifier(notifier); |
| 152 power_handler_->SetNotifier(notifier); |
| 150 g_instances.Get().push_back(this); | 153 g_instances.Get().push_back(this); |
| 151 AddRef(); // Balanced in RenderViewHostDestroyed. | 154 AddRef(); // Balanced in RenderViewHostDestroyed. |
| 152 } | 155 } |
| 153 | 156 |
| 154 RenderViewHost* RenderViewDevToolsAgentHost::GetRenderViewHost() { | 157 RenderViewHost* RenderViewDevToolsAgentHost::GetRenderViewHost() { |
| 155 return render_view_host_; | 158 return render_view_host_; |
| 156 } | 159 } |
| 157 | 160 |
| 158 void RenderViewDevToolsAgentHost::DispatchOnInspectorBackend( | 161 void RenderViewDevToolsAgentHost::DispatchOnInspectorBackend( |
| 159 const std::string& message) { | 162 const std::string& message) { |
| 160 std::string error_message; | 163 std::string error_message; |
| 161 scoped_refptr<DevToolsProtocol::Command> command = | 164 scoped_refptr<DevToolsProtocol::Command> command = |
| 162 DevToolsProtocol::ParseCommand(message, &error_message); | 165 DevToolsProtocol::ParseCommand(message, &error_message); |
| 163 | 166 |
| 164 if (command) { | 167 if (command) { |
| 165 scoped_refptr<DevToolsProtocol::Response> overridden_response = | 168 scoped_refptr<DevToolsProtocol::Response> overridden_response = |
| 166 overrides_handler_->HandleCommand(command); | 169 overrides_handler_->HandleCommand(command); |
| 167 if (!overridden_response) | 170 if (!overridden_response) |
| 168 overridden_response = tracing_handler_->HandleCommand(command); | 171 overridden_response = tracing_handler_->HandleCommand(command); |
| 172 if (!overridden_response) |
| 173 overridden_response = power_handler_->HandleCommand(command); |
| 169 if (overridden_response) { | 174 if (overridden_response) { |
| 170 if (!overridden_response->is_async_promise()) | 175 if (!overridden_response->is_async_promise()) |
| 171 OnDispatchOnInspectorFrontend(overridden_response->Serialize()); | 176 OnDispatchOnInspectorFrontend(overridden_response->Serialize()); |
| 172 return; | 177 return; |
| 173 } | 178 } |
| 174 } | 179 } |
| 175 | 180 |
| 176 IPCDevToolsAgentHost::DispatchOnInspectorBackend(message); | 181 IPCDevToolsAgentHost::DispatchOnInspectorBackend(message); |
| 177 } | 182 } |
| 178 | 183 |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 if (render_view_host_) | 419 if (render_view_host_) |
| 415 GetContentClient()->browser()->ClearCache(render_view_host_); | 420 GetContentClient()->browser()->ClearCache(render_view_host_); |
| 416 } | 421 } |
| 417 | 422 |
| 418 void RenderViewDevToolsAgentHost::OnClearBrowserCookies() { | 423 void RenderViewDevToolsAgentHost::OnClearBrowserCookies() { |
| 419 if (render_view_host_) | 424 if (render_view_host_) |
| 420 GetContentClient()->browser()->ClearCookies(render_view_host_); | 425 GetContentClient()->browser()->ClearCookies(render_view_host_); |
| 421 } | 426 } |
| 422 | 427 |
| 423 } // namespace content | 428 } // namespace content |
| OLD | NEW |