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

Side by Side Diff: third_party/WebKit/Source/modules/presentation/PresentationReceiver.cpp

Issue 2692333004: [Presentation API] Adds UseCounters for origin types. (Closed)
Patch Set: Created 3 years, 10 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/presentation/PresentationReceiver.h" 5 #include "modules/presentation/PresentationReceiver.h"
6 6
7 #include "bindings/core/v8/ScriptPromise.h" 7 #include "bindings/core/v8/ScriptPromise.h"
8 #include "bindings/core/v8/ScriptPromiseResolver.h" 8 #include "bindings/core/v8/ScriptPromiseResolver.h"
9 #include "core/dom/DOMException.h" 9 #include "core/dom/DOMException.h"
10 #include "core/dom/Document.h" 10 #include "core/dom/Document.h"
11 #include "core/dom/ExceptionCode.h" 11 #include "core/dom/ExceptionCode.h"
12 #include "core/frame/LocalFrame.h" 12 #include "core/frame/LocalFrame.h"
13 #include "core/frame/UseCounter.h"
13 #include "modules/presentation/PresentationConnection.h" 14 #include "modules/presentation/PresentationConnection.h"
14 #include "modules/presentation/PresentationConnectionList.h" 15 #include "modules/presentation/PresentationConnectionList.h"
15 #include "public/platform/modules/presentation/WebPresentationClient.h" 16 #include "public/platform/modules/presentation/WebPresentationClient.h"
16 17
17 namespace blink { 18 namespace blink {
18 19
19 PresentationReceiver::PresentationReceiver(LocalFrame* frame, 20 PresentationReceiver::PresentationReceiver(LocalFrame* frame,
20 WebPresentationClient* client) 21 WebPresentationClient* client)
21 : ContextClient(frame) { 22 : ContextClient(frame) {
23 recordOriginTypeAccess(frame->document());
22 m_connectionList = new PresentationConnectionList(frame->document()); 24 m_connectionList = new PresentationConnectionList(frame->document());
23 25
24 if (client) 26 if (client)
25 client->setReceiver(this); 27 client->setReceiver(this);
26 } 28 }
27 29
28 ScriptPromise PresentationReceiver::connectionList(ScriptState* scriptState) { 30 ScriptPromise PresentationReceiver::connectionList(ScriptState* scriptState) {
29 if (!m_connectionListProperty) 31 if (!m_connectionListProperty)
30 m_connectionListProperty = 32 m_connectionListProperty =
31 new ConnectionListProperty(scriptState->getExecutionContext(), this, 33 new ConnectionListProperty(scriptState->getExecutionContext(), this,
(...skipping 26 matching lines...) Expand all
58 60
59 return connection; 61 return connection;
60 } 62 }
61 63
62 void PresentationReceiver::registerConnection( 64 void PresentationReceiver::registerConnection(
63 PresentationConnection* connection) { 65 PresentationConnection* connection) {
64 DCHECK(m_connectionList); 66 DCHECK(m_connectionList);
65 m_connectionList->addConnection(connection); 67 m_connectionList->addConnection(connection);
66 } 68 }
67 69
70 void PresentationReceiver::recordOriginTypeAccess(Document* document) const {
71 DCHECK(document);
72 if (document->isSecureContext()) {
73 UseCounter::count(document, UseCounter::PresentationReceiverSecureOrigin);
74 } else {
75 UseCounter::count(document, UseCounter::PresentationReceiverInsecureOrigin);
76 }
77 }
78
68 DEFINE_TRACE(PresentationReceiver) { 79 DEFINE_TRACE(PresentationReceiver) {
69 visitor->trace(m_connectionList); 80 visitor->trace(m_connectionList);
70 visitor->trace(m_connectionListProperty); 81 visitor->trace(m_connectionListProperty);
71 ContextClient::trace(visitor); 82 ContextClient::trace(visitor);
72 } 83 }
73 84
74 } // namespace blink 85 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698