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

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

Issue 1660193007: [Presentation API] Adding a flag to disable gesture check for starting presentations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed philipj@'s comment Created 4 years, 10 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/Source/core/frame/Settings.in ('k') | third_party/WebKit/Source/web/WebSettingsImpl.h » ('j') | 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 ed5c0ab21d24567c49b6b0288747c292a1276e13..53ae883c1fc6c8f644fcc4f3eb0e2b0bc0990661 100644
--- a/third_party/WebKit/Source/modules/presentation/PresentationRequest.cpp
+++ b/third_party/WebKit/Source/modules/presentation/PresentationRequest.cpp
@@ -10,6 +10,7 @@
#include "bindings/core/v8/ScriptPromiseResolver.h"
#include "core/dom/Document.h"
#include "core/dom/ExecutionContext.h"
+#include "core/frame/Settings.h"
#include "core/frame/UseCounter.h"
#include "modules/EventTargetModules.h"
#include "modules/presentation/PresentationAvailability.h"
@@ -36,6 +37,14 @@ WebPresentationClient* presentationClient(ExecutionContext* executionContext)
return controller ? controller->client() : nullptr;
}
+Settings* settings(ExecutionContext* executionContext)
+{
+ ASSERT(executionContext && executionContext->isDocument());
+
+ Document* document = toDocument(executionContext);
+ return document->settings();
+}
+
} // anonymous namespace
// static
@@ -85,7 +94,10 @@ ScriptPromise PresentationRequest::start(ScriptState* scriptState)
ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
ScriptPromise promise = resolver->promise();
- if (!UserGestureIndicator::processingUserGesture()) {
+ Settings* contextSettings = settings(executionContext());
+ bool isUserGestureRequired = !contextSettings || contextSettings->presentationRequiresUserGesture();
+
+ if (isUserGestureRequired && !UserGestureIndicator::processingUserGesture()) {
resolver->reject(DOMException::create(InvalidAccessError, "PresentationRequest::start() requires user gesture."));
return promise;
}
« no previous file with comments | « third_party/WebKit/Source/core/frame/Settings.in ('k') | third_party/WebKit/Source/web/WebSettingsImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698