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

Unified Diff: third_party/WebKit/Source/modules/vibration/NavigatorVibration.cpp

Issue 2614913005: Add UseCounters for navigator.vibrate usage compared to site engagement. (Closed)
Patch Set: Created 3 years, 11 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
Index: third_party/WebKit/Source/modules/vibration/NavigatorVibration.cpp
diff --git a/third_party/WebKit/Source/modules/vibration/NavigatorVibration.cpp b/third_party/WebKit/Source/modules/vibration/NavigatorVibration.cpp
index 95e5b353ce92c7bb4da370d38504a524671702ad..2e82f6fc650068f71f2a4a278411932011c458c0 100644
--- a/third_party/WebKit/Source/modules/vibration/NavigatorVibration.cpp
+++ b/third_party/WebKit/Source/modules/vibration/NavigatorVibration.cpp
@@ -29,6 +29,7 @@
#include "modules/vibration/VibrationController.h"
#include "platform/Histogram.h"
#include "platform/UserGestureIndicator.h"
+#include "public/platform/site_engagement.mojom-blink.h"
namespace blink {
@@ -124,6 +125,22 @@ void NavigatorVibration::collectHistogramMetrics(const LocalFrame& frame) {
DEFINE_STATIC_LOCAL(EnumerationHistogram, NavigatorVibrateHistogram,
("Vibration.Context", NavigatorVibrationType::EnumMax));
NavigatorVibrateHistogram.count(type);
+
+ mojom::blink::EngagementLevel level = frame.document()->getEngagementLevel();
+ if (level == mojom::blink::EngagementLevel::NONE)
haraken 2017/01/06 00:56:27 Shall we use a switch statement?
dominickn 2017/01/06 01:38:34 Done - though it's a bit more verbose as a result.
+ UseCounter::count(&frame, UseCounter::NavigatorVibrateEngagementNone);
+ else if (level == mojom::blink::EngagementLevel::MINIMAL)
+ UseCounter::count(&frame, UseCounter::NavigatorVibrateEngagementMinimal);
+ else if (level == mojom::blink::EngagementLevel::LOW)
+ UseCounter::count(&frame, UseCounter::NavigatorVibrateEngagementLow);
+ else if (level == mojom::blink::EngagementLevel::MEDIUM)
+ UseCounter::count(&frame, UseCounter::NavigatorVibrateEngagementMedium);
+ else if (level == mojom::blink::EngagementLevel::HIGH)
+ UseCounter::count(&frame, UseCounter::NavigatorVibrateEngagementHigh);
+ else if (level == mojom::blink::EngagementLevel::MAX)
+ UseCounter::count(&frame, UseCounter::NavigatorVibrateEngagementMax);
+ else
+ NOTREACHED();
}
VibrationController* NavigatorVibration::controller(const LocalFrame& frame) {
« no previous file with comments | « third_party/WebKit/Source/core/frame/UseCounter.h ('k') | third_party/WebKit/Source/modules/vibration/VibrationController.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698