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

Side by Side 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: Removing default parameter for OnRoutesUpdated 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 var mediaRouter; 5 var mediaRouter;
6 6
7 define('media_router_bindings', [ 7 define('media_router_bindings', [
8 'mojo/public/js/bindings', 8 'mojo/public/js/bindings',
9 'mojo/public/js/core', 9 'mojo/public/js/core',
10 'content/public/renderer/service_provider', 10 'content/public/renderer/service_provider',
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 'default_action': issueActionToMojo_(issue.defaultAction), 272 'default_action': issueActionToMojo_(issue.defaultAction),
273 'secondary_actions': secondaryActions, 273 'secondary_actions': secondaryActions,
274 'help_url': issue.helpUrl, 274 'help_url': issue.helpUrl,
275 'is_blocking': issue.isBlocking 275 'is_blocking': issue.isBlocking
276 })); 276 }));
277 }; 277 };
278 278
279 /** 279 /**
280 * Called by the provider manager when the set of active routes 280 * Called by the provider manager when the set of active routes
281 * has been updated. 281 * has been updated.
282 * @param {!string} sourceUrn The sourUrn associated with this route query.
282 * @param {!Array<MediaRoute>} routes The active set of media routes. 283 * @param {!Array<MediaRoute>} routes The active set of media routes.
284 * @param {!Array<string>} joinableRoutes The active set of joinable media
285 * routes.
283 */ 286 */
284 MediaRouter.prototype.onRoutesUpdated = function(routes) { 287 MediaRouter.prototype.onRoutesUpdated =
285 this.service_.onRoutesUpdated(routes.map(routeToMojo_)); 288 function(sourceUrn, routes, joinableRouteIds) {
289 this.service_.onRoutesUpdated(
290 sourceUrn, routes.map(routeToMojo_), joinableRouteIds);
286 }; 291 };
287 292
288 /** 293 /**
289 * Called by the provider manager when sink availability has been updated. 294 * Called by the provider manager when sink availability has been updated.
290 * @param {!mediaRouterMojom.MediaRouter.SinkAvailability} availability 295 * @param {!mediaRouterMojom.MediaRouter.SinkAvailability} availability
291 * The new sink availability. 296 * The new sink availability.
292 */ 297 */
293 MediaRouter.prototype.onSinkAvailabilityUpdated = function(availability) { 298 MediaRouter.prototype.onSinkAvailabilityUpdated = function(availability) {
294 this.service_.onSinkAvailabilityUpdated(availability); 299 this.service_.onSinkAvailabilityUpdated(availability);
295 }; 300 };
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 371
367 /** 372 /**
368 * @type {function()} 373 * @type {function()}
369 */ 374 */
370 this.startObservingMediaRoutes = null; 375 this.startObservingMediaRoutes = null;
371 376
372 /** 377 /**
373 * @type {function()} 378 * @type {function()}
374 */ 379 */
375 this.stopObservingMediaRoutes = null; 380 this.stopObservingMediaRoutes = null;
381
382 /**
383 * @type {function()}
384 */
385 this.connectRouteByRouteId = null;
376 }; 386 };
377 387
378 /** 388 /**
379 * Routes calls from Media Router to the provider manager extension. 389 * Routes calls from Media Router to the provider manager extension.
380 * Registered with the MediaRouter stub. 390 * Registered with the MediaRouter stub.
381 * @param {!MediaRouter} MediaRouter proxy to call into the 391 * @param {!MediaRouter} MediaRouter proxy to call into the
382 * Media Router mojo interface. 392 * Media Router mojo interface.
383 * @constructor 393 * @constructor
384 */ 394 */
385 function MediaRouteProvider(mediaRouter) { 395 function MediaRouteProvider(mediaRouter) {
(...skipping 26 matching lines...) Expand all
412 'startObservingMediaRoutes', 422 'startObservingMediaRoutes',
413 'sendRouteMessage', 423 'sendRouteMessage',
414 'sendRouteBinaryMessage', 424 'sendRouteBinaryMessage',
415 'listenForRouteMessages', 425 'listenForRouteMessages',
416 'stopListeningForRouteMessages', 426 'stopListeningForRouteMessages',
417 'onPresentationSessionDetached', 427 'onPresentationSessionDetached',
418 'closeRoute', 428 'closeRoute',
419 'joinRoute', 429 'joinRoute',
420 'createRoute', 430 'createRoute',
421 'stopObservingMediaSinks', 431 'stopObservingMediaSinks',
422 'startObservingMediaRoutes' 432 'startObservingMediaRoutes',
433 'connectRouteByRouteId'
423 ]; 434 ];
424 requiredHandlers.forEach(function(nextHandler) { 435 requiredHandlers.forEach(function(nextHandler) {
425 if (handlers[nextHandler] === undefined) { 436 if (handlers[nextHandler] === undefined) {
426 console.error(nextHandler + ' handler not registered.'); 437 console.error(nextHandler + ' handler not registered.');
427 } 438 }
428 }); 439 });
429 } 440 }
430 441
431 /** 442 /**
432 * Starts querying for sinks capable of displaying the media source 443 * Starts querying for sinks capable of displaying the media source
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 return this.handlers_.joinRoute(sourceUrn, presentationId, origin, tabId) 502 return this.handlers_.joinRoute(sourceUrn, presentationId, origin, tabId)
492 .then(function(newRoute) { 503 .then(function(newRoute) {
493 return {route: routeToMojo_(newRoute)}; 504 return {route: routeToMojo_(newRoute)};
494 }, 505 },
495 function(err) { 506 function(err) {
496 return {error_text: 'Error joining route: ' + err.message}; 507 return {error_text: 'Error joining route: ' + err.message};
497 }); 508 });
498 }; 509 };
499 510
500 /** 511 /**
512 * Handles a request via the Presentation API to join an existing route given
513 * by |sourceUrn| and |routeId|. |origin| and |tabId| are used for
514 * validating same-origin/tab scope.
515 * @param {!string} sourceUrn Media source to render.
516 * @param {!string} routeId Route ID to join.
517 * @param {!string} presentationId Presentation ID to join.
518 * @param {!string} origin Origin of site requesting join.
519 * @param {!number} tabId ID of tab requesting join.
520 * @return {!Promise.<!Object>} A Promise resolving to an object describing
521 * the newly created media route, or rejecting with an error message on
522 * failure.
523 */
524 MediaRouteProvider.prototype.connectRouteByRouteId =
525 function(sourceUrn, routeId, presentationId, origin, tabId) {
526 return this.handlers_.connectRouteByRouteId(
527 sourceUrn, routeId, presentationId, origin, tabId)
528 .then(function(newRoute) {
529 return {route: routeToMojo_(newRoute)};
530 },
531 function(err) {
532 return {error_text: 'Error joining route: ' + err.message};
533 });
534 };
535
536 /**
501 * Closes the route specified by |routeId|. 537 * Closes the route specified by |routeId|.
502 * @param {!string} routeId 538 * @param {!string} routeId
503 */ 539 */
504 MediaRouteProvider.prototype.closeRoute = function(routeId) { 540 MediaRouteProvider.prototype.closeRoute = function(routeId) {
505 this.handlers_.closeRoute(routeId); 541 this.handlers_.closeRoute(routeId);
506 }; 542 };
507 543
508 /** 544 /**
509 * Posts a message to the route designated by |routeId|. 545 * Posts a message to the route designated by |routeId|.
510 * @param {!string} routeId 546 * @param {!string} routeId
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 * @param {!string} routeId 607 * @param {!string} routeId
572 */ 608 */
573 MediaRouteProvider.prototype.onPresentationSessionDetached = function( 609 MediaRouteProvider.prototype.onPresentationSessionDetached = function(
574 routeId) { 610 routeId) {
575 this.handlers_.onPresentationSessionDetached(routeId); 611 this.handlers_.onPresentationSessionDetached(routeId);
576 }; 612 };
577 613
578 /** 614 /**
579 * Requests that the provider manager start sending information about active 615 * Requests that the provider manager start sending information about active
580 * media routes to the Media Router. 616 * media routes to the Media Router.
617 * @param {!string} sourceUrn
581 */ 618 */
582 MediaRouteProvider.prototype.startObservingMediaRoutes = function() { 619 MediaRouteProvider.prototype.startObservingMediaRoutes = function(sourceUrn) {
583 this.handlers_.startObservingMediaRoutes(); 620 this.handlers_.startObservingMediaRoutes(sourceUrn);
584 }; 621 };
585 622
586 /** 623 /**
587 * Requests that the provider manager stop sending information about active 624 * Requests that the provider manager stop sending information about active
588 * media routes to the Media Router. 625 * media routes to the Media Router.
626 * @param {!string} sourceUrn
589 */ 627 */
590 MediaRouteProvider.prototype.stopObservingMediaRoutes = function() { 628 MediaRouteProvider.prototype.stopObservingMediaRoutes = function(sourceUrn) {
591 this.handlers_.stopObservingMediaRoutes(); 629 this.handlers_.stopObservingMediaRoutes(sourceUrn);
592 }; 630 };
593 631
594 mediaRouter = new MediaRouter(connector.bindHandleToProxy( 632 mediaRouter = new MediaRouter(connector.bindHandleToProxy(
595 serviceProvider.connectToService( 633 serviceProvider.connectToService(
596 mediaRouterMojom.MediaRouter.name), 634 mediaRouterMojom.MediaRouter.name),
597 mediaRouterMojom.MediaRouter)); 635 mediaRouterMojom.MediaRouter));
598 636
599 return mediaRouter; 637 return mediaRouter;
600 }); 638 });
601 639
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698