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

Unified Diff: third_party/WebKit/Source/modules/presentation/PresentationRequest.cpp

Issue 2782663002: [Presentation API] Move sandbox check to PresentationRequest constructor. (Closed)
Patch Set: Respond to imcheng@ comments Created 3 years, 9 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 | « third_party/WebKit/LayoutTests/presentation/resources/iframe-sandbox.html ('k') | 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/presentation/PresentationRequest.cpp
diff --git a/third_party/WebKit/Source/modules/presentation/PresentationRequest.cpp b/third_party/WebKit/Source/modules/presentation/PresentationRequest.cpp
index d5c698d718f625a7e434252f4422c958cdbc3016..b31c14c39ae28e5d8250786c7e4868c6b121cbba 100644
--- a/third_party/WebKit/Source/modules/presentation/PresentationRequest.cpp
+++ b/third_party/WebKit/Source/modules/presentation/PresentationRequest.cpp
@@ -51,13 +51,6 @@ Settings* settings(ExecutionContext* executionContext) {
return document->settings();
}
-ScriptPromise rejectWithSandBoxException(ScriptState* scriptState) {
- return ScriptPromise::rejectWithDOMException(
- scriptState, DOMException::create(SecurityError,
- "The document is sandboxed and lacks "
- "the 'allow-presentation' flag."));
-}
-
} // anonymous namespace
// static
@@ -74,6 +67,12 @@ PresentationRequest* PresentationRequest::create(
ExecutionContext* executionContext,
const Vector<String>& urls,
ExceptionState& exceptionState) {
+ if (toDocument(executionContext)->isSandboxed(SandboxPresentation)) {
+ exceptionState.throwSecurityError(
+ "The document is sandboxed and lacks the 'allow-presentation' flag.");
+ return nullptr;
+ }
+
if (urls.isEmpty()) {
exceptionState.throwDOMException(NotSupportedError,
"Do not support empty sequence of URLs.");
@@ -140,8 +139,6 @@ ScriptPromise PresentationRequest::start(ScriptState* scriptState) {
InvalidAccessError,
"PresentationRequest::start() requires user gesture."));
- if (toDocument(getExecutionContext())->isSandboxed(SandboxPresentation))
- return rejectWithSandBoxException(scriptState);
WebPresentationClient* client = presentationClient(getExecutionContext());
if (!client)
@@ -159,9 +156,6 @@ ScriptPromise PresentationRequest::start(ScriptState* scriptState) {
ScriptPromise PresentationRequest::reconnect(ScriptState* scriptState,
const String& id) {
- if (toDocument(getExecutionContext())->isSandboxed(SandboxPresentation))
- return rejectWithSandBoxException(scriptState);
-
WebPresentationClient* client = presentationClient(getExecutionContext());
if (!client)
return ScriptPromise::rejectWithDOMException(
@@ -192,9 +186,6 @@ ScriptPromise PresentationRequest::reconnect(ScriptState* scriptState,
}
ScriptPromise PresentationRequest::getAvailability(ScriptState* scriptState) {
- if (toDocument(getExecutionContext())->isSandboxed(SandboxPresentation))
- return rejectWithSandBoxException(scriptState);
-
WebPresentationClient* client = presentationClient(getExecutionContext());
if (!client)
return ScriptPromise::rejectWithDOMException(
« no previous file with comments | « third_party/WebKit/LayoutTests/presentation/resources/iframe-sandbox.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698