Index: content/renderer/presentation/presentation_dispatcher.cc |
diff --git a/content/renderer/presentation/presentation_dispatcher.cc b/content/renderer/presentation/presentation_dispatcher.cc |
index 04b44eca6fe231e3e98c363f1f4b64339ad4ec8f..5a877acb0aaff5b6f0bd9fd99473ea6fbbe02029 100644 |
--- a/content/renderer/presentation/presentation_dispatcher.cc |
+++ b/content/renderer/presentation/presentation_dispatcher.cc |
@@ -8,6 +8,7 @@ |
#include "content/public/common/service_registry.h" |
#include "content/public/renderer/render_frame.h" |
#include "third_party/WebKit/public/platform/modules/presentation/WebPresentationController.h" |
+#include "third_party/WebKit/public/platform/modules/presentation/WebPresentationSessionCreateCallback.h" |
namespace content { |
@@ -44,6 +45,32 @@ void PresentationDispatcher::updateAvailableChangeWatched(bool watched) { |
} |
} |
+void PresentationDispatcher::startSession( |
+ const blink::WebString& presentationUrl, |
+ const blink::WebString& presentationId, |
+ blink::WebPresentationSessionCreateCallback* callback) { |
+ ConnectToPresentationServiceIfNeeded(); |
+ presentation_service_->StartSession( |
+ presentationUrl.utf8(), |
+ presentationId.utf8(), |
+ base::Bind(&PresentationDispatcher::OnSessionCreated, |
+ base::Unretained(this), |
+ base::Unretained(callback))); |
+} |
+ |
+void PresentationDispatcher::joinSession( |
+ const blink::WebString& presentationUrl, |
+ const blink::WebString& presentationId, |
+ blink::WebPresentationSessionCreateCallback* callback) { |
+ ConnectToPresentationServiceIfNeeded(); |
+ presentation_service_->JoinSession( |
+ presentationUrl.utf8(), |
+ presentationId.utf8(), |
+ base::Bind(&PresentationDispatcher::OnSessionCreated, |
+ base::Unretained(this), |
+ base::Unretained(callback))); |
+} |
+ |
void PresentationDispatcher::OnScreenAvailabilityChanged(bool available) { |
if (!controller_) |
return; |
@@ -54,6 +81,27 @@ void PresentationDispatcher::OnScreenAvailabilityChanged(bool available) { |
controller_->didChangeAvailability(available); |
} |
+void PresentationDispatcher::OnSessionCreated( |
+ blink::WebPresentationSessionCreateCallback* callback, |
+ bool success, |
+ mojo::InterfaceRequest<presentation::PresentationSession> session_request, |
+ const mojo::String& url, |
+ const mojo::String& id, |
+ const mojo::String& error) { |
+ if (!callback) |
+ return; |
+ if (!success) { |
+ callback->onError(blink::WebString::fromUTF8(error)); |
+ return; |
+ } |
+ |
+ linked_ptr<PresentationSessionDispatcher> session_dispatcher; |
+ session_dispatcher.reset( |
+ new PresentationSessionDispatcher(session_request.Pass(), url, id)); |
+ presentation_sessions_.push_back(session_dispatcher); |
+ callback->onSuccess(session_dispatcher.get()); |
+} |
+ |
void PresentationDispatcher::ConnectToPresentationServiceIfNeeded() { |
if (presentation_service_.get()) |
return; |