Index: content/renderer/presentation/presentation_dispatcher.cc |
diff --git a/content/renderer/presentation/presentation_dispatcher.cc b/content/renderer/presentation/presentation_dispatcher.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..96f75c0366bc6f1676eaa800b3a37322f36c3257 |
--- /dev/null |
+++ b/content/renderer/presentation/presentation_dispatcher.cc |
@@ -0,0 +1,46 @@ |
+// 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 "content/renderer/presentation/presentation_dispatcher.h" |
+ |
+#include "content/public/common/service_registry.h" |
+#include "content/public/renderer/render_frame.h" |
+#include "third_party/WebKit/public/platform/WebPresentationController.h" |
+ |
+namespace content { |
+ |
+PresentationDispatcher::PresentationDispatcher(RenderFrame* render_frame) |
+ : RenderFrameObserver(render_frame) {} |
+ |
+PresentationDispatcher::~PresentationDispatcher() {} |
+ |
+void PresentationDispatcher::setController( |
+ blink::WebPresentationController* controller) { |
+ controller_ = controller; |
+} |
+ |
+void PresentationDispatcher::addDeviceAvailabilityListener() { |
+ ConnectToPresentationServiceIfNeeded(); |
+ presentation_service_->AddDeviceAvailabilityListener(); |
+} |
+ |
+void PresentationDispatcher::removeDeviceAvailabilityListener() { |
+ ConnectToPresentationServiceIfNeeded(); |
+ presentation_service_->RemoveDeviceAvailabilityListener(); |
+} |
+ |
+void PresentationDispatcher::DeviceAvailabilityChanged(bool available) { |
+ if (controller_) |
+ controller_->didChangeAvailability(available); |
+} |
+ |
+void PresentationDispatcher::ConnectToPresentationServiceIfNeeded() { |
+ if (!presentation_service_.get()) { |
Peter Beverloo
2015/01/07 19:41:21
nit: I'd prefer early returns over a block like th
whywhat
2015/01/08 17:28:53
Done.
|
+ render_frame()->GetServiceRegistry()->ConnectToRemoteService( |
+ &presentation_service_); |
+ presentation_service_.set_client(this); |
+ } |
+} |
+ |
+} // namespace content |