Chromium Code Reviews| 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 "content/renderer/presentation/presentation_dispatcher.h" | |
| 6 | |
| 7 #include "content/public/common/service_registry.h" | |
| 8 #include "content/public/renderer/render_frame.h" | |
| 9 #include "third_party/WebKit/public/platform/WebPresentationController.h" | |
| 10 | |
| 11 namespace content { | |
| 12 | |
| 13 PresentationDispatcher::PresentationDispatcher(RenderFrame* render_frame) | |
| 14 : RenderFrameObserver(render_frame) {} | |
| 15 | |
| 16 PresentationDispatcher::~PresentationDispatcher() {} | |
| 17 | |
| 18 void PresentationDispatcher::setController( | |
| 19 blink::WebPresentationController* controller) { | |
| 20 controller_ = controller; | |
| 21 } | |
| 22 | |
| 23 void PresentationDispatcher::addDeviceAvailabilityListener() { | |
| 24 ConnectToPresentationServiceIfNeeded(); | |
| 25 presentation_service_->AddDeviceAvailabilityListener(); | |
| 26 } | |
| 27 | |
| 28 void PresentationDispatcher::removeDeviceAvailabilityListener() { | |
| 29 ConnectToPresentationServiceIfNeeded(); | |
| 30 presentation_service_->RemoveDeviceAvailabilityListener(); | |
| 31 } | |
| 32 | |
| 33 void PresentationDispatcher::DeviceAvailabilityChanged(bool available) { | |
| 34 if (controller_) | |
| 35 controller_->didChangeAvailability(available); | |
| 36 } | |
| 37 | |
| 38 void PresentationDispatcher::ConnectToPresentationServiceIfNeeded() { | |
| 39 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.
| |
| 40 render_frame()->GetServiceRegistry()->ConnectToRemoteService( | |
| 41 &presentation_service_); | |
| 42 presentation_service_.set_client(this); | |
| 43 } | |
| 44 } | |
| 45 | |
| 46 } // namespace content | |
| OLD | NEW |