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

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: 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
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..5d773b7b349dc0a24fb8d14c6bb6ed21e244429d 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* getSettings(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* settings = getSettings(executionContext());
whywhat 2016/02/04 20:39:08 I wonder if this can be null? Does similar code ch
Zhiqiang Zhang (Slow) 2016/02/05 16:20:33 See here: https://code.google.com/p/chromium/codes
+ bool bypassGestureCheck = settings && settings->presentationRequiresUserGesture();
whywhat 2016/02/04 20:39:08 I think the name of the variable means the opposit
Zhiqiang Zhang (Slow) 2016/02/05 16:20:33 Done.
+
+ if (!bypassGestureCheck && !UserGestureIndicator::processingUserGesture()) {
resolver->reject(DOMException::create(InvalidAccessError, "PresentationRequest::start() requires user gesture."));
return promise;
}

Powered by Google App Engine
This is Rietveld 408576698