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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/devtools/devtools_agent.h ('k') | content/renderer/external_popup_menu.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/devtools/devtools_agent.cc
diff --git a/content/renderer/devtools/devtools_agent.cc b/content/renderer/devtools/devtools_agent.cc
index 635acc18641098000005084b573e00275d3cb652..cb9aeba635ae64a733af4d18dace4ecd7b394586 100644
--- a/content/renderer/devtools/devtools_agent.cc
+++ b/content/renderer/devtools/devtools_agent.cc
@@ -22,6 +22,7 @@
#include "third_party/WebKit/public/web/WebConsoleMessage.h"
#include "third_party/WebKit/public/web/WebDevToolsAgent.h"
#include "third_party/WebKit/public/web/WebFrame.h"
+#include "third_party/WebKit/public/web/WebSettings.h"
#include "third_party/WebKit/public/web/WebView.h"
#if defined(USE_TCMALLOC)
@@ -144,6 +145,22 @@ void DevToolsAgent::setTraceEventCallback(TraceEventCallback cb) {
}
}
+void DevToolsAgent::enableDeviceEmulation(
+ const WebKit::WebSize& device_size,
+ const WebKit::WebRect& view_rect,
+ float device_scale_factor,
+ bool fit_to_view) {
+ RenderViewImpl* impl = static_cast<RenderViewImpl*>(render_view());
+ impl->webview()->settings()->setForceCompositingMode(true);
+ impl->EnableScreenMetricsEmulation(gfx::Size(device_size),
+ gfx::Rect(view_rect), device_scale_factor, fit_to_view);
+}
+
+void DevToolsAgent::disableDeviceEmulation() {
+ RenderViewImpl* impl = static_cast<RenderViewImpl*>(render_view());
+ impl->DisableScreenMetricsEmulation();
+}
+
#if defined(USE_TCMALLOC) && !defined(OS_WIN)
static void AllocationVisitor(void* data, const void* ptr) {
typedef WebKit::WebDevToolsAgentClient::AllocatedObjectVisitor Visitor;
« 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