Chromium Code Reviews| 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 ae5ca2c5c3622862bdb791b90a39b4e520bbbc8e..c33c8c4875774a643f12a3624ca4e5788409c0e3 100644 |
| --- a/third_party/WebKit/Source/modules/vibration/NavigatorVibration.cpp |
| +++ b/third_party/WebKit/Source/modules/vibration/NavigatorVibration.cpp |
| @@ -24,6 +24,8 @@ |
| #include "core/frame/UseCounter.h" |
|
Michael van Ouwerkerk
2016/06/28 11:45:52
Delete this as it is no longer used.
|
| #include "core/page/Page.h" |
| #include "modules/vibration/VibrationController.h" |
| +#include "platform/Histogram.h" |
| +#include "platform/UserGestureIndicator.h" |
| namespace blink { |
| @@ -71,9 +73,20 @@ bool NavigatorVibration::vibrate(Navigator& navigator, const VibrationPattern& p |
| if (!frame) |
| return false; |
| - UseCounter::count(frame, UseCounter::NavigatorVibrate); |
| - if (!frame->isMainFrame()) |
| - UseCounter::count(frame, UseCounter::NavigatorVibrateSubFrame); |
| + const unsigned userGestureBit = 0x1; |
|
Michael van Ouwerkerk
2016/06/28 11:45:53
I don't find this section very readable, using bit
|
| + const unsigned subFrameBit = 0x2; |
| + const unsigned crossOriginFrameBit = 0x4; |
| + unsigned vibrateParams = 0; |
| + if (UserGestureIndicator::processingUserGesture()) |
| + vibrateParams |= userGestureBit; |
| + if (!frame->isMainFrame()) { |
| + if (frame->isCrossOrigin()) |
| + vibrateParams |= crossOriginFrameBit; |
| + else |
| + vibrateParams |= subFrameBit; |
| + } |
| + DEFINE_STATIC_LOCAL(EnumerationHistogram, NavigatorVibrateHistogram, ("Vibration.Context", NavigatorVibrationType::EnumMax)); |
| + NavigatorVibrateHistogram.count(static_cast<NavigatorVibrationType>(vibrateParams)); |
| DCHECK(frame->document()); |
| DCHECK(frame->page()); |