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

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

Issue 2354433002: Block navigator.vibrate in cross-domain iframe. (Closed)
Patch Set: Fix the header issue. Created 4 years, 3 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 | « no previous file | 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 50e5ce29ebf0b5d6baff3a91dfdb0d42f0616a0a..3d0c82fe1209d8ee5ef2618735950dc002ce1cb1 100644
--- a/third_party/WebKit/Source/modules/vibration/NavigatorVibration.cpp
+++ b/third_party/WebKit/Source/modules/vibration/NavigatorVibration.cpp
@@ -20,6 +20,7 @@
#include "modules/vibration/NavigatorVibration.h"
#include "core/dom/Document.h"
+#include "core/frame/LocalDOMWindow.h"
#include "core/frame/LocalFrame.h"
#include "core/frame/Navigator.h"
#include "core/frame/UseCounter.h"
@@ -81,6 +82,12 @@ bool NavigatorVibration::vibrate(Navigator& navigator, const VibrationPattern& p
if (!frame->page()->isPageVisible())
return false;
+ if (frame->isCrossOriginSubframe()) {
+ frame->localDOMWindow()->printErrorMessage(
+ "The cross-domain iframe is disallowed to call navigator.vibrate: https://www.chromestatus.com/feature/5682658461876224.");
Nate Chapin 2016/09/19 19:33:29 "A cross-origin iframe may not call navigator.vibr
+ return false;
+ }
+
return NavigatorVibration::from(navigator).controller(*frame)->vibrate(pattern);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698