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

Unified Diff: Source/modules/screen_orientation/ScreenOrientation.cpp

Issue 272213002: Add support for 'allow-orientation-lock' sandboxing directive (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Revert bad local change Created 6 years, 7 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
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;
}
« no previous file with comments | « Source/modules/screen_orientation/ScreenOrientation.h ('k') | Source/modules/screen_orientation/ScreenOrientation.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698