summaryrefslogtreecommitdiffstats
path: root/extensions
diff options
context:
space:
mode:
authorboetger <boetger@chromium.org>2016-01-07 19:10:17 -0800
committerCommit bot <commit-bot@chromium.org>2016-01-08 03:11:38 +0000
commit5628601c63e07c7aa04d3e62eaeb90b2d60ea53a (patch)
tree12e09c7c84058ce7a141bf4f08c95a7038124cbf /extensions
parentd860e2d6711d51df34773f50053dee124f45e3b9 (diff)
downloadchromium_src-5628601c63e07c7aa04d3e62eaeb90b2d60ea53a.zip
chromium_src-5628601c63e07c7aa04d3e62eaeb90b2d60ea53a.tar.gz
chromium_src-5628601c63e07c7aa04d3e62eaeb90b2d60ea53a.tar.bz2
Non-Local Join for Media Router and Presentation API
The Cast SDK has a concept of non-local joins. This means that if a Cast session is started on Device A (e.g. an Android phone), a user should be able to join the session via a webpage in Chrome on Device B. This requires the idea of "joinable" routes to enter into the media router. The route queries need a context for this to make sense, and that context is the page's |media_source|. If the route can be joined by the page (given the page's media_source), then a list of route_ids (that are a subset of the routes returned in OnRouteUpdated) signify what routes are joinable. The UI should present a "Join" button if the currently viewed route is joinable. Current Screenshots for MediaRoute Dialog Stop And Join - LTR: https://screenshot.googleplex.com/X814uW7esBU Stop Only - LTR: https://screenshot.googleplex.com/iybKZd1aABh Stop And Join - RTL: https://screenshot.googleplex.com/ffKqawTFgTF Stop Only - RTL: https://screenshot.googleplex.com/HWbR94H5Qef Review URL: https://codereview.chromium.org/1415103006 Cr-Commit-Position: refs/heads/master@{#368260}
Diffstat (limited to 'extensions')
-rw-r--r--extensions/renderer/resources/media_router_bindings.js61
1 files changed, 54 insertions, 7 deletions
diff --git a/extensions/renderer/resources/media_router_bindings.js b/extensions/renderer/resources/media_router_bindings.js
index 462fd2f..dc621ac 100644
--- a/extensions/renderer/resources/media_router_bindings.js
+++ b/extensions/renderer/resources/media_router_bindings.js
@@ -280,9 +280,23 @@ 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 sourceUrn associated with this route
+ * query. This parameter is optional and can be empty.
+ * @param {Array<string>=} opt_joinableRouteIds The active set of joinable
+ * media routes. This parameter is optional and can be empty.
*/
- MediaRouter.prototype.onRoutesUpdated = function(routes) {
- this.service_.onRoutesUpdated(routes.map(routeToMojo_));
+ MediaRouter.prototype.onRoutesUpdated =
+ function(routes, opt_sourceUrn, opt_joinableRouteIds) {
+ // TODO(boetger): This check allows backward compatibility with the Cast SDK
+ // and can be removed when the Cast SDK is updated.
+ if (typeof(opt_sourceUrn) != 'string') {
+ opt_sourceUrn = '';
+ }
+
+ this.service_.onRoutesUpdated(
+ routes.map(routeToMojo_),
+ opt_sourceUrn || '',
+ opt_joinableRouteIds || []);
};
/**
@@ -373,6 +387,11 @@ define('media_router_bindings', [
* @type {function()}
*/
this.stopObservingMediaRoutes = null;
+
+ /**
+ * @type {function()}
+ */
+ this.connectRouteByRouteId = null;
};
/**
@@ -419,7 +438,8 @@ define('media_router_bindings', [
'joinRoute',
'createRoute',
'stopObservingMediaSinks',
- 'startObservingMediaRoutes'
+ 'startObservingMediaRoutes',
+ 'connectRouteByRouteId'
];
requiredHandlers.forEach(function(nextHandler) {
if (handlers[nextHandler] === undefined) {
@@ -498,6 +518,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};
+ });
+ };
+
+ /**
* Terminates the route specified by |routeId|.
* @param {!string} routeId
*/
@@ -578,17 +623,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(