| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "config.h" | 5 #include "config.h" |
| 6 #include "modules/presentation/Presentation.h" | 6 #include "modules/presentation/Presentation.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/ScriptPromise.h" | 8 #include "bindings/core/v8/ScriptPromise.h" |
| 9 #include "bindings/core/v8/ScriptPromiseResolver.h" | 9 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 10 #include "bindings/core/v8/ScriptState.h" | 10 #include "bindings/core/v8/ScriptState.h" |
| 11 #include "core/dom/DOMException.h" | 11 #include "core/dom/DOMException.h" |
| 12 #include "core/dom/Document.h" | 12 #include "core/dom/Document.h" |
| 13 #include "core/dom/ExceptionCode.h" | 13 #include "core/dom/ExceptionCode.h" |
| 14 #include "core/frame/LocalFrame.h" | 14 #include "core/frame/LocalFrame.h" |
| 15 #include "modules/EventTargetModules.h" | 15 #include "modules/EventTargetModules.h" |
| 16 #include "modules/presentation/AvailableChangeEvent.h" | 16 #include "modules/presentation/AvailableChangeEvent.h" |
| 17 #include "modules/presentation/DefaultSessionStartEvent.h" | 17 #include "modules/presentation/DefaultSessionStartEvent.h" |
| 18 #include "modules/presentation/PresentationController.h" | 18 #include "modules/presentation/PresentationController.h" |
| 19 #include "modules/presentation/PresentationSessionClientCallbacks.h" | 19 #include "modules/presentation/PresentationSessionClientCallbacks.h" |
| 20 #include "public/platform/modules/presentation/WebPresentationSessionClient.h" |
| 20 | 21 |
| 21 namespace blink { | 22 namespace blink { |
| 22 | 23 |
| 23 Presentation::Presentation(LocalFrame* frame) | 24 Presentation::Presentation(LocalFrame* frame) |
| 24 : DOMWindowProperty(frame) | 25 : DOMWindowProperty(frame) |
| 25 { | 26 { |
| 26 } | 27 } |
| 27 | 28 |
| 28 Presentation::~Presentation() | 29 Presentation::~Presentation() |
| 29 { | 30 { |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 bool Presentation::isAvailableChangeWatched() const | 145 bool Presentation::isAvailableChangeWatched() const |
| 145 { | 146 { |
| 146 return hasEventListeners(EventTypeNames::availablechange); | 147 return hasEventListeners(EventTypeNames::availablechange); |
| 147 } | 148 } |
| 148 | 149 |
| 149 void Presentation::didStartDefaultSession(PresentationSession* session) | 150 void Presentation::didStartDefaultSession(PresentationSession* session) |
| 150 { | 151 { |
| 151 dispatchEvent(DefaultSessionStartEvent::create(EventTypeNames::defaultsessio
nstart, session)); | 152 dispatchEvent(DefaultSessionStartEvent::create(EventTypeNames::defaultsessio
nstart, session)); |
| 152 } | 153 } |
| 153 | 154 |
| 155 void Presentation::didChangeSessionState(WebPresentationSessionClient* sessionCl
ient, WebPresentationSessionState sessionState) |
| 156 { |
| 157 PresentationSession* session = findSession(sessionClient); |
| 158 if (session) |
| 159 session->didChangeState(sessionState); |
| 160 |
| 161 PresentationSession::dispose(sessionClient); |
| 162 } |
| 163 |
| 154 void Presentation::registerSession(PresentationSession* session) | 164 void Presentation::registerSession(PresentationSession* session) |
| 155 { | 165 { |
| 156 m_openSessions.add(session); | 166 m_openSessions.add(session); |
| 157 } | 167 } |
| 158 | 168 |
| 159 PresentationController* Presentation::presentationController() | 169 PresentationController* Presentation::presentationController() |
| 160 { | 170 { |
| 161 if (!frame()) | 171 if (!frame()) |
| 162 return nullptr; | 172 return nullptr; |
| 163 return PresentationController::from(*frame()); | 173 return PresentationController::from(*frame()); |
| 164 } | 174 } |
| 165 | 175 |
| 176 PresentationSession* Presentation::findSession(WebPresentationSessionClient* ses
sionClient) |
| 177 { |
| 178 for (const auto& session : m_openSessions) { |
| 179 if (session->matches(sessionClient)) |
| 180 return session.get(); |
| 181 } |
| 182 return nullptr; |
| 183 } |
| 184 |
| 166 } // namespace blink | 185 } // namespace blink |
| OLD | NEW |