Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 {!Array<MediaRoute>} routes The active set of media routes. | 282 * @param {!Array<MediaRoute>} routes The active set of media routes. |
| 283 * @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.
| |
| 284 * query. | |
| 285 * @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.
| |
| 286 * routes. | |
| 283 */ | 287 */ |
| 284 MediaRouter.prototype.onRoutesUpdated = function(routes) { | 288 MediaRouter.prototype.onRoutesUpdated = |
| 285 this.service_.onRoutesUpdated(routes.map(routeToMojo_)); | 289 function(routes, opt_sourceUrn, opt_joinableRouteIds) { |
| 290 this.service_.onRoutesUpdated( | |
| 291 routes.map(routeToMojo_), | |
| 292 opt_sourceUrn || '', | |
| 293 opt_joinableRouteIds || []); | |
| 286 }; | 294 }; |
| 287 | 295 |
| 288 /** | 296 /** |
| 289 * Called by the provider manager when sink availability has been updated. | 297 * Called by the provider manager when sink availability has been updated. |
| 290 * @param {!mediaRouterMojom.MediaRouter.SinkAvailability} availability | 298 * @param {!mediaRouterMojom.MediaRouter.SinkAvailability} availability |
| 291 * The new sink availability. | 299 * The new sink availability. |
| 292 */ | 300 */ |
| 293 MediaRouter.prototype.onSinkAvailabilityUpdated = function(availability) { | 301 MediaRouter.prototype.onSinkAvailabilityUpdated = function(availability) { |
| 294 this.service_.onSinkAvailabilityUpdated(availability); | 302 this.service_.onSinkAvailabilityUpdated(availability); |
| 295 }; | 303 }; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 366 | 374 |
| 367 /** | 375 /** |
| 368 * @type {function()} | 376 * @type {function()} |
| 369 */ | 377 */ |
| 370 this.startObservingMediaRoutes = null; | 378 this.startObservingMediaRoutes = null; |
| 371 | 379 |
| 372 /** | 380 /** |
| 373 * @type {function()} | 381 * @type {function()} |
| 374 */ | 382 */ |
| 375 this.stopObservingMediaRoutes = null; | 383 this.stopObservingMediaRoutes = null; |
| 384 | |
| 385 /** | |
| 386 * @type {function()} | |
| 387 */ | |
| 388 this.connectRouteByRouteId = null; | |
| 376 }; | 389 }; |
| 377 | 390 |
| 378 /** | 391 /** |
| 379 * Routes calls from Media Router to the provider manager extension. | 392 * Routes calls from Media Router to the provider manager extension. |
| 380 * Registered with the MediaRouter stub. | 393 * Registered with the MediaRouter stub. |
| 381 * @param {!MediaRouter} MediaRouter proxy to call into the | 394 * @param {!MediaRouter} MediaRouter proxy to call into the |
| 382 * Media Router mojo interface. | 395 * Media Router mojo interface. |
| 383 * @constructor | 396 * @constructor |
| 384 */ | 397 */ |
| 385 function MediaRouteProvider(mediaRouter) { | 398 function MediaRouteProvider(mediaRouter) { |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 412 'startObservingMediaRoutes', | 425 'startObservingMediaRoutes', |
| 413 'sendRouteMessage', | 426 'sendRouteMessage', |
| 414 'sendRouteBinaryMessage', | 427 'sendRouteBinaryMessage', |
| 415 'listenForRouteMessages', | 428 'listenForRouteMessages', |
| 416 'stopListeningForRouteMessages', | 429 'stopListeningForRouteMessages', |
| 417 'onPresentationSessionDetached', | 430 'onPresentationSessionDetached', |
| 418 'closeRoute', | 431 'closeRoute', |
| 419 'joinRoute', | 432 'joinRoute', |
| 420 'createRoute', | 433 'createRoute', |
| 421 'stopObservingMediaSinks', | 434 'stopObservingMediaSinks', |
| 422 'startObservingMediaRoutes' | 435 'startObservingMediaRoutes', |
| 436 'connectRouteByRouteId' | |
| 423 ]; | 437 ]; |
| 424 requiredHandlers.forEach(function(nextHandler) { | 438 requiredHandlers.forEach(function(nextHandler) { |
| 425 if (handlers[nextHandler] === undefined) { | 439 if (handlers[nextHandler] === undefined) { |
| 426 console.error(nextHandler + ' handler not registered.'); | 440 console.error(nextHandler + ' handler not registered.'); |
| 427 } | 441 } |
| 428 }); | 442 }); |
| 429 } | 443 } |
| 430 | 444 |
| 431 /** | 445 /** |
| 432 * Starts querying for sinks capable of displaying the media source | 446 * Starts querying for sinks capable of displaying the media source |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 491 return this.handlers_.joinRoute(sourceUrn, presentationId, origin, tabId) | 505 return this.handlers_.joinRoute(sourceUrn, presentationId, origin, tabId) |
| 492 .then(function(newRoute) { | 506 .then(function(newRoute) { |
| 493 return {route: routeToMojo_(newRoute)}; | 507 return {route: routeToMojo_(newRoute)}; |
| 494 }, | 508 }, |
| 495 function(err) { | 509 function(err) { |
| 496 return {error_text: 'Error joining route: ' + err.message}; | 510 return {error_text: 'Error joining route: ' + err.message}; |
| 497 }); | 511 }); |
| 498 }; | 512 }; |
| 499 | 513 |
| 500 /** | 514 /** |
| 515 * Handles a request via the Presentation API to join an existing route given | |
| 516 * by |sourceUrn| and |routeId|. |origin| and |tabId| are used for | |
| 517 * validating same-origin/tab scope. | |
| 518 * @param {!string} sourceUrn Media source to render. | |
| 519 * @param {!string} routeId Route ID to join. | |
| 520 * @param {!string} presentationId Presentation ID to join. | |
| 521 * @param {!string} origin Origin of site requesting join. | |
| 522 * @param {!number} tabId ID of tab requesting join. | |
| 523 * @return {!Promise.<!Object>} A Promise resolving to an object describing | |
| 524 * the newly created media route, or rejecting with an error message on | |
| 525 * failure. | |
| 526 */ | |
| 527 MediaRouteProvider.prototype.connectRouteByRouteId = | |
| 528 function(sourceUrn, routeId, presentationId, origin, tabId) { | |
| 529 return this.handlers_.connectRouteByRouteId( | |
| 530 sourceUrn, routeId, presentationId, origin, tabId) | |
| 531 .then(function(newRoute) { | |
| 532 return {route: routeToMojo_(newRoute)}; | |
| 533 }, | |
| 534 function(err) { | |
| 535 return {error_text: 'Error joining route: ' + err.message}; | |
| 536 }); | |
| 537 }; | |
| 538 | |
| 539 /** | |
| 501 * Closes the route specified by |routeId|. | 540 * Closes the route specified by |routeId|. |
| 502 * @param {!string} routeId | 541 * @param {!string} routeId |
| 503 */ | 542 */ |
| 504 MediaRouteProvider.prototype.closeRoute = function(routeId) { | 543 MediaRouteProvider.prototype.closeRoute = function(routeId) { |
| 505 this.handlers_.closeRoute(routeId); | 544 this.handlers_.closeRoute(routeId); |
| 506 }; | 545 }; |
| 507 | 546 |
| 508 /** | 547 /** |
| 509 * Posts a message to the route designated by |routeId|. | 548 * Posts a message to the route designated by |routeId|. |
| 510 * @param {!string} routeId | 549 * @param {!string} routeId |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 571 * @param {!string} routeId | 610 * @param {!string} routeId |
| 572 */ | 611 */ |
| 573 MediaRouteProvider.prototype.onPresentationSessionDetached = function( | 612 MediaRouteProvider.prototype.onPresentationSessionDetached = function( |
| 574 routeId) { | 613 routeId) { |
| 575 this.handlers_.onPresentationSessionDetached(routeId); | 614 this.handlers_.onPresentationSessionDetached(routeId); |
| 576 }; | 615 }; |
| 577 | 616 |
| 578 /** | 617 /** |
| 579 * Requests that the provider manager start sending information about active | 618 * Requests that the provider manager start sending information about active |
| 580 * media routes to the Media Router. | 619 * media routes to the Media Router. |
| 620 * @param {!string} sourceUrn | |
| 581 */ | 621 */ |
| 582 MediaRouteProvider.prototype.startObservingMediaRoutes = function() { | 622 MediaRouteProvider.prototype.startObservingMediaRoutes = function(sourceUrn) { |
| 583 this.handlers_.startObservingMediaRoutes(); | 623 this.handlers_.startObservingMediaRoutes(sourceUrn); |
| 584 }; | 624 }; |
| 585 | 625 |
| 586 /** | 626 /** |
| 587 * Requests that the provider manager stop sending information about active | 627 * Requests that the provider manager stop sending information about active |
| 588 * media routes to the Media Router. | 628 * media routes to the Media Router. |
| 629 * @param {!string} sourceUrn | |
| 589 */ | 630 */ |
| 590 MediaRouteProvider.prototype.stopObservingMediaRoutes = function() { | 631 MediaRouteProvider.prototype.stopObservingMediaRoutes = function(sourceUrn) { |
| 591 this.handlers_.stopObservingMediaRoutes(); | 632 this.handlers_.stopObservingMediaRoutes(sourceUrn); |
| 592 }; | 633 }; |
| 593 | 634 |
| 594 mediaRouter = new MediaRouter(connector.bindHandleToProxy( | 635 mediaRouter = new MediaRouter(connector.bindHandleToProxy( |
| 595 serviceProvider.connectToService( | 636 serviceProvider.connectToService( |
| 596 mediaRouterMojom.MediaRouter.name), | 637 mediaRouterMojom.MediaRouter.name), |
| 597 mediaRouterMojom.MediaRouter)); | 638 mediaRouterMojom.MediaRouter)); |
| 598 | 639 |
| 599 return mediaRouter; | 640 return mediaRouter; |
| 600 }); | 641 }); |
| 601 | 642 |
| OLD | NEW |