| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/renderer/devtools_agent.h" | 5 #include "content/renderer/devtools_agent.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/command_line.h" | |
| 10 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 11 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 12 #include "base/process.h" | 11 #include "base/process.h" |
| 13 #include "base/string_number_conversions.h" | 12 #include "base/string_number_conversions.h" |
| 14 #include "content/common/devtools_messages.h" | 13 #include "content/common/devtools_messages.h" |
| 15 #include "content/common/view_messages.h" | 14 #include "content/common/view_messages.h" |
| 16 #include "content/public/common/content_switches.h" | |
| 17 #include "content/renderer/devtools_agent_filter.h" | 15 #include "content/renderer/devtools_agent_filter.h" |
| 18 #include "content/renderer/devtools_client.h" | 16 #include "content/renderer/devtools_client.h" |
| 19 #include "content/renderer/render_view_impl.h" | 17 #include "content/renderer/render_view_impl.h" |
| 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDevToolsAgent.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDevToolsAgent.h" |
| 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPoint.h" | 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPoint.h" |
| 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" | 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" |
| 23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
| 24 | 22 |
| 25 using WebKit::WebDevToolsAgent; | 23 using WebKit::WebDevToolsAgent; |
| 26 using WebKit::WebDevToolsAgentClient; | 24 using WebKit::WebDevToolsAgentClient; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 56 base::LazyInstance<IdToAgentMap, base::LeakyLazyInstanceTraits<IdToAgentMap> > | 54 base::LazyInstance<IdToAgentMap, base::LeakyLazyInstanceTraits<IdToAgentMap> > |
| 57 g_agent_for_routing_id = LAZY_INSTANCE_INITIALIZER; | 55 g_agent_for_routing_id = LAZY_INSTANCE_INITIALIZER; |
| 58 | 56 |
| 59 } // namespace | 57 } // namespace |
| 60 | 58 |
| 61 DevToolsAgent::DevToolsAgent(RenderViewImpl* render_view) | 59 DevToolsAgent::DevToolsAgent(RenderViewImpl* render_view) |
| 62 : content::RenderViewObserver(render_view), | 60 : content::RenderViewObserver(render_view), |
| 63 is_attached_(false) { | 61 is_attached_(false) { |
| 64 g_agent_for_routing_id.Get()[routing_id()] = this; | 62 g_agent_for_routing_id.Get()[routing_id()] = this; |
| 65 | 63 |
| 66 CommandLine* cmd = CommandLine::ForCurrentProcess(); | |
| 67 expose_v8_debugger_protocol_ = cmd->HasSwitch(switches::kRemoteShellPort); | |
| 68 | |
| 69 render_view->webview()->setDevToolsAgentClient(this); | 64 render_view->webview()->setDevToolsAgentClient(this); |
| 70 render_view->webview()->devToolsAgent()->setProcessId( | 65 render_view->webview()->devToolsAgent()->setProcessId( |
| 71 base::Process::Current().pid()); | 66 base::Process::Current().pid()); |
| 72 } | 67 } |
| 73 | 68 |
| 74 DevToolsAgent::~DevToolsAgent() { | 69 DevToolsAgent::~DevToolsAgent() { |
| 75 g_agent_for_routing_id.Get().erase(routing_id()); | 70 g_agent_for_routing_id.Get().erase(routing_id()); |
| 76 } | 71 } |
| 77 | 72 |
| 78 // Called on the Renderer thread. | 73 // Called on the Renderer thread. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 97 } | 92 } |
| 98 | 93 |
| 99 void DevToolsAgent::sendMessageToInspectorFrontend( | 94 void DevToolsAgent::sendMessageToInspectorFrontend( |
| 100 const WebKit::WebString& message) { | 95 const WebKit::WebString& message) { |
| 101 Send(new DevToolsHostMsg_ForwardToClient( | 96 Send(new DevToolsHostMsg_ForwardToClient( |
| 102 routing_id(), | 97 routing_id(), |
| 103 DevToolsClientMsg_DispatchOnInspectorFrontend(MSG_ROUTING_NONE, | 98 DevToolsClientMsg_DispatchOnInspectorFrontend(MSG_ROUTING_NONE, |
| 104 message.utf8()))); | 99 message.utf8()))); |
| 105 } | 100 } |
| 106 | 101 |
| 107 void DevToolsAgent::sendDebuggerOutput(const WebKit::WebString& data) { | |
| 108 Send(new DevToolsHostMsg_ForwardToClient( | |
| 109 routing_id(), | |
| 110 DevToolsClientMsg_DebuggerOutput(MSG_ROUTING_NONE, data.utf8()))); | |
| 111 } | |
| 112 | |
| 113 int DevToolsAgent::hostIdentifier() { | 102 int DevToolsAgent::hostIdentifier() { |
| 114 return routing_id(); | 103 return routing_id(); |
| 115 } | 104 } |
| 116 | 105 |
| 117 void DevToolsAgent::saveAgentRuntimeState( | 106 void DevToolsAgent::saveAgentRuntimeState( |
| 118 const WebKit::WebString& state) { | 107 const WebKit::WebString& state) { |
| 119 Send(new DevToolsHostMsg_SaveAgentRuntimeState(routing_id(), state.utf8())); | 108 Send(new DevToolsHostMsg_SaveAgentRuntimeState(routing_id(), state.utf8())); |
| 120 } | 109 } |
| 121 | 110 |
| 122 WebKit::WebDevToolsAgentClient::WebKitClientMessageLoop* | 111 WebKit::WebDevToolsAgentClient::WebKitClientMessageLoop* |
| 123 DevToolsAgent::createClientMessageLoop() { | 112 DevToolsAgent::createClientMessageLoop() { |
| 124 return new WebKitClientMessageLoopImpl(); | 113 return new WebKitClientMessageLoopImpl(); |
| 125 } | 114 } |
| 126 | 115 |
| 127 bool DevToolsAgent::exposeV8DebuggerProtocol() { | |
| 128 return expose_v8_debugger_protocol_; | |
| 129 } | |
| 130 | |
| 131 void DevToolsAgent::clearBrowserCache() { | 116 void DevToolsAgent::clearBrowserCache() { |
| 132 Send(new DevToolsHostMsg_ClearBrowserCache(routing_id())); | 117 Send(new DevToolsHostMsg_ClearBrowserCache(routing_id())); |
| 133 } | 118 } |
| 134 | 119 |
| 135 void DevToolsAgent::clearBrowserCookies() { | 120 void DevToolsAgent::clearBrowserCookies() { |
| 136 Send(new DevToolsHostMsg_ClearBrowserCookies(routing_id())); | 121 Send(new DevToolsHostMsg_ClearBrowserCookies(routing_id())); |
| 137 } | 122 } |
| 138 | 123 |
| 139 // static | 124 // static |
| 140 DevToolsAgent* DevToolsAgent::FromHostId(int host_id) { | 125 DevToolsAgent* DevToolsAgent::FromHostId(int host_id) { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 WebDevToolsAgent* DevToolsAgent::GetWebAgent() { | 188 WebDevToolsAgent* DevToolsAgent::GetWebAgent() { |
| 204 WebView* web_view = render_view()->GetWebView(); | 189 WebView* web_view = render_view()->GetWebView(); |
| 205 if (!web_view) | 190 if (!web_view) |
| 206 return NULL; | 191 return NULL; |
| 207 return web_view->devToolsAgent(); | 192 return web_view->devToolsAgent(); |
| 208 } | 193 } |
| 209 | 194 |
| 210 bool DevToolsAgent::IsAttached() { | 195 bool DevToolsAgent::IsAttached() { |
| 211 return is_attached_; | 196 return is_attached_; |
| 212 } | 197 } |
| OLD | NEW |