| 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/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| 11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "base/process/process.h" | 12 #include "base/process/process.h" |
| 13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 14 #include "content/common/devtools_messages.h" | 14 #include "content/common/devtools_messages.h" |
| 15 #include "content/common/frame_messages.h" | 15 #include "content/common/frame_messages.h" |
| 16 #include "content/common/gpu/gpu_messages.h" | 16 #include "content/common/gpu/gpu_messages.h" |
| 17 #include "content/common/view_messages.h" | 17 #include "content/common/view_messages.h" |
| 18 #include "content/renderer/devtools/devtools_agent_filter.h" | 18 #include "content/renderer/devtools/devtools_agent_filter.h" |
| 19 #include "content/renderer/devtools/devtools_client.h" | 19 #include "content/renderer/devtools/devtools_client.h" |
| 20 #include "content/renderer/render_thread_impl.h" | 20 #include "content/renderer/render_thread_impl.h" |
| 21 #include "content/renderer/render_view_impl.h" | 21 #include "content/renderer/render_view_impl.h" |
| 22 #include "third_party/WebKit/public/platform/WebPoint.h" | 22 #include "third_party/WebKit/public/platform/WebPoint.h" |
| 23 #include "third_party/WebKit/public/platform/WebString.h" | 23 #include "third_party/WebKit/public/platform/WebString.h" |
| 24 #include "third_party/WebKit/public/web/WebConsoleMessage.h" | 24 #include "third_party/WebKit/public/web/WebConsoleMessage.h" |
| 25 #include "third_party/WebKit/public/web/WebConsoleMessage.h" | 25 #include "third_party/WebKit/public/web/WebConsoleMessage.h" |
| 26 #include "third_party/WebKit/public/web/WebDevToolsAgent.h" | 26 #include "third_party/WebKit/public/web/WebDevToolsAgent.h" |
| 27 #include "third_party/WebKit/public/web/WebDeviceEmulationParams.h" |
| 27 #include "third_party/WebKit/public/web/WebFrame.h" | 28 #include "third_party/WebKit/public/web/WebFrame.h" |
| 28 #include "third_party/WebKit/public/web/WebSettings.h" | 29 #include "third_party/WebKit/public/web/WebSettings.h" |
| 29 #include "third_party/WebKit/public/web/WebView.h" | 30 #include "third_party/WebKit/public/web/WebView.h" |
| 30 | 31 |
| 31 #if defined(USE_TCMALLOC) | 32 #if defined(USE_TCMALLOC) |
| 32 #include "third_party/tcmalloc/chromium/src/gperftools/heap-profiler.h" | 33 #include "third_party/tcmalloc/chromium/src/gperftools/heap-profiler.h" |
| 33 #endif | 34 #endif |
| 34 | 35 |
| 35 using blink::WebConsoleMessage; | 36 using blink::WebConsoleMessage; |
| 36 using blink::WebDevToolsAgent; | 37 using blink::WebDevToolsAgent; |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 static_cast<size_t>(task.used_gpu_memory_bytes)); | 217 static_cast<size_t>(task.used_gpu_memory_bytes)); |
| 217 web_agent->processGPUEvent(event); | 218 web_agent->processGPUEvent(event); |
| 218 } | 219 } |
| 219 } | 220 } |
| 220 | 221 |
| 221 void DevToolsAgent::enableDeviceEmulation( | 222 void DevToolsAgent::enableDeviceEmulation( |
| 222 const blink::WebRect& device_rect, | 223 const blink::WebRect& device_rect, |
| 223 const blink::WebRect& view_rect, | 224 const blink::WebRect& view_rect, |
| 224 float device_scale_factor, | 225 float device_scale_factor, |
| 225 bool fit_to_view) { | 226 bool fit_to_view) { |
| 227 blink::WebDeviceEmulationParams params; |
| 228 params.screenPosition = device_rect.isEmpty() ? |
| 229 blink::WebDeviceEmulationParams::Desktop : |
| 230 blink::WebDeviceEmulationParams::Mobile; |
| 231 params.deviceScaleFactor = device_scale_factor; |
| 232 params.viewSize = blink::WebSize(view_rect.width, view_rect.height); |
| 233 params.fitToView = fit_to_view; |
| 234 params.viewInsets = blink::WebSize(device_rect.x, device_rect.y); |
| 235 enableDeviceEmulation(params); |
| 236 } |
| 237 |
| 238 void DevToolsAgent::enableDeviceEmulation( |
| 239 const blink::WebDeviceEmulationParams& params) { |
| 226 RenderViewImpl* impl = static_cast<RenderViewImpl*>(render_view()); | 240 RenderViewImpl* impl = static_cast<RenderViewImpl*>(render_view()); |
| 227 impl->webview()->settings()->setForceCompositingMode(true); | 241 impl->webview()->settings()->setForceCompositingMode(true); |
| 228 impl->EnableScreenMetricsEmulation(gfx::Rect(device_rect), | 242 impl->EnableScreenMetricsEmulation(params); |
| 229 gfx::Rect(view_rect), device_scale_factor, fit_to_view); | |
| 230 } | 243 } |
| 231 | 244 |
| 232 void DevToolsAgent::disableDeviceEmulation() { | 245 void DevToolsAgent::disableDeviceEmulation() { |
| 233 RenderViewImpl* impl = static_cast<RenderViewImpl*>(render_view()); | 246 RenderViewImpl* impl = static_cast<RenderViewImpl*>(render_view()); |
| 234 impl->DisableScreenMetricsEmulation(); | 247 impl->DisableScreenMetricsEmulation(); |
| 235 } | 248 } |
| 236 | 249 |
| 237 #if defined(USE_TCMALLOC) && !defined(OS_WIN) | 250 #if defined(USE_TCMALLOC) && !defined(OS_WIN) |
| 238 static void AllocationVisitor(void* data, const void* ptr) { | 251 static void AllocationVisitor(void* data, const void* ptr) { |
| 239 typedef blink::WebDevToolsAgentClient::AllocatedObjectVisitor Visitor; | 252 typedef blink::WebDevToolsAgentClient::AllocatedObjectVisitor Visitor; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 if (!web_view) | 359 if (!web_view) |
| 347 return NULL; | 360 return NULL; |
| 348 return web_view->devToolsAgent(); | 361 return web_view->devToolsAgent(); |
| 349 } | 362 } |
| 350 | 363 |
| 351 bool DevToolsAgent::IsAttached() { | 364 bool DevToolsAgent::IsAttached() { |
| 352 return is_attached_; | 365 return is_attached_; |
| 353 } | 366 } |
| 354 | 367 |
| 355 } // namespace content | 368 } // namespace content |
| OLD | NEW |