Index: Source/modules/presentation/PresentationController.cpp |
diff --git a/Source/modules/presentation/PresentationController.cpp b/Source/modules/presentation/PresentationController.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..282ff97c76bb273fb2cfd4f71cbf8962f6247204 |
--- /dev/null |
+++ b/Source/modules/presentation/PresentationController.cpp |
@@ -0,0 +1,96 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "config.h" |
+#include "modules/presentation/PresentationController.h" |
+ |
+#include "core/frame/LocalFrame.h" |
+#include "public/platform/WebPresentationClient.h" |
+#include "public/platform/WebPresentationController.h" |
+ |
+namespace blink { |
+ |
+PresentationController::PresentationController(LocalFrame& frame, WebPresentationClient* client) |
+ : FrameDestructionObserver(&frame) |
+ , m_client(client) |
+{ |
+ if (m_client) |
+ m_client->setController(this); |
+} |
+ |
+PresentationController::~PresentationController() |
+{ |
+ if (m_client) |
+ m_client->setController(nullptr); |
+} |
+ |
+// static |
+PassOwnPtrWillBeRawPtr<PresentationController> PresentationController::create(LocalFrame& frame, WebPresentationClient* client) |
+{ |
+ return adoptPtrWillBeNoop(new PresentationController(frame, client)); |
+} |
+ |
+// static |
+const char* PresentationController::supplementName() |
+{ |
+ return "PresentationController"; |
+} |
+ |
+// static |
+PresentationController* PresentationController::from(LocalFrame& frame) |
+{ |
+ return static_cast<PresentationController*>(WillBeHeapSupplement<LocalFrame>::from(frame, supplementName())); |
+} |
+ |
+// static |
+void PresentationController::provideTo(LocalFrame& frame, WebPresentationClient* client) |
+{ |
+ WillBeHeapSupplement<LocalFrame>::provideTo(frame, PresentationController::supplementName(), PresentationController::create(frame, client)); |
+} |
+ |
+void PresentationController::trace(Visitor* visitor) |
+{ |
+ visitor->trace(m_presentation); |
+ WillBeHeapSupplement<LocalFrame>::trace(visitor); |
+ FrameDestructionObserver::trace(visitor); |
+} |
+ |
+void PresentationController::didChangeAvailability(bool available) |
+{ |
+ if (m_presentation) |
+ m_presentation->didChangeAvailability(available); |
+} |
+ |
+bool PresentationController::isAvailableChangeWatched() const |
+{ |
+ if (!m_presentation) |
+ return false; |
+ return m_presentation->isAvailableChangeWatched(); |
+} |
+ |
+void PresentationController::onClientDestroyed() |
+{ |
+ m_client = nullptr; |
+} |
+ |
+void PresentationController::updateAvailableChangeWatched(bool watched) |
+{ |
+ if (m_client) |
+ m_client->updateAvailableChangeWatched(watched); |
+} |
+ |
+void PresentationController::setPresentation(Presentation* presentation) |
+{ |
+ m_presentation = presentation; |
+} |
+ |
+void PresentationController::willDetachFrameHost() |
+{ |
+ if (m_client) { |
+ m_client->setController(nullptr); |
+ m_client = nullptr; |
+ } |
+} |
+ |
+} // namespace blink |