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/renderer/devtools/devtools_agent.h" | 5 #include "content/renderer/devtools/devtools_agent.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 IPC_BEGIN_MESSAGE_MAP(DevToolsAgent, message) | 98 IPC_BEGIN_MESSAGE_MAP(DevToolsAgent, message) |
99 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Attach, OnAttach) | 99 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Attach, OnAttach) |
100 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Reattach, OnReattach) | 100 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Reattach, OnReattach) |
101 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Detach, OnDetach) | 101 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Detach, OnDetach) |
102 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_DispatchOnInspectorBackend, | 102 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_DispatchOnInspectorBackend, |
103 OnDispatchOnInspectorBackend) | 103 OnDispatchOnInspectorBackend) |
104 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_InspectElement, OnInspectElement) | 104 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_InspectElement, OnInspectElement) |
105 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_AddMessageToConsole, | 105 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_AddMessageToConsole, |
106 OnAddMessageToConsole) | 106 OnAddMessageToConsole) |
107 IPC_MESSAGE_HANDLER(DevToolsMsg_SetupDevToolsClient, OnSetupDevToolsClient) | 107 IPC_MESSAGE_HANDLER(DevToolsMsg_SetupDevToolsClient, OnSetupDevToolsClient) |
| 108 IPC_MESSAGE_HANDLER(DevToolsMsg_EnableDeviceEmulation, |
| 109 OnEnableDeviceEmulation) |
| 110 IPC_MESSAGE_HANDLER(DevToolsMsg_DisableDeviceEmulation, |
| 111 OnDisableDeviceEmulation) |
108 IPC_MESSAGE_UNHANDLED(handled = false) | 112 IPC_MESSAGE_UNHANDLED(handled = false) |
109 IPC_END_MESSAGE_MAP() | 113 IPC_END_MESSAGE_MAP() |
110 | 114 |
111 if (message.type() == FrameMsg_Navigate::ID || | 115 if (message.type() == FrameMsg_Navigate::ID || |
112 message.type() == ViewMsg_Close::ID) | 116 message.type() == ViewMsg_Close::ID) |
113 ContinueProgram(); // Don't want to swallow the message. | 117 ContinueProgram(); // Don't want to swallow the message. |
114 | 118 |
115 return handled; | 119 return handled; |
116 } | 120 } |
117 | 121 |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 } | 335 } |
332 | 336 |
333 void DevToolsAgent::OnSetupDevToolsClient() { | 337 void DevToolsAgent::OnSetupDevToolsClient() { |
334 // We only want to register once per render view. | 338 // We only want to register once per render view. |
335 if (is_devtools_client_) | 339 if (is_devtools_client_) |
336 return; | 340 return; |
337 is_devtools_client_ = true; | 341 is_devtools_client_ = true; |
338 new DevToolsClient(main_render_frame_); | 342 new DevToolsClient(main_render_frame_); |
339 } | 343 } |
340 | 344 |
| 345 void DevToolsAgent::OnEnableDeviceEmulation( |
| 346 const blink::WebDeviceEmulationParams& params) { |
| 347 GetRenderViewImpl()->EnableScreenMetricsEmulation(params); |
| 348 } |
| 349 |
| 350 void DevToolsAgent::OnDisableDeviceEmulation() { |
| 351 GetRenderViewImpl()->DisableScreenMetricsEmulation(); |
| 352 } |
| 353 |
341 WebDevToolsAgent* DevToolsAgent::GetWebAgent() { | 354 WebDevToolsAgent* DevToolsAgent::GetWebAgent() { |
342 WebView* web_view = main_render_frame_->GetRenderView()->GetWebView(); | 355 WebView* web_view = main_render_frame_->GetRenderView()->GetWebView(); |
343 if (!web_view) | 356 if (!web_view) |
344 return NULL; | 357 return NULL; |
345 return web_view->devToolsAgent(); | 358 return web_view->devToolsAgent(); |
346 } | 359 } |
347 | 360 |
348 RenderViewImpl* DevToolsAgent::GetRenderViewImpl() { | 361 RenderViewImpl* DevToolsAgent::GetRenderViewImpl() { |
349 return static_cast<RenderViewImpl*>(main_render_frame_->GetRenderView()); | 362 return static_cast<RenderViewImpl*>(main_render_frame_->GetRenderView()); |
350 } | 363 } |
351 | 364 |
352 bool DevToolsAgent::IsAttached() { | 365 bool DevToolsAgent::IsAttached() { |
353 return is_attached_; | 366 return is_attached_; |
354 } | 367 } |
355 | 368 |
356 } // namespace content | 369 } // namespace content |
OLD | NEW |