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 77c0ce17a2369290356d15bd872b5cb3c38f69a3..befe390e8bee990f95f146aa90670853012d6f07 100644 |
| --- a/third_party/WebKit/Source/modules/vibration/NavigatorVibration.cpp |
| +++ b/third_party/WebKit/Source/modules/vibration/NavigatorVibration.cpp |
| @@ -80,17 +80,21 @@ bool NavigatorVibration::vibrate(Navigator& navigator, |
| return false; |
| // TODO(lunalu): When FeaturePolicy is ready, take out the check for the |
| - // runtime flag. |
| - if (!isFeatureEnabledInFrame(blink::kVibrateFeature, frame)) { |
| - if (RuntimeEnabledFeatures::featurePolicyEnabled()) { |
| - frame->domWindow()->printErrorMessage( |
| - "Navigator.vibrate() is not enabled in feature policy for this " |
| - "frame."); |
| - } else { |
| - frame->domWindow()->printErrorMessage( |
| - "A call of navigator.vibrate will be no-op inside cross-origin " |
| - "iframes: https://www.chromestatus.com/feature/5682658461876224."); |
| - } |
| + // runtime flag. Please pay attention to the user gesture code below. |
| + if (RuntimeEnabledFeatures::featurePolicyEnabled() && |
|
iclelland
2017/01/23 16:11:38
This version of the logic lgtm, thanks!
I'll clea
Bin Lu
2017/01/23 20:18:40
Acknowledged.
|
| + !isFeatureEnabledInFrame(blink::kVibrateFeature, frame)) { |
| + frame->domWindow()->printErrorMessage( |
| + "Navigator.vibrate() is not enabled in feature policy for this " |
| + "frame."); |
| + return false; |
| + } |
| + |
| + if (!RuntimeEnabledFeatures::featurePolicyEnabled() && |
| + frame->isCrossOriginSubframe() && !frame->hasReceivedUserGesture()) { |
| + frame->domWindow()->printErrorMessage( |
| + "A call of navigator.vibrate will be no-op inside a cross-origin " |
| + "iframe if there is no user activation on the iframe: " |
|
Rick Byers
2017/01/23 15:42:14
nit to wording - this sounds like a warning about
Bin Lu
2017/01/23 20:18:40
Done.
|
| + "https://www.chromestatus.com/feature/5682658461876224."); |
| return false; |
| } |