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

Side by Side Diff: third_party/WebKit/Source/modules/webshare/NavigatorShare.cpp

Issue 2349253004: Restrict WebShare to secure contexts. (Closed)
Patch Set: Created 4 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "modules/webshare/NavigatorShare.h" 5 #include "modules/webshare/NavigatorShare.h"
6 6
7 #include "core/dom/DOMException.h" 7 #include "core/dom/DOMException.h"
8 #include "core/dom/Document.h" 8 #include "core/dom/Document.h"
9 #include "core/dom/ExceptionCode.h" 9 #include "core/dom/ExceptionCode.h"
10 #include "core/frame/LocalFrame.h" 10 #include "core/frame/LocalFrame.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 { 75 {
76 } 76 }
77 77
78 const char* NavigatorShare::supplementName() 78 const char* NavigatorShare::supplementName()
79 { 79 {
80 return "NavigatorShare"; 80 return "NavigatorShare";
81 } 81 }
82 82
83 ScriptPromise NavigatorShare::share(ScriptState* scriptState, const ShareData& s hareData) 83 ScriptPromise NavigatorShare::share(ScriptState* scriptState, const ShareData& s hareData)
84 { 84 {
85 String errorMessage;
86 if (!scriptState->getExecutionContext()->isSecureContext(errorMessage)) {
87 DOMException* error = DOMException::create(SecurityError, errorMessage);
88 return ScriptPromise::rejectWithDOMException(scriptState, error);
89 }
85 if (!UserGestureIndicator::utilizeUserGesture()) { 90 if (!UserGestureIndicator::utilizeUserGesture()) {
86 DOMException* error = DOMException::create(SecurityError, "Must be handl ing a user gesture to perform a share request."); 91 DOMException* error = DOMException::create(SecurityError, "Must be handl ing a user gesture to perform a share request.");
87 return ScriptPromise::rejectWithDOMException(scriptState, error); 92 return ScriptPromise::rejectWithDOMException(scriptState, error);
88 } 93 }
89 94
90 Document* doc = toDocument(scriptState->getExecutionContext()); 95 Document* doc = toDocument(scriptState->getExecutionContext());
91 DCHECK(doc); 96 DCHECK(doc);
92 if (!m_service) { 97 if (!m_service) {
93 LocalFrame* frame = doc->frame(); 98 LocalFrame* frame = doc->frame();
94 DCHECK(frame); 99 DCHECK(frame);
(...skipping 14 matching lines...) Expand all
109 114
110 return promise; 115 return promise;
111 } 116 }
112 117
113 ScriptPromise NavigatorShare::share(ScriptState* scriptState, Navigator& navigat or, const ShareData& shareData) 118 ScriptPromise NavigatorShare::share(ScriptState* scriptState, Navigator& navigat or, const ShareData& shareData)
114 { 119 {
115 return from(navigator).share(scriptState, shareData); 120 return from(navigator).share(scriptState, shareData);
116 } 121 }
117 122
118 } // namespace blink 123 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/security/powerfulFeatureRestrictions/webshare-on-insecure-origin.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698