Index: Source/modules/screen_orientation/ScreenOrientation.cpp |
diff --git a/Source/modules/screen_orientation/ScreenOrientation.cpp b/Source/modules/screen_orientation/ScreenOrientation.cpp |
index d428f1a2fbc710cdc6589fc0ba4de4f36710c11b..8acb1303a8497ac21023b11032d5901608e78769 100644 |
--- a/Source/modules/screen_orientation/ScreenOrientation.cpp |
+++ b/Source/modules/screen_orientation/ScreenOrientation.cpp |
@@ -5,6 +5,8 @@ |
#include "config.h" |
#include "modules/screen_orientation/ScreenOrientation.h" |
+#include "bindings/v8/ExceptionState.h" |
+#include "core/dom/Document.h" |
#include "core/frame/DOMWindow.h" |
#include "core/frame/LocalFrame.h" |
#include "core/frame/Screen.h" |
@@ -139,9 +141,17 @@ const AtomicString& ScreenOrientation::orientation(Screen& screen) |
return orientationTypeToString(controller.orientation()); |
} |
-bool ScreenOrientation::lockOrientation(Screen& screen, const AtomicString& lockString) |
+bool ScreenOrientation::lockOrientation(Screen& screen, const AtomicString& lockString, ExceptionState& exceptionState) |
{ |
- ScreenOrientation::from(screen).lockOrientationAsync(stringToOrientationLock(lockString)); |
+ ScreenOrientation& screenOrientation = ScreenOrientation::from(screen); |
+ Document* document = screenOrientation.document(); |
+ if (!document) |
+ return false; |
+ if (document->isSandboxed(SandboxOrientationLock)) { |
+ exceptionState.throwSecurityError("The document is sandboxed and lacks the 'allow-orientation-lock' flag."); |
+ return false; |
+ } |
+ screenOrientation.lockOrientationAsync(stringToOrientationLock(lockString)); |
return true; |
} |