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

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

Issue 2642263006: Allow vibrate in cross-origin iframes with user gesture. (Closed)
Patch Set: git cl try 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
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/security/vibrate_in_same_origin_iframe_allowed-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..e81e8457444bd136b088db1da3d347b8d90ea0b6 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() &&
+ !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(
+ "Blocked call to navigator.vibrate inside a cross-origin iframe "
+ "because the frame has never been activated by the user: "
+ "https://www.chromestatus.com/feature/5682658461876224.");
return false;
}
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/security/vibrate_in_same_origin_iframe_allowed-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698