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

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

Issue 2492623002: Implementation for feature policy - vibrate. (Closed)
Patch Set: Added layout tests for vibrate with runtime flag turned on Created 4 years, 1 month 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 ce72bc0774435ef851a5994d41f56c561ff41be3..a932c52d8fb91acd1190398809414c75e55c7378 100644
--- a/third_party/WebKit/Source/modules/vibration/NavigatorVibration.cpp
+++ b/third_party/WebKit/Source/modules/vibration/NavigatorVibration.cpp
@@ -19,6 +19,7 @@
#include "modules/vibration/NavigatorVibration.h"
+#include "bindings/core/v8/ConditionalFeatures.h"
#include "core/dom/Document.h"
#include "core/frame/LocalDOMWindow.h"
#include "core/frame/LocalFrame.h"
@@ -77,12 +78,18 @@ bool NavigatorVibration::vibrate(Navigator& navigator,
if (!frame->page()->isPageVisible())
return false;
- if (frame->isCrossOriginSubframe()) {
- // TODO(binlu): Once FeaturePolicy is ready, exploring using it to
- // remove the API instead of having it return false.
- frame->localDOMWindow()->printErrorMessage(
- "A call of navigator.vibrate will be no-op inside cross-origin "
- "iframes: https://www.chromestatus.com/feature/5682658461876224.");
+ // TODO(lunalu): When FeaturePolicy is ready, take out the check for the
+ // runtime flag.
+ if (!isFeatureEnabledInFrame(blink::kVibrateFeature, frame)) {
+ if (RuntimeEnabledFeatures::featurePolicyEnabled()) {
+ frame->localDOMWindow()->printErrorMessage(
+ "Navigator.vibrate() is not enabled in feature policy for this "
+ "frame.");
+ } else {
+ frame->localDOMWindow()->printErrorMessage(
+ "A call of navigator.vibrate will be no-op inside cross-origin "
+ "iframes: https://www.chromestatus.com/feature/5682658461876224.");
+ }
return false;
}

Powered by Google App Engine
This is Rietveld 408576698