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

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

Issue 2234723002: Added UseCounter for navigator.share (WebShareShare). (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 "core/frame/UseCounter.h"
12 #include "modules/webshare/ShareData.h" 13 #include "modules/webshare/ShareData.h"
13 #include "platform/mojo/MojoHelper.h" 14 #include "platform/mojo/MojoHelper.h"
14 #include "public/platform/InterfaceProvider.h" 15 #include "public/platform/InterfaceProvider.h"
15 #include "public/platform/Platform.h" 16 #include "public/platform/Platform.h"
16 17
17 namespace blink { 18 namespace blink {
18 19
19 class NavigatorShare::ShareClientImpl final : public GarbageCollected<ShareClien tImpl> { 20 class NavigatorShare::ShareClientImpl final : public GarbageCollected<ShareClien tImpl> {
20 public: 21 public:
21 ShareClientImpl(NavigatorShare*, ScriptPromiseResolver*); 22 ShareClientImpl(NavigatorShare*, ScriptPromiseResolver*);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 { 75 {
75 } 76 }
76 77
77 const char* NavigatorShare::supplementName() 78 const char* NavigatorShare::supplementName()
78 { 79 {
79 return "NavigatorShare"; 80 return "NavigatorShare";
80 } 81 }
81 82
82 ScriptPromise NavigatorShare::share(ScriptState* scriptState, const ShareData& s hareData) 83 ScriptPromise NavigatorShare::share(ScriptState* scriptState, const ShareData& s hareData)
83 { 84 {
85 Document* doc = toDocument(scriptState->getExecutionContext());
86 DCHECK(doc);
87 UseCounter::count(doc, UseCounter::WebShareShare);
esprehn 2016/08/10 17:58:58 You're actually calling the ExecutionContext versi
Matt Giuca 2016/08/11 03:33:17 D'oh. That's pretty confusing (I was deliberately
88
84 if (!m_service) { 89 if (!m_service) {
85 Document* doc = toDocument(scriptState->getExecutionContext());
86 DCHECK(doc);
87 LocalFrame* frame = doc->frame(); 90 LocalFrame* frame = doc->frame();
88 DCHECK(frame); 91 DCHECK(frame);
89 frame->interfaceProvider()->getInterface(mojo::GetProxy(&m_service)); 92 frame->interfaceProvider()->getInterface(mojo::GetProxy(&m_service));
90 DCHECK(m_service); 93 DCHECK(m_service);
91 } 94 }
92 95
93 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ; 96 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ;
94 ShareClientImpl* client = new ShareClientImpl(this, resolver); 97 ShareClientImpl* client = new ShareClientImpl(this, resolver);
95 m_clients.add(client); 98 m_clients.add(client);
96 ScriptPromise promise = resolver->promise(); 99 ScriptPromise promise = resolver->promise();
97 100
98 // TODO(sammc): Use shareData.url(). 101 // 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)))); 102 m_service->Share(shareData.hasTitle() ? shareData.title() : emptyString(), s hareData.hasText() ? shareData.text() : emptyString(), convertToBaseCallback(WTF ::bind(&ShareClientImpl::callback, wrapPersistent(client))));
100 103
101 return promise; 104 return promise;
102 } 105 }
103 106
104 ScriptPromise NavigatorShare::share(ScriptState* scriptState, Navigator& navigat or, const ShareData& shareData) 107 ScriptPromise NavigatorShare::share(ScriptState* scriptState, Navigator& navigat or, const ShareData& shareData)
105 { 108 {
106 return from(navigator).share(scriptState, shareData); 109 return from(navigator).share(scriptState, shareData);
107 } 110 }
108 111
109 } // namespace blink 112 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/UseCounter.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698