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

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

Issue 2207343002: Update navigator.share API to match draft specs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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 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"
11 #include "core/frame/Navigator.h" 11 #include "core/frame/Navigator.h"
12 #include "modules/webshare/ShareData.h"
12 #include "platform/mojo/MojoHelper.h" 13 #include "platform/mojo/MojoHelper.h"
13 #include "public/platform/InterfaceProvider.h" 14 #include "public/platform/InterfaceProvider.h"
14 #include "public/platform/Platform.h" 15 #include "public/platform/Platform.h"
15 16
16 namespace blink { 17 namespace blink {
17 18
18 class NavigatorShare::ShareClientImpl final : public GarbageCollected<ShareClien tImpl> { 19 class NavigatorShare::ShareClientImpl final : public GarbageCollected<ShareClien tImpl> {
19 public: 20 public:
20 ShareClientImpl(NavigatorShare*, ScriptPromiseResolver*); 21 ShareClientImpl(NavigatorShare*, ScriptPromiseResolver*);
21 22
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 72
72 NavigatorShare::NavigatorShare() 73 NavigatorShare::NavigatorShare()
73 { 74 {
74 } 75 }
75 76
76 const char* NavigatorShare::supplementName() 77 const char* NavigatorShare::supplementName()
77 { 78 {
78 return "NavigatorShare"; 79 return "NavigatorShare";
79 } 80 }
80 81
81 ScriptPromise NavigatorShare::share(ScriptState* scriptState, const String& titl e, const String& text) 82 ScriptPromise NavigatorShare::share(ScriptState* scriptState, const ShareData& s hareData)
82 { 83 {
83 if (!m_service) { 84 if (!m_service) {
84 Document* doc = toDocument(scriptState->getExecutionContext()); 85 Document* doc = toDocument(scriptState->getExecutionContext());
85 DCHECK(doc); 86 DCHECK(doc);
86 LocalFrame* frame = doc->frame(); 87 LocalFrame* frame = doc->frame();
87 DCHECK(frame); 88 DCHECK(frame);
88 frame->interfaceProvider()->getInterface(mojo::GetProxy(&m_service)); 89 frame->interfaceProvider()->getInterface(mojo::GetProxy(&m_service));
89 DCHECK(m_service); 90 DCHECK(m_service);
90 } 91 }
91 92
92 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ; 93 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ;
93 ShareClientImpl* client = new ShareClientImpl(this, resolver); 94 ShareClientImpl* client = new ShareClientImpl(this, resolver);
94 m_clients.add(client); 95 m_clients.add(client);
95 ScriptPromise promise = resolver->promise(); 96 ScriptPromise promise = resolver->promise();
96 97
97 m_service->Share(title, text, convertToBaseCallback(WTF::bind(&ShareClientIm pl::callback, wrapPersistent(client)))); 98 // TODO(sammc): Use shareData.url().
99 m_service->Share(shareData.hasTitle() ? shareData.title() : emptyString(), s hareData.hasText() ? shareData.text() : emptyString(), convertToBaseCallback(WTF ::bind(&ShareClientImpl::callback, wrapPersistent(client))));
98 100
99 return promise; 101 return promise;
100 } 102 }
101 103
102 ScriptPromise NavigatorShare::share(ScriptState* scriptState, Navigator& navigat or, const String& title, const String& text) 104 ScriptPromise NavigatorShare::share(ScriptState* scriptState, Navigator& navigat or, const ShareData& shareData)
103 { 105 {
104 return from(navigator).share(scriptState, title, text); 106 return from(navigator).share(scriptState, shareData);
105 } 107 }
106 108
107 } // namespace blink 109 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698