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

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

Issue 935083002: [PresentationAPI] Implementing start/joinSession from WebPresentationClient to PresentationService. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: No find copoes Created 5 years, 10 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 04b44eca6fe231e3e98c363f1f4b64339ad4ec8f..80fae62fde30538e616479228e9aa48f73d979b4 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/WebPresentationError.h"
namespace content {
@@ -44,6 +45,32 @@ void PresentationDispatcher::updateAvailableChangeWatched(bool watched) {
}
}
+void PresentationDispatcher::startSession(
+ const blink::WebString& presentationUrl,
+ const blink::WebString& presentationId,
+ blink::WebPresentationSessionClientCallbacks* 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::WebPresentationSessionClientCallbacks* 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::WebPresentationSessionClientCallbacks* callback,
+ presentation::PresentationSessionInfoPtr session_info,
+ presentation::PresentationErrorPtr error) {
+ if (!callback)
+ return;
+ if (error.get()) {
+ DCHECK(!session_info.get());
+ callback->onError(new blink::WebPresentationError(
+ error->errorCode,
+ blink::WebString::fromUTF8(error->message)));
+ return;
+ }
+
+ DCHECK(session_info.get());
+ PresentationSessionDispatcher* session_dispatcher =
+ new PresentationSessionDispatcher(session_info.Pass());
+ presentation_sessions_.push_back(session_dispatcher);
+ callback->onSuccess(session_dispatcher);
+}
+
void PresentationDispatcher::ConnectToPresentationServiceIfNeeded() {
if (presentation_service_.get())
return;

Powered by Google App Engine
This is Rietveld 408576698