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..138c08d449128a832dd8d118d882cc62dcfc3eb8 |
--- /dev/null |
+++ b/Source/modules/presentation/PresentationController.cpp |
@@ -0,0 +1,80 @@ |
+// 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) |
+ : 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); |
+} |
+ |
+void PresentationController::deviceAvailabilityChanged(bool available) |
+{ |
+ if (m_presentation) |
Peter Beverloo
2015/01/07 14:29:09
Should we get this event if there is no m_presenta
whywhat
2015/01/07 16:22:16
Done.
|
+ m_presentation->deviceAvailabilityChanged(available); |
+} |
+ |
+void PresentationController::addDeviceAvailabilityListener() |
+{ |
+ if (m_client) |
+ m_client->addDeviceAvailabilityListener(); |
Peter Beverloo
2015/01/07 14:29:09
Hm, so the embedder is responsible for doing some
whywhat
2015/01/07 16:22:16
In general, the embedder should care if there's an
Peter Beverloo
2015/01/07 19:53:11
In order to keep information local, we should only
whywhat
2015/01/08 16:05:28
Done.
|
+} |
+ |
+void PresentationController::removeDeviceAvailabilityListener() |
+{ |
+ if (m_client) |
+ m_client->removeDeviceAvailabilityListener(); |
+} |
+ |
+void PresentationController::setPresentation(Presentation* presentation) |
Peter Beverloo
2015/01/07 14:29:09
Can we limit the scope of what PresentationControl
whywhat
2015/01/07 16:22:16
Not sure I want to introduce another interface and
Peter Beverloo
2015/01/07 19:53:11
Oh right, that's OK. Just make sure the names of t
whywhat
2015/01/08 16:05:28
I assume that most of the time the code won't comp
|
+{ |
+ m_presentation = presentation; |
+} |
+ |
+} // namespace blink |