Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/LocalFrame.h" | 13 #include "core/frame/LocalFrame.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) { |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 52 if (m_connectionListProperty->getState() == | 53 if (m_connectionListProperty->getState() == |
| 53 ScriptPromisePropertyBase::Pending) | 54 ScriptPromisePropertyBase::Pending) |
| 54 m_connectionListProperty->resolve(m_connectionList); | 55 m_connectionListProperty->resolve(m_connectionList); |
| 55 else if (m_connectionListProperty->getState() == | 56 else if (m_connectionListProperty->getState() == |
| 56 ScriptPromisePropertyBase::Resolved) | 57 ScriptPromisePropertyBase::Resolved) |
| 57 m_connectionList->dispatchConnectionAvailableEvent(connection); | 58 m_connectionList->dispatchConnectionAvailableEvent(connection); |
| 58 | 59 |
| 59 return connection; | 60 return connection; |
| 60 } | 61 } |
| 61 | 62 |
| 63 void PresentationReceiver::didChangeSessionState( | |
| 64 WebPresentationConnectionState state) { | |
| 65 // TODO(zhaobin): remove or modify DCHECK when receiver supports more | |
| 66 // connection state change. | |
| 67 DCHECK(state == WebPresentationConnectionState::Terminated); | |
| 68 | |
| 69 for (auto connection : m_connectionList->connections()) | |
| 70 connection->didChangeState(state); | |
|
mark a. foltz
2017/02/25 01:43:12
Will this fire a terminated event on the receiver
zhaobin
2017/02/28 04:25:19
Done.
| |
| 71 } | |
| 72 | |
| 73 void PresentationReceiver::closeWindow() { | |
| 74 if (!frame()) | |
| 75 return; | |
| 76 | |
| 77 auto* window = frame()->domWindow(); | |
| 78 if (!window || window->closed()) | |
| 79 return; | |
| 80 | |
| 81 window->close(frame()->document()); | |
| 82 } | |
| 83 | |
| 62 void PresentationReceiver::registerConnection( | 84 void PresentationReceiver::registerConnection( |
| 63 PresentationConnection* connection) { | 85 PresentationConnection* connection) { |
| 64 DCHECK(m_connectionList); | 86 DCHECK(m_connectionList); |
| 65 m_connectionList->addConnection(connection); | 87 m_connectionList->addConnection(connection); |
| 66 } | 88 } |
| 67 | 89 |
| 68 DEFINE_TRACE(PresentationReceiver) { | 90 DEFINE_TRACE(PresentationReceiver) { |
| 69 visitor->trace(m_connectionList); | 91 visitor->trace(m_connectionList); |
| 70 visitor->trace(m_connectionListProperty); | 92 visitor->trace(m_connectionListProperty); |
| 71 ContextClient::trace(visitor); | 93 ContextClient::trace(visitor); |
| 72 } | 94 } |
| 73 | 95 |
| 74 } // namespace blink | 96 } // namespace blink |
| OLD | NEW |