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/presentation/PresentationReceiver.cpp

Issue 2801823003: [Presentation API] Change connection to 'connected' if start a presentation with "https://www.googl… (Closed)
Patch Set: fix windows compile error 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->GetDocument()); 27 RecordOriginTypeAccess(frame->GetDocument());
25 connection_list_ = new PresentationConnectionList(frame->GetDocument()); 28 connection_list_ = new PresentationConnectionList(frame->GetDocument());
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.GetFrame() || !document.GetFrame()->DomWindow())
37 return nullptr;
38 Navigator& navigator = *document.GetFrame()->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* script_state) { 46 ScriptPromise PresentationReceiver::connectionList(ScriptState* script_state) {
32 if (!connection_list_property_) 47 if (!connection_list_property_)
33 connection_list_property_ = 48 connection_list_property_ =
34 new ConnectionListProperty(script_state->GetExecutionContext(), this, 49 new ConnectionListProperty(script_state->GetExecutionContext(), this,
35 ConnectionListProperty::kReady); 50 ConnectionListProperty::kReady);
36 51
37 if (!connection_list_->IsEmpty() && connection_list_property_->GetState() == 52 if (!connection_list_->IsEmpty() && connection_list_property_->GetState() ==
38 ScriptPromisePropertyBase::kPending) 53 ScriptPromisePropertyBase::kPending)
39 connection_list_property_->Resolve(connection_list_); 54 connection_list_property_->Resolve(connection_list_);
40 55
(...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(connection_list_); 118 visitor->Trace(connection_list_);
104 visitor->Trace(connection_list_property_); 119 visitor->Trace(connection_list_property_);
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