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

Unified Diff: extensions/renderer/resources/media_router_bindings.js

Issue 1415103006: Non-Local Join for Media Router and Presentation API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Backwards Compatibility Created 4 years, 12 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: extensions/renderer/resources/media_router_bindings.js
diff --git a/extensions/renderer/resources/media_router_bindings.js b/extensions/renderer/resources/media_router_bindings.js
index 7bf09d3bf9ab598f5fdd89024c20877802727f60..0196871bb99830e8ba52572282ebfcfccab0e940 100644
--- a/extensions/renderer/resources/media_router_bindings.js
+++ b/extensions/renderer/resources/media_router_bindings.js
@@ -280,9 +280,17 @@ define('media_router_bindings', [
* Called by the provider manager when the set of active routes
* has been updated.
* @param {!Array<MediaRoute>} routes The active set of media routes.
+ * @param {string=} opt_sourceUrn The sourUrn associated with this route
imcheng 2016/01/05 02:12:47 nit: fix comments. Also comment that it can be emp
matt.boetger 2016/01/06 22:49:08 Done.
+ * query.
+ * @param {Array<string>=} opt_joinableRoutes The active set of joinable media
apacible 2016/01/05 21:41:58 op_joinableRouteIds?
matt.boetger 2016/01/06 22:49:08 Done.
+ * routes.
*/
- MediaRouter.prototype.onRoutesUpdated = function(routes) {
- this.service_.onRoutesUpdated(routes.map(routeToMojo_));
+ MediaRouter.prototype.onRoutesUpdated =
+ function(routes, opt_sourceUrn, opt_joinableRouteIds) {
+ this.service_.onRoutesUpdated(
+ routes.map(routeToMojo_),
+ opt_sourceUrn || '',
+ opt_joinableRouteIds || []);
};
/**
@@ -373,6 +381,11 @@ define('media_router_bindings', [
* @type {function()}
*/
this.stopObservingMediaRoutes = null;
+
+ /**
+ * @type {function()}
+ */
+ this.connectRouteByRouteId = null;
};
/**
@@ -419,7 +432,8 @@ define('media_router_bindings', [
'joinRoute',
'createRoute',
'stopObservingMediaSinks',
- 'startObservingMediaRoutes'
+ 'startObservingMediaRoutes',
+ 'connectRouteByRouteId'
];
requiredHandlers.forEach(function(nextHandler) {
if (handlers[nextHandler] === undefined) {
@@ -498,6 +512,31 @@ define('media_router_bindings', [
};
/**
+ * Handles a request via the Presentation API to join an existing route given
+ * by |sourceUrn| and |routeId|. |origin| and |tabId| are used for
+ * validating same-origin/tab scope.
+ * @param {!string} sourceUrn Media source to render.
+ * @param {!string} routeId Route ID to join.
+ * @param {!string} presentationId Presentation ID to join.
+ * @param {!string} origin Origin of site requesting join.
+ * @param {!number} tabId ID of tab requesting join.
+ * @return {!Promise.<!Object>} A Promise resolving to an object describing
+ * the newly created media route, or rejecting with an error message on
+ * failure.
+ */
+ MediaRouteProvider.prototype.connectRouteByRouteId =
+ function(sourceUrn, routeId, presentationId, origin, tabId) {
+ return this.handlers_.connectRouteByRouteId(
+ sourceUrn, routeId, presentationId, origin, tabId)
+ .then(function(newRoute) {
+ return {route: routeToMojo_(newRoute)};
+ },
+ function(err) {
+ return {error_text: 'Error joining route: ' + err.message};
+ });
+ };
+
+ /**
* Closes the route specified by |routeId|.
* @param {!string} routeId
*/
@@ -578,17 +617,19 @@ define('media_router_bindings', [
/**
* Requests that the provider manager start sending information about active
* media routes to the Media Router.
+ * @param {!string} sourceUrn
*/
- MediaRouteProvider.prototype.startObservingMediaRoutes = function() {
- this.handlers_.startObservingMediaRoutes();
+ MediaRouteProvider.prototype.startObservingMediaRoutes = function(sourceUrn) {
+ this.handlers_.startObservingMediaRoutes(sourceUrn);
};
/**
* Requests that the provider manager stop sending information about active
* media routes to the Media Router.
+ * @param {!string} sourceUrn
*/
- MediaRouteProvider.prototype.stopObservingMediaRoutes = function() {
- this.handlers_.stopObservingMediaRoutes();
+ MediaRouteProvider.prototype.stopObservingMediaRoutes = function(sourceUrn) {
+ this.handlers_.stopObservingMediaRoutes(sourceUrn);
};
mediaRouter = new MediaRouter(connector.bindHandleToProxy(

Powered by Google App Engine
This is Rietveld 408576698