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

Unified Diff: third_party/WebKit/Source/modules/webshare/NavigatorShare.cpp

Issue 2219383002: Require a user gesture to use navigator.share. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@webshare-dictionary
Patch Set: Created 4 years, 4 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/webshare/NavigatorShare.cpp
diff --git a/third_party/WebKit/Source/modules/webshare/NavigatorShare.cpp b/third_party/WebKit/Source/modules/webshare/NavigatorShare.cpp
index 6e4bba14596b7147ffc6f9577a0694a049f2814a..98c57cc4cd279c0e870dfb9a834def076074cac0 100644
--- a/third_party/WebKit/Source/modules/webshare/NavigatorShare.cpp
+++ b/third_party/WebKit/Source/modules/webshare/NavigatorShare.cpp
@@ -10,6 +10,7 @@
#include "core/frame/LocalFrame.h"
#include "core/frame/Navigator.h"
#include "modules/webshare/ShareData.h"
+#include "platform/UserGestureIndicator.h"
#include "platform/mojo/MojoHelper.h"
#include "public/platform/InterfaceProvider.h"
#include "public/platform/Platform.h"
@@ -81,6 +82,9 @@ const char* NavigatorShare::supplementName()
ScriptPromise NavigatorShare::share(ScriptState* scriptState, const ShareData& shareData)
{
+ if (!UserGestureIndicator::utilizeUserGesture())
+ return ScriptPromise::rejectWithDOMException(scriptState, DOMException::create(SecurityError, "Must be handling a user gesture to perform a share request."));
Matt Giuca 2016/08/08 08:00:06 nit: Maybe split this into a temp variable, for li
Sam McNally 2016/08/08 09:08:44 Done.
+
if (!m_service) {
Document* doc = toDocument(scriptState->getExecutionContext());
DCHECK(doc);

Powered by Google App Engine
This is Rietveld 408576698