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

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
« no previous file with comments | « third_party/WebKit/LayoutTests/webshare/share-without-user-gesture.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/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..87fa7f0e4d439a2c58a7e702d0a31b8c1103b68c 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,11 @@ const char* NavigatorShare::supplementName()
ScriptPromise NavigatorShare::share(ScriptState* scriptState, const ShareData& shareData)
{
+ if (!UserGestureIndicator::utilizeUserGesture()) {
+ DOMException* error = DOMException::create(SecurityError, "Must be handling a user gesture to perform a share request.");
+ return ScriptPromise::rejectWithDOMException(scriptState, error);
+ }
+
if (!m_service) {
Document* doc = toDocument(scriptState->getExecutionContext());
DCHECK(doc);
« no previous file with comments | « third_party/WebKit/LayoutTests/webshare/share-without-user-gesture.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698