Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1489)

Unified Diff: Source/modules/presentation/PresentationController.cpp

Issue 832263007: Added plumbing for the availablechange event from Blink to WebPresentationClient. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Added onClientDestroyed Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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
« no previous file with comments | « Source/modules/presentation/PresentationController.h ('k') | Source/modules/presentation/PresentationSession.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698