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

Side by Side Diff: content/renderer/presentation/presentation_dispatcher.cc

Issue 839773002: Plumbing from WebPresentationClient to the Presentation Mojo service for (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Got rid of the PresentationServiceClient Created 5 years, 10 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 unified diff | Download patch
OLDNEW
(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/common/presentation/presentation_service.mojom.h"
8 #include "content/public/common/service_registry.h"
9 #include "content/public/renderer/render_frame.h"
10 #include "third_party/WebKit/public/platform/WebPresentationController.h"
11
12 namespace content {
13
14 PresentationDispatcher::PresentationDispatcher(RenderFrame* render_frame)
15 : RenderFrameObserver(render_frame) {}
16
17 PresentationDispatcher::~PresentationDispatcher() {}
18
19 void PresentationDispatcher::setController(
20 blink::WebPresentationController* controller) {
21 // Provide the service with the callback to get the next |availablechange|
22 // event if needed.
23 if (controller != nullptr && controller_ != controller)
24 updateAvailableChangeWatched(controller->isAvailableChangeWatched());
25 controller_ = controller;
26 }
27
28 void PresentationDispatcher::updateAvailableChangeWatched(bool watched) {
29 ConnectToPresentationServiceIfNeeded();
30 if (watched) {
31 presentation_service_->GetScreenAvailability(
32 base::Bind(&PresentationDispatcher::OnScreenAvailabilityChanged,
33 base::Unretained(this)));
34 }
35 }
36
37 void PresentationDispatcher::OnScreenAvailabilityChanged(bool available) {
38 if (!controller_)
39 return;
40
41 controller_->didChangeAvailability(available);
42
43 // Reset the callback to get the next event.
44 updateAvailableChangeWatched(controller_->isAvailableChangeWatched());
blundell 2015/01/26 10:31:08 You should call this before line 41 as you don't k
whywhat 2015/01/26 11:06:08 Done.
45 }
46
47 void PresentationDispatcher::ConnectToPresentationServiceIfNeeded() {
48 if (presentation_service_.get())
49 return;
50
51 render_frame()->GetServiceRegistry()->ConnectToRemoteService(
52 &presentation_service_);
53 }
54
55 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698