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

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

Issue 1024903003: [Presentation API] Plumbing of |onstatechange| from the Mojo service to the public/platform (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Call the Mojo method again from the callback Created 5 years, 9 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
Index: content/renderer/presentation/presentation_dispatcher.cc
diff --git a/content/renderer/presentation/presentation_dispatcher.cc b/content/renderer/presentation/presentation_dispatcher.cc
index eec933b874dba7d3ebdf510d6dc3833d3e3a74e5..7bbca6bf032d976a8c844996ee61bbe23e32238f 100644
--- a/content/renderer/presentation/presentation_dispatcher.cc
+++ b/content/renderer/presentation/presentation_dispatcher.cc
@@ -33,6 +33,19 @@ blink::WebPresentationError::ErrorType GetWebPresentationErrorTypeFromMojo(
}
}
+blink::WebPresentationSessionState GetWebPresentationSessionStateFromMojo(
+ presentation::PresentationSessionState mojoSessionState) {
+ switch (mojoSessionState) {
+ case presentation::PRESENTATION_SESSION_STATE_CONNECTED:
+ return blink::WebPresentationSessionState::Connected;
+ case presentation::PRESENTATION_SESSION_STATE_DISCONNECTED:
+ return blink::WebPresentationSessionState::Disconnected;
+ }
+
+ NOTREACHED();
+ return blink::WebPresentationSessionState::Disconnected;
+}
+
GURL GetPresentationURLFromFrame(content::RenderFrame* frame) {
DCHECK(frame);
@@ -161,11 +174,8 @@ void PresentationDispatcher::OnDefaultSessionStarted(
base::Unretained(this)));
DCHECK(!session_info.is_null());
- PresentationSessionDispatcher* session_dispatcher =
- new PresentationSessionDispatcher(session_info.Pass());
- presentation_session_dispatchers_.push_back(session_dispatcher);
controller_->didStartDefaultSession(
- new PresentationSessionClient(session_dispatcher));
+ new PresentationSessionClient(session_info.Pass()));
}
void PresentationDispatcher::OnSessionCreated(
@@ -182,10 +192,23 @@ void PresentationDispatcher::OnSessionCreated(
}
DCHECK(!session_info.is_null());
- PresentationSessionDispatcher* session_dispatcher =
- new PresentationSessionDispatcher(session_info.Pass());
- presentation_session_dispatchers_.push_back(session_dispatcher);
- callback->onSuccess(new PresentationSessionClient(session_dispatcher));
+ callback->onSuccess(new PresentationSessionClient(session_info.Pass()));
+}
+
+void PresentationDispatcher::OnSessionStateChange(
+ presentation::PresentationSessionInfoPtr session_info,
+ presentation::PresentationSessionState session_state) {
+ if (!controller_)
+ return;
+
+ presentation_service_->ListenForSessionStateChange(base::Bind(
+ &PresentationDispatcher::OnSessionStateChange,
+ base::Unretained(this)));
+
+ DCHECK(!session_info.is_null());
+ controller_->didChangeSessionState(
+ new PresentationSessionClient(session_info.Pass()),
+ GetWebPresentationSessionStateFromMojo(session_state));
}
void PresentationDispatcher::ConnectToPresentationServiceIfNeeded() {
@@ -197,6 +220,9 @@ void PresentationDispatcher::ConnectToPresentationServiceIfNeeded() {
presentation_service_->ListenForDefaultSessionStart(base::Bind(
&PresentationDispatcher::OnDefaultSessionStarted,
base::Unretained(this)));
+ presentation_service_->ListenForSessionStateChange(base::Bind(
+ &PresentationDispatcher::OnSessionStateChange,
+ base::Unretained(this)));
}
} // namespace content
« no previous file with comments | « content/renderer/presentation/presentation_dispatcher.h ('k') | content/renderer/presentation/presentation_session_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698