| 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 0ab176f09d805274672cf723fb519c39104ff57c..1bd2acd4d7e24a8581da8c901935efb1450f4313 100644
|
| --- a/third_party/WebKit/Source/modules/vibration/NavigatorVibration.cpp
|
| +++ b/third_party/WebKit/Source/modules/vibration/NavigatorVibration.cpp
|
| @@ -20,10 +20,12 @@
|
| #include "modules/vibration/NavigatorVibration.h"
|
|
|
| #include "core/dom/Document.h"
|
| +#include "core/frame/FrameConsole.h"
|
| #include "core/frame/LocalDOMWindow.h"
|
| #include "core/frame/LocalFrame.h"
|
| #include "core/frame/Navigator.h"
|
| #include "core/frame/UseCounter.h"
|
| +#include "core/inspector/ConsoleMessage.h"
|
| #include "core/page/Page.h"
|
| #include "modules/vibration/VibrationController.h"
|
| #include "platform/Histogram.h"
|
| @@ -89,13 +91,32 @@ bool NavigatorVibration::vibrate(Navigator& navigator,
|
| 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;
|
| + if (!frame->HasReceivedUserGesture()) {
|
| + String message;
|
| + MessageLevel level = kErrorMessageLevel;
|
| + if (frame->IsCrossOriginSubframe()) {
|
| + message =
|
| + "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.";
|
| + } else if (RuntimeEnabledFeatures::vibrateRequiresUserGestureEnabled()) {
|
| + message =
|
| + "Blocked call to navigator.vibrate because user hasn't tapped "
|
| + "on the frame or any embedded frame yet: "
|
| + "https://www.chromestatus.com/feature/5644273861001216.";
|
| + } else { // Just print a warning.
|
| + level = kWarningMessageLevel;
|
| + message =
|
| + "A call to navigator.vibrate will soon require user tap on "
|
| + "the frame or any embedded frame: "
|
| + "https://www.chromestatus.com/feature/5644273861001216.";
|
| + }
|
| +
|
| + frame->DomWindow()->GetFrameConsole()->AddMessage(
|
| + ConsoleMessage::Create(kInterventionMessageSource, level, message));
|
| + if (level == kErrorMessageLevel) {
|
| + return false;
|
| + }
|
| }
|
|
|
| return NavigatorVibration::From(navigator).Controller(*frame)->Vibrate(
|
|
|