Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(904)

Side by Side Diff: content/renderer/devtools/devtools_agent.cc

Issue 23364004: Implementation of device metrics emulation in render view. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Rebase Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/renderer/devtools/devtools_agent.h ('k') | content/renderer/external_popup_menu.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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::enableDeviceEmulation(
149 const WebKit::WebSize& device_size,
150 const WebKit::WebRect& view_rect,
151 float device_scale_factor,
152 bool fit_to_view) {
153 RenderViewImpl* impl = static_cast<RenderViewImpl*>(render_view());
154 impl->webview()->settings()->setForceCompositingMode(true);
155 impl->EnableScreenMetricsEmulation(gfx::Size(device_size),
156 gfx::Rect(view_rect), device_scale_factor, fit_to_view);
157 }
158
159 void DevToolsAgent::disableDeviceEmulation() {
160 RenderViewImpl* impl = static_cast<RenderViewImpl*>(render_view());
161 impl->DisableScreenMetricsEmulation();
162 }
163
147 #if defined(USE_TCMALLOC) && !defined(OS_WIN) 164 #if defined(USE_TCMALLOC) && !defined(OS_WIN)
148 static void AllocationVisitor(void* data, const void* ptr) { 165 static void AllocationVisitor(void* data, const void* ptr) {
149 typedef WebKit::WebDevToolsAgentClient::AllocatedObjectVisitor Visitor; 166 typedef WebKit::WebDevToolsAgentClient::AllocatedObjectVisitor Visitor;
150 Visitor* visitor = reinterpret_cast<Visitor*>(data); 167 Visitor* visitor = reinterpret_cast<Visitor*>(data);
151 visitor->visitObject(ptr); 168 visitor->visitObject(ptr);
152 } 169 }
153 #endif 170 #endif
154 171
155 void DevToolsAgent::visitAllocatedObjects(AllocatedObjectVisitor* visitor) { 172 void DevToolsAgent::visitAllocatedObjects(AllocatedObjectVisitor* visitor) {
156 #if defined(USE_TCMALLOC) && !defined(OS_WIN) 173 #if defined(USE_TCMALLOC) && !defined(OS_WIN)
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 if (!web_view) 272 if (!web_view)
256 return NULL; 273 return NULL;
257 return web_view->devToolsAgent(); 274 return web_view->devToolsAgent();
258 } 275 }
259 276
260 bool DevToolsAgent::IsAttached() { 277 bool DevToolsAgent::IsAttached() {
261 return is_attached_; 278 return is_attached_;
262 } 279 }
263 280
264 } // namespace content 281 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/devtools/devtools_agent.h ('k') | content/renderer/external_popup_menu.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698