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

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

Issue 2801823003: [Presentation API] Change connection to 'connected' if start a presentation with "https://www.googl… (Closed)
Patch Set: resolve code review comments from Mark Created 3 years, 8 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/LocalDOMWindow.h" 12 #include "core/frame/LocalDOMWindow.h"
13 #include "core/frame/LocalFrame.h" 13 #include "core/frame/LocalFrame.h"
14 #include "core/frame/Navigator.h"
14 #include "core/frame/UseCounter.h" 15 #include "core/frame/UseCounter.h"
16 #include "modules/presentation/NavigatorPresentation.h"
17 #include "modules/presentation/Presentation.h"
15 #include "modules/presentation/PresentationConnection.h" 18 #include "modules/presentation/PresentationConnection.h"
16 #include "modules/presentation/PresentationConnectionList.h" 19 #include "modules/presentation/PresentationConnectionList.h"
17 #include "public/platform/modules/presentation/WebPresentationClient.h" 20 #include "public/platform/modules/presentation/WebPresentationClient.h"
18 21
19 namespace blink { 22 namespace blink {
20 23
21 PresentationReceiver::PresentationReceiver(LocalFrame* frame, 24 PresentationReceiver::PresentationReceiver(LocalFrame* frame,
22 WebPresentationClient* client) 25 WebPresentationClient* client)
23 : ContextClient(frame) { 26 : ContextClient(frame) {
24 recordOriginTypeAccess(frame->document()); 27 recordOriginTypeAccess(frame->document());
25 m_connectionList = new PresentationConnectionList(frame->document()); 28 m_connectionList = new PresentationConnectionList(frame->document());
26 29
27 if (client) 30 if (client)
28 client->setReceiver(this); 31 client->setReceiver(this);
29 } 32 }
30 33
34 // static
35 PresentationReceiver* PresentationReceiver::from(Document& document) {
36 if (!document.frame() || !document.frame()->domWindow())
37 return nullptr;
38 Navigator& navigator = *document.frame()->domWindow()->navigator();
39 Presentation* presentation = NavigatorPresentation::presentation(navigator);
40 if (!presentation)
41 return nullptr;
42
43 return presentation->receiver();
44 }
45
31 ScriptPromise PresentationReceiver::connectionList(ScriptState* scriptState) { 46 ScriptPromise PresentationReceiver::connectionList(ScriptState* scriptState) {
32 if (!m_connectionListProperty) 47 if (!m_connectionListProperty)
33 m_connectionListProperty = 48 m_connectionListProperty =
34 new ConnectionListProperty(scriptState->getExecutionContext(), this, 49 new ConnectionListProperty(scriptState->getExecutionContext(), this,
35 ConnectionListProperty::Ready); 50 ConnectionListProperty::Ready);
36 51
37 if (!m_connectionList->isEmpty() && 52 if (!m_connectionList->isEmpty() &&
38 m_connectionListProperty->getState() == 53 m_connectionListProperty->getState() ==
39 ScriptPromisePropertyBase::Pending) 54 ScriptPromisePropertyBase::Pending)
40 m_connectionListProperty->resolve(m_connectionList); 55 m_connectionListProperty->resolve(m_connectionList);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 } 114 }
100 } 115 }
101 116
102 DEFINE_TRACE(PresentationReceiver) { 117 DEFINE_TRACE(PresentationReceiver) {
103 visitor->trace(m_connectionList); 118 visitor->trace(m_connectionList);
104 visitor->trace(m_connectionListProperty); 119 visitor->trace(m_connectionListProperty);
105 ContextClient::trace(visitor); 120 ContextClient::trace(visitor);
106 } 121 }
107 122
108 } // namespace blink 123 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698