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

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

Issue 2309403002: Use the URL passed to navigator.share(). (Closed)
Patch Set: rebase 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 if (!UserGestureIndicator::utilizeUserGesture()) { 85 if (!UserGestureIndicator::utilizeUserGesture()) {
86 DOMException* error = DOMException::create(SecurityError, "Must be handl ing a user gesture to perform a share request."); 86 DOMException* error = DOMException::create(SecurityError, "Must be handl ing a user gesture to perform a share request.");
87 return ScriptPromise::rejectWithDOMException(scriptState, error); 87 return ScriptPromise::rejectWithDOMException(scriptState, error);
88 } 88 }
89 89
90 Document* doc = toDocument(scriptState->getExecutionContext());
91 DCHECK(doc);
90 if (!m_service) { 92 if (!m_service) {
91 Document* doc = toDocument(scriptState->getExecutionContext());
92 DCHECK(doc);
93 LocalFrame* frame = doc->frame(); 93 LocalFrame* frame = doc->frame();
94 DCHECK(frame); 94 DCHECK(frame);
95 frame->interfaceProvider()->getInterface(mojo::GetProxy(&m_service)); 95 frame->interfaceProvider()->getInterface(mojo::GetProxy(&m_service));
96 DCHECK(m_service); 96 DCHECK(m_service);
97 } 97 }
98 98
99 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ; 99 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ;
100 ShareClientImpl* client = new ShareClientImpl(this, resolver); 100 ShareClientImpl* client = new ShareClientImpl(this, resolver);
101 m_clients.add(client); 101 m_clients.add(client);
102 ScriptPromise promise = resolver->promise(); 102 ScriptPromise promise = resolver->promise();
103 103
104 // TODO(sammc): Use shareData.url(). 104 m_service->Share(
105 m_service->Share(shareData.hasTitle() ? shareData.title() : emptyString(), s hareData.hasText() ? shareData.text() : emptyString(), convertToBaseCallback(WTF ::bind(&ShareClientImpl::callback, wrapPersistent(client)))); 105 shareData.hasTitle() ? shareData.title() : emptyString(),
106 shareData.hasText() ? shareData.text() : emptyString(),
107 doc->completeURL(shareData.url()),
108 convertToBaseCallback(WTF::bind(&ShareClientImpl::callback, wrapPersiste nt(client))));
106 109
107 return promise; 110 return promise;
108 } 111 }
109 112
110 ScriptPromise NavigatorShare::share(ScriptState* scriptState, Navigator& navigat or, const ShareData& shareData) 113 ScriptPromise NavigatorShare::share(ScriptState* scriptState, Navigator& navigat or, const ShareData& shareData)
111 { 114 {
112 return from(navigator).share(scriptState, shareData); 115 return from(navigator).share(scriptState, shareData);
113 } 116 }
114 117
115 } // namespace blink 118 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/webshare/share-without-user-gesture.html ('k') | third_party/WebKit/public/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698