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

Unified Diff: third_party/WebKit/Source/core/frame/VisualViewport.cpp

Issue 1358173008: Add UMA stats for pinch-zoom behavior on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 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 | « third_party/WebKit/Source/core/frame/VisualViewport.h ('k') | third_party/WebKit/Source/core/page/Page.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/frame/VisualViewport.cpp
diff --git a/third_party/WebKit/Source/core/frame/VisualViewport.cpp b/third_party/WebKit/Source/core/frame/VisualViewport.cpp
index 3b2033c942f0e02cc6dd9d63f1ac1457394fd2fb..cf5d81d819d4af3a72d0a0d3a8a443f40911a207 100644
--- a/third_party/WebKit/Source/core/frame/VisualViewport.cpp
+++ b/third_party/WebKit/Source/core/frame/VisualViewport.cpp
@@ -71,12 +71,15 @@ VisualViewport::VisualViewport(FrameHost& owner)
: m_frameHost(&owner)
, m_scale(1)
, m_topControlsAdjustment(0)
+ , m_maxPageScale(-1)
+ , m_trackPinchZoomStatsForPage(false)
{
reset();
}
VisualViewport::~VisualViewport()
{
+ sendUMAMetrics();
}
DEFINE_TRACE(VisualViewport)
@@ -654,6 +657,68 @@ IntPoint VisualViewport::rootFrameToViewport(const IntPoint& pointInRootFrame) c
return flooredIntPoint(FloatPoint(rootFrameToViewport(FloatPoint(pointInRootFrame))));
}
+void VisualViewport::startTrackingPinchStats()
+{
+ if (!mainFrame())
+ return;
+
+ Document* document = mainFrame()->document();
+ if (!document)
+ return;
+
+ if (!document->url().protocolIsInHTTPFamily())
+ return;
+
+ m_trackPinchZoomStatsForPage = !shouldDisableDesktopWorkarounds();
+}
+
+void VisualViewport::userDidChangeScale()
+{
+ if (!m_trackPinchZoomStatsForPage)
+ return;
+
+ m_maxPageScale = std::max(m_maxPageScale, m_scale);
+}
+
+void VisualViewport::sendUMAMetrics()
+{
+ if (m_trackPinchZoomStatsForPage) {
+ bool didScale = m_maxPageScale > 0;
+
+ Platform::current()->histogramEnumeration("Viewport.DidScalePage", didScale ? 1 : 0, 2);
+
+ if (didScale) {
+ int zoomPercentage = floor(m_maxPageScale * 100);
+
+ // See the PageScaleFactor enumeration in histograms.xml for the bucket ranges.
+ int bucket = floor(zoomPercentage / 25.f);
+
+ Platform::current()->histogramEnumeration("Viewport.MaxPageScale", bucket, 21);
+ }
+ }
+
+ m_maxPageScale = -1;
+ m_trackPinchZoomStatsForPage = false;
+}
+
+bool VisualViewport::shouldDisableDesktopWorkarounds() const
+{
+ if (!mainFrame() || !mainFrame()->view())
+ return false;
+
+ if (!mainFrame()->settings()->viewportEnabled())
+ return false;
+
+ // A document is considered adapted to small screen UAs if one of these holds:
+ // 1. The author specified viewport has a constrained width that is equal to
+ // the initial viewport width.
+ // 2. The author has disabled viewport zoom.
+ const PageScaleConstraints& constraints = frameHost().pageScaleConstraintsSet().pageDefinedConstraints();
+
+ return mainFrame()->view()->layoutSize().width() == m_size.width()
+ || (constraints.minimumScale == constraints.maximumScale && constraints.minimumScale != -1);
+}
+
String VisualViewport::debugName(const GraphicsLayer* graphicsLayer)
{
String name;
« no previous file with comments | « third_party/WebKit/Source/core/frame/VisualViewport.h ('k') | third_party/WebKit/Source/core/page/Page.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698