Index: content/browser/presentation/presentation_service_impl.cc |
diff --git a/content/browser/presentation/presentation_service_impl.cc b/content/browser/presentation/presentation_service_impl.cc |
index 19372a179473915a2e2c95a9b68e0f1dbe60b03e..3845c3bf9f06bf5365f9a3a11b8cf005b19b0c02 100644 |
--- a/content/browser/presentation/presentation_service_impl.cc |
+++ b/content/browser/presentation/presentation_service_impl.cc |
@@ -10,6 +10,7 @@ |
#include "content/browser/presentation/presentation_type_converters.h" |
#include "content/public/browser/content_browser_client.h" |
#include "content/public/browser/navigation_details.h" |
+#include "content/public/browser/presentation_session_message.h" |
#include "content/public/browser/render_frame_host.h" |
#include "content/public/browser/render_process_host.h" |
#include "content/public/browser/web_contents.h" |
@@ -335,7 +336,47 @@ bool PresentationServiceImpl::FrameMatches( |
void PresentationServiceImpl::ListenForSessionMessages( |
const SessionMessagesCallback& callback) { |
- NOTIMPLEMENTED(); |
+ DVLOG(2) << "ListenForSessionMessages"; |
+ if (!delegate_) { |
+ callback.Run(mojo::Array<presentation::SessionMessagePtr>()); |
+ return; |
+ } |
+ |
+ delegate_->ListenForSessionMessages( |
+ render_process_id_, render_frame_id_, |
+ base::Bind(&PresentationServiceImpl::OnSessionMessages, |
+ weak_factory_.GetWeakPtr(), callback)); |
imcheng (use chromium acct)
2015/04/30 21:52:01
I am not sure about binding the mojo callback to O
haibinlu
2015/05/01 01:37:11
Done.
|
+} |
+ |
+void PresentationServiceImpl::OnSessionMessages( |
+ const SessionMessagesCallback& callback, |
+ scoped_ptr<ScopedVector<PresentationSessionMessage>> messages) { |
imcheng (use chromium acct)
2015/04/30 21:52:01
should probably add a DCHECK on messages
haibinlu
2015/05/01 19:03:19
Done.
|
+ mojo::Array<presentation::SessionMessagePtr> mojoMessages(messages->size()); |
+ for (size_t i = 0; i < messages->size(); ++i) |
+ mojoMessages[i] = PresentationServiceImpl::ToMojoSessionMessage( |
+ messages.get()->get().at(i)); |
+ |
+ callback.Run(mojoMessages.Pass()); |
+} |
+ |
+// static |
+presentation::SessionMessagePtr PresentationServiceImpl::ToMojoSessionMessage( |
+ PresentationSessionMessage* input) { |
+ presentation::SessionMessagePtr output(presentation::SessionMessage::New()); |
+ output->presentation_url = input->presentation_url; |
+ output->presentation_id = input->presentation_id; |
+ if (input->message->size() == 0) { |
+ // binary data |
+ output->type = presentation::PresentationMessageType:: |
+ PRESENTATION_MESSAGE_TYPE_ARRAY_BUFFER; |
+ output->data.Swap(input->data.get()); |
+ } else { |
+ // string message |
+ output->type = |
+ presentation::PresentationMessageType::PRESENTATION_MESSAGE_TYPE_TEXT; |
+ output->message.Swap(input->message.get()); |
+ } |
+ return output.Pass(); |
} |
void PresentationServiceImpl::DidNavigateAnyFrame( |