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/DOMWindow.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 : DOMWindowProperty(frame) { | 22 : DOMWindowProperty(frame) { |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 52 return; | 53 return; |
| 53 | 54 |
| 54 if (m_connectionListProperty->getState() == | 55 if (m_connectionListProperty->getState() == |
| 55 ScriptPromisePropertyBase::Pending) | 56 ScriptPromisePropertyBase::Pending) |
| 56 m_connectionListProperty->resolve(m_connectionList); | 57 m_connectionListProperty->resolve(m_connectionList); |
| 57 else if (m_connectionListProperty->getState() == | 58 else if (m_connectionListProperty->getState() == |
| 58 ScriptPromisePropertyBase::Resolved) | 59 ScriptPromisePropertyBase::Resolved) |
| 59 m_connectionList->dispatchConnectionAvailableEvent(connection); | 60 m_connectionList->dispatchConnectionAvailableEvent(connection); |
| 60 } | 61 } |
| 61 | 62 |
| 63 void PresentationReceiver::didChangeSessionState( | |
| 64 WebPresentationConnectionState state) { | |
| 65 DCHECK(state == WebPresentationConnectionState::Terminated); | |
| 66 | |
| 67 for (auto connection : m_connectionList->connections()) | |
| 68 connection->didChangeState(state); | |
| 69 } | |
| 70 | |
| 71 void PresentationReceiver::closeWindow() { | |
| 72 DOMWindow* window = frame()->domWindow(); | |
| 73 if (!window->closed()) | |
|
haraken
2016/11/08 23:44:50
You need to check if frame(), frame()->domWindow()
zhaobin
2016/11/09 03:40:12
Done.
| |
| 74 window->close(frame()->document()); | |
| 75 } | |
| 76 | |
| 62 void PresentationReceiver::registerConnection( | 77 void PresentationReceiver::registerConnection( |
| 63 PresentationConnection* connection) { | 78 PresentationConnection* connection) { |
| 64 DCHECK(m_connectionList); | 79 DCHECK(m_connectionList); |
| 65 m_connectionList->addConnection(connection); | 80 m_connectionList->addConnection(connection); |
| 66 } | 81 } |
| 67 | 82 |
| 68 DEFINE_TRACE(PresentationReceiver) { | 83 DEFINE_TRACE(PresentationReceiver) { |
| 69 visitor->trace(m_connectionList); | 84 visitor->trace(m_connectionList); |
| 70 visitor->trace(m_connectionListProperty); | 85 visitor->trace(m_connectionListProperty); |
| 71 DOMWindowProperty::trace(visitor); | 86 DOMWindowProperty::trace(visitor); |
| 72 } | 87 } |
| 73 } // namespace blink | 88 } // namespace blink |
| OLD | NEW |