Chromium Code Reviews| Index: content/renderer/presentation/presentation_dispatcher.cc |
| diff --git a/content/renderer/presentation/presentation_dispatcher.cc b/content/renderer/presentation/presentation_dispatcher.cc |
| index 50759293cf7973ce2f82bc0774984896143535e6..414f96228cabaa9a186c68269b1abedcf8d2ef6f 100644 |
| --- a/content/renderer/presentation/presentation_dispatcher.cc |
| +++ b/content/renderer/presentation/presentation_dispatcher.cc |
| @@ -59,7 +59,8 @@ namespace content { |
| PresentationDispatcher::PresentationDispatcher(RenderFrame* render_frame) |
| : RenderFrameObserver(render_frame), |
| - controller_(nullptr) { |
| + controller_(nullptr), |
| + binding_(this) { |
| } |
| PresentationDispatcher::~PresentationDispatcher() { |
| @@ -79,20 +80,11 @@ void PresentationDispatcher::setController( |
| } |
| void PresentationDispatcher::updateAvailableChangeWatched(bool watched) { |
| - GURL presentation_url(GetPresentationURLFromFrame(render_frame())); |
| - DoUpdateAvailableChangeWatched(presentation_url.spec(), watched); |
| -} |
| - |
| -void PresentationDispatcher::DoUpdateAvailableChangeWatched( |
| - const std::string& presentation_url, bool watched) { |
| ConnectToPresentationServiceIfNeeded(); |
| if (watched) { |
| - presentation_service_->ListenForScreenAvailability( |
| - presentation_url, |
| - base::Bind(&PresentationDispatcher::OnScreenAvailabilityChanged, |
| - base::Unretained(this))); |
| + presentation_service_->ListenForScreenAvailability(); |
| } else { |
|
whywhat
2015/05/11 17:58:19
nit: don't need the {}
imcheng (use chromium acct)
2015/05/11 22:04:12
Done.
|
| - presentation_service_->RemoveScreenAvailabilityListener(presentation_url); |
| + presentation_service_->StopListeningForScreenAvailability(); |
| } |
| } |
| @@ -150,16 +142,9 @@ void PresentationDispatcher::DidChangeDefaultPresentation() { |
| presentation_url.spec(), mojo::String()); |
| } |
| -void PresentationDispatcher::OnScreenAvailabilityChanged( |
| - const std::string& presentation_url, bool available) { |
| - if (!controller_) |
| - return; |
| - |
| - // Reset the callback to get the next event. |
| - DoUpdateAvailableChangeWatched(presentation_url, |
| - controller_->isAvailableChangeWatched()); |
| - |
| - controller_->didChangeAvailability(available); |
| +void PresentationDispatcher::OnScreenAvailabilityUpdated(bool available) { |
| + if (controller_) |
| + controller_->didChangeAvailability(available); |
| } |
| void PresentationDispatcher::OnDefaultSessionStarted( |
| @@ -240,6 +225,10 @@ void PresentationDispatcher::ConnectToPresentationServiceIfNeeded() { |
| render_frame()->GetServiceRegistry()->ConnectToRemoteService( |
| &presentation_service_); |
| + presentation::PresentationServiceClientPtr client_ptr; |
| + binding_.Bind(GetProxy(&client_ptr)); |
| + presentation_service_->SetClient(client_ptr.Pass()); |
| + |
| // TODO(imcheng): Uncomment these once they are implemented on the browser |
| // side. (crbug.com/459006) |
| /* |