OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "config.h" |
| 6 #include "modules/presentation/PresentationController.h" |
| 7 |
| 8 #include "core/frame/LocalFrame.h" |
| 9 #include "public/platform/WebPresentationClient.h" |
| 10 #include "public/platform/WebPresentationController.h" |
| 11 |
| 12 namespace blink { |
| 13 |
| 14 PresentationController::PresentationController(LocalFrame& frame, WebPresentatio
nClient* client) |
| 15 : FrameDestructionObserver(&frame) |
| 16 , m_client(client) |
| 17 { |
| 18 if (m_client) |
| 19 m_client->setController(this); |
| 20 } |
| 21 |
| 22 PresentationController::~PresentationController() |
| 23 { |
| 24 if (m_client) |
| 25 m_client->setController(nullptr); |
| 26 } |
| 27 |
| 28 // static |
| 29 PassOwnPtrWillBeRawPtr<PresentationController> PresentationController::create(Lo
calFrame& frame, WebPresentationClient* client) |
| 30 { |
| 31 return adoptPtrWillBeNoop(new PresentationController(frame, client)); |
| 32 } |
| 33 |
| 34 // static |
| 35 const char* PresentationController::supplementName() |
| 36 { |
| 37 return "PresentationController"; |
| 38 } |
| 39 |
| 40 // static |
| 41 PresentationController* PresentationController::from(LocalFrame& frame) |
| 42 { |
| 43 return static_cast<PresentationController*>(WillBeHeapSupplement<LocalFrame>
::from(frame, supplementName())); |
| 44 } |
| 45 |
| 46 // static |
| 47 void PresentationController::provideTo(LocalFrame& frame, WebPresentationClient*
client) |
| 48 { |
| 49 WillBeHeapSupplement<LocalFrame>::provideTo(frame, PresentationController::s
upplementName(), PresentationController::create(frame, client)); |
| 50 } |
| 51 |
| 52 void PresentationController::trace(Visitor* visitor) |
| 53 { |
| 54 visitor->trace(m_presentation); |
| 55 WillBeHeapSupplement<LocalFrame>::trace(visitor); |
| 56 FrameDestructionObserver::trace(visitor); |
| 57 } |
| 58 |
| 59 void PresentationController::didChangeAvailability(bool available) |
| 60 { |
| 61 if (m_presentation) |
| 62 m_presentation->didChangeAvailability(available); |
| 63 } |
| 64 |
| 65 bool PresentationController::isAvailableChangeWatched() const |
| 66 { |
| 67 if (!m_presentation) |
| 68 return false; |
| 69 return m_presentation->isAvailableChangeWatched(); |
| 70 } |
| 71 |
| 72 void PresentationController::onClientDestroyed() |
| 73 { |
| 74 m_client = nullptr; |
| 75 } |
| 76 |
| 77 void PresentationController::updateAvailableChangeWatched(bool watched) |
| 78 { |
| 79 if (m_client) |
| 80 m_client->updateAvailableChangeWatched(watched); |
| 81 } |
| 82 |
| 83 void PresentationController::setPresentation(Presentation* presentation) |
| 84 { |
| 85 m_presentation = presentation; |
| 86 } |
| 87 |
| 88 void PresentationController::willDetachFrameHost() |
| 89 { |
| 90 if (m_client) { |
| 91 m_client->setController(nullptr); |
| 92 m_client = nullptr; |
| 93 } |
| 94 } |
| 95 |
| 96 } // namespace blink |
OLD | NEW |