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/view_messages.h" | 15 #include "content/common/view_messages.h" |
16 #include "content/renderer/devtools/devtools_agent_filter.h" | 16 #include "content/renderer/devtools/devtools_agent_filter.h" |
17 #include "content/renderer/devtools/devtools_client.h" | 17 #include "content/renderer/devtools/devtools_client.h" |
18 #include "content/renderer/render_view_impl.h" | 18 #include "content/renderer/render_view_impl.h" |
19 #include "third_party/WebKit/public/platform/WebPoint.h" | 19 #include "third_party/WebKit/public/platform/WebPoint.h" |
20 #include "third_party/WebKit/public/platform/WebString.h" | 20 #include "third_party/WebKit/public/platform/WebString.h" |
21 #include "third_party/WebKit/public/web/WebConsoleMessage.h" | 21 #include "third_party/WebKit/public/web/WebConsoleMessage.h" |
22 #include "third_party/WebKit/public/web/WebConsoleMessage.h" | 22 #include "third_party/WebKit/public/web/WebConsoleMessage.h" |
23 #include "third_party/WebKit/public/web/WebDevToolsAgent.h" | 23 #include "third_party/WebKit/public/web/WebDevToolsAgent.h" |
24 #include "third_party/WebKit/public/web/WebFrame.h" | 24 #include "third_party/WebKit/public/web/WebFrame.h" |
25 #include "third_party/WebKit/public/web/WebSettings.h" | |
25 #include "third_party/WebKit/public/web/WebView.h" | 26 #include "third_party/WebKit/public/web/WebView.h" |
26 | 27 |
27 #if defined(USE_TCMALLOC) | 28 #if defined(USE_TCMALLOC) |
28 #include "third_party/tcmalloc/chromium/src/gperftools/heap-profiler.h" | 29 #include "third_party/tcmalloc/chromium/src/gperftools/heap-profiler.h" |
29 #endif | 30 #endif |
30 | 31 |
31 using WebKit::WebConsoleMessage; | 32 using WebKit::WebConsoleMessage; |
32 using WebKit::WebDevToolsAgent; | 33 using WebKit::WebDevToolsAgent; |
33 using WebKit::WebDevToolsAgentClient; | 34 using WebKit::WebDevToolsAgentClient; |
34 using WebKit::WebFrame; | 35 using WebKit::WebFrame; |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
137 trace_log->SetEventCallback(cb); | 138 trace_log->SetEventCallback(cb); |
138 if (!!cb) { | 139 if (!!cb) { |
139 trace_log->SetEnabled(base::debug::CategoryFilter( | 140 trace_log->SetEnabled(base::debug::CategoryFilter( |
140 base::debug::CategoryFilter::kDefaultCategoryFilterString), | 141 base::debug::CategoryFilter::kDefaultCategoryFilterString), |
141 TraceLog::RECORD_UNTIL_FULL); | 142 TraceLog::RECORD_UNTIL_FULL); |
142 } else { | 143 } else { |
143 trace_log->SetDisabled(); | 144 trace_log->SetDisabled(); |
144 } | 145 } |
145 } | 146 } |
146 | 147 |
148 void DevToolsAgent::emulateDevice( | |
149 bool enabled, | |
150 const WebKit::WebSize& device_size, | |
151 const WebKit::WebRect& view_rect, | |
152 float device_scale_factor, | |
153 bool fit_to_view) { | |
154 RenderViewImpl* impl = static_cast<RenderViewImpl*>(render_view()); | |
155 if (enabled && impl->webview()) | |
aelias_OOO_until_Jul13
2013/10/01 08:08:22
No need for the NULL pointer check of impl->webvie
dgozman
2013/10/01 15:26:10
Done.
| |
156 impl->webview()->settings()->setForceCompositingMode(true); | |
157 impl->EmulateScreenMetrics(enabled, gfx::Size(device_size), | |
158 gfx::Rect(view_rect), device_scale_factor, fit_to_view); | |
159 } | |
160 | |
147 #if defined(USE_TCMALLOC) && !defined(OS_WIN) | 161 #if defined(USE_TCMALLOC) && !defined(OS_WIN) |
148 static void AllocationVisitor(void* data, const void* ptr) { | 162 static void AllocationVisitor(void* data, const void* ptr) { |
149 typedef WebKit::WebDevToolsAgentClient::AllocatedObjectVisitor Visitor; | 163 typedef WebKit::WebDevToolsAgentClient::AllocatedObjectVisitor Visitor; |
150 Visitor* visitor = reinterpret_cast<Visitor*>(data); | 164 Visitor* visitor = reinterpret_cast<Visitor*>(data); |
151 visitor->visitObject(ptr); | 165 visitor->visitObject(ptr); |
152 } | 166 } |
153 #endif | 167 #endif |
154 | 168 |
155 void DevToolsAgent::visitAllocatedObjects(AllocatedObjectVisitor* visitor) { | 169 void DevToolsAgent::visitAllocatedObjects(AllocatedObjectVisitor* visitor) { |
156 #if defined(USE_TCMALLOC) && !defined(OS_WIN) | 170 #if defined(USE_TCMALLOC) && !defined(OS_WIN) |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
255 if (!web_view) | 269 if (!web_view) |
256 return NULL; | 270 return NULL; |
257 return web_view->devToolsAgent(); | 271 return web_view->devToolsAgent(); |
258 } | 272 } |
259 | 273 |
260 bool DevToolsAgent::IsAttached() { | 274 bool DevToolsAgent::IsAttached() { |
261 return is_attached_; | 275 return is_attached_; |
262 } | 276 } |
263 | 277 |
264 } // namespace content | 278 } // namespace content |
OLD | NEW |