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

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

Issue 1084293004: [PresentationAPI] Added on-session-message handler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 5 years, 8 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 c074df3d823dc97bfaf68ce6480666de7845e3be..c07f2658e2a5b2bc045bee6a321cf72bc256df5e 100644
--- a/content/renderer/presentation/presentation_dispatcher.cc
+++ b/content/renderer/presentation/presentation_dispatcher.cc
@@ -211,6 +211,28 @@ void PresentationDispatcher::OnSessionStateChange(
GetWebPresentationSessionStateFromMojo(session_state));
}
+void PresentationDispatcher::OnSessionMessagesReceived(
+ mojo::Array<presentation::SessionMessagePtr> messages) {
+ if (!controller_)
+ return;
+
+ for (size_t i = 0; i < messages.size(); ++i) {
+ if (messages[i]->type ==
+ presentation::PresentationMessageType::PRESENTATION_MESSAGE_TYPE_TEXT) {
+ controller_->didReceiveSessionTextMessage(
+ new PresentationSessionClient(messages[i]->presentation_url,
+ messages[i]->presentation_id),
+ blink::WebString::fromUTF8(messages[i]->message));
+ } else {
+ // TODO(haibinlu): handle binary message
+ }
+ }
+
+ presentation_service_->ListenForSessionMessages(
+ base::Bind(&PresentationDispatcher::OnSessionMessagesReceived,
+ base::Unretained(this)));
+}
+
void PresentationDispatcher::ConnectToPresentationServiceIfNeeded() {
if (presentation_service_.get())
return;
@@ -226,6 +248,9 @@ void PresentationDispatcher::ConnectToPresentationServiceIfNeeded() {
presentation_service_->ListenForSessionStateChange(base::Bind(
&PresentationDispatcher::OnSessionStateChange,
base::Unretained(this)));
+ presentation_service_->ListenForSessionMessages(
+ base::Bind(&PresentationDispatcher::OnSessionMessagesReceived,
+ base::Unretained(this)));
*/
}
« 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