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

Unified Diff: content/renderer/presentation/presentation_dispatcher.cc

Issue 1131053005: [Presentation API] Convert screen availability API into Client style. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix dcheck Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/presentation/presentation_dispatcher.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/presentation/presentation_dispatcher.cc
diff --git a/content/renderer/presentation/presentation_dispatcher.cc b/content/renderer/presentation/presentation_dispatcher.cc
index 69ba2c3291d1ee3e57396c4074f595bb4147977b..29f5047f0b57ec0639ff4d9765a2c645beb807f9 100644
--- a/content/renderer/presentation/presentation_dispatcher.cc
+++ b/content/renderer/presentation/presentation_dispatcher.cc
@@ -60,7 +60,8 @@ namespace content {
PresentationDispatcher::PresentationDispatcher(RenderFrame* render_frame)
: RenderFrameObserver(render_frame),
- controller_(nullptr) {
+ controller_(nullptr),
+ binding_(this) {
}
PresentationDispatcher::~PresentationDispatcher() {
@@ -80,21 +81,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)));
- } else {
- presentation_service_->RemoveScreenAvailabilityListener(presentation_url);
- }
+ if (watched)
+ presentation_service_->ListenForScreenAvailability();
+ else
+ presentation_service_->StopListeningForScreenAvailability();
}
void PresentationDispatcher::startSession(
@@ -270,16 +261,9 @@ void PresentationDispatcher::DidCommitProvisionalLoad(
std::swap(message_request_queue_, empty);
}
-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(
@@ -360,6 +344,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)
/*
« no previous file with comments | « content/renderer/presentation/presentation_dispatcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698