| 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/frame_service_registry', | 10 'content/public/renderer/frame_service_registry', |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 * @param {Array<string>=} opt_origins | 268 * @param {Array<string>=} opt_origins |
| 269 */ | 269 */ |
| 270 MediaRouter.prototype.onSinksReceived = function(sourceUrn, sinks, | 270 MediaRouter.prototype.onSinksReceived = function(sourceUrn, sinks, |
| 271 opt_origins) { | 271 opt_origins) { |
| 272 // TODO(imcheng): Make origins required in M52+. | 272 // TODO(imcheng): Make origins required in M52+. |
| 273 this.service_.onSinksReceived(sourceUrn, sinks.map(sinkToMojo_), | 273 this.service_.onSinksReceived(sourceUrn, sinks.map(sinkToMojo_), |
| 274 opt_origins || []); | 274 opt_origins || []); |
| 275 }; | 275 }; |
| 276 | 276 |
| 277 /** | 277 /** |
| 278 * Called by the provider manager when a sink is found to notify the MR of the |
| 279 * sink's ID. The actual sink will be returned through the normal sink list |
| 280 * update process, so this helps the MR identify the search result in the |
| 281 * list. |
| 282 * @param {string} pseudoSinkId ID of the pseudo sink that started the |
| 283 * search. |
| 284 * @param {string} sinkId ID of the newly-found sink. |
| 285 */ |
| 286 MediaRouter.prototype.onSearchSinkIdReceived = function( |
| 287 pseudoSinkId, sinkId) { |
| 288 this.service_.onSearchSinkIdReceived(pseudoSinkId, sinkId); |
| 289 }; |
| 290 |
| 291 /** |
| 278 * Called by the provider manager to keep the extension from suspending | 292 * Called by the provider manager to keep the extension from suspending |
| 279 * if it enters a state where suspension is undesirable (e.g. there is an | 293 * if it enters a state where suspension is undesirable (e.g. there is an |
| 280 * active MediaRoute.) | 294 * active MediaRoute.) |
| 281 * If keepAlive is true, the extension is kept alive. | 295 * If keepAlive is true, the extension is kept alive. |
| 282 * If keepAlive is false, the extension is allowed to suspend. | 296 * If keepAlive is false, the extension is allowed to suspend. |
| 283 * @param {boolean} keepAlive | 297 * @param {boolean} keepAlive |
| 284 */ | 298 */ |
| 285 MediaRouter.prototype.setKeepAlive = function(keepAlive) { | 299 MediaRouter.prototype.setKeepAlive = function(keepAlive) { |
| 286 if (keepAlive === false && this.keepAlive_) { | 300 if (keepAlive === false && this.keepAlive_) { |
| 287 this.keepAlive_.close(); | 301 this.keepAlive_.close(); |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 | 485 |
| 472 /** | 486 /** |
| 473 * @type {function()} | 487 * @type {function()} |
| 474 */ | 488 */ |
| 475 this.connectRouteByRouteId = null; | 489 this.connectRouteByRouteId = null; |
| 476 | 490 |
| 477 /** | 491 /** |
| 478 * @type {function()} | 492 * @type {function()} |
| 479 */ | 493 */ |
| 480 this.enableMdnsDiscovery = null; | 494 this.enableMdnsDiscovery = null; |
| 495 |
| 496 /** |
| 497 * @type {function(!string, !string, !SinkSearchCriteria, !string, !string, |
| 498 * !number, !number, !boolean)} |
| 499 */ |
| 500 this.searchSinksAndCreateRoute = null; |
| 481 }; | 501 }; |
| 482 | 502 |
| 483 /** | 503 /** |
| 484 * Routes calls from Media Router to the provider manager extension. | 504 * Routes calls from Media Router to the provider manager extension. |
| 485 * Registered with the MediaRouter stub. | 505 * Registered with the MediaRouter stub. |
| 486 * @param {!MediaRouter} MediaRouter proxy to call into the | 506 * @param {!MediaRouter} MediaRouter proxy to call into the |
| 487 * Media Router mojo interface. | 507 * Media Router mojo interface. |
| 488 * @constructor | 508 * @constructor |
| 489 */ | 509 */ |
| 490 function MediaRouteProvider(mediaRouter) { | 510 function MediaRouteProvider(mediaRouter) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 520 'listenForRouteMessages', | 540 'listenForRouteMessages', |
| 521 'stopListeningForRouteMessages', | 541 'stopListeningForRouteMessages', |
| 522 'detachRoute', | 542 'detachRoute', |
| 523 'terminateRoute', | 543 'terminateRoute', |
| 524 'joinRoute', | 544 'joinRoute', |
| 525 'createRoute', | 545 'createRoute', |
| 526 'stopObservingMediaSinks', | 546 'stopObservingMediaSinks', |
| 527 'startObservingMediaRoutes', | 547 'startObservingMediaRoutes', |
| 528 'connectRouteByRouteId', | 548 'connectRouteByRouteId', |
| 529 'enableMdnsDiscovery', | 549 'enableMdnsDiscovery', |
| 550 'searchSinksAndCreateRoute', |
| 530 ]; | 551 ]; |
| 531 requiredHandlers.forEach(function(nextHandler) { | 552 requiredHandlers.forEach(function(nextHandler) { |
| 532 if (handlers[nextHandler] === undefined) { | 553 if (handlers[nextHandler] === undefined) { |
| 533 console.error(nextHandler + ' handler not registered.'); | 554 console.error(nextHandler + ' handler not registered.'); |
| 534 } | 555 } |
| 535 }); | 556 }); |
| 536 } | 557 } |
| 537 | 558 |
| 538 /** | 559 /** |
| 539 * Starts querying for sinks capable of displaying the media source | 560 * Starts querying for sinks capable of displaying the media source |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 746 this.handlers_.stopObservingMediaRoutes(sourceUrn); | 767 this.handlers_.stopObservingMediaRoutes(sourceUrn); |
| 747 }; | 768 }; |
| 748 | 769 |
| 749 /** | 770 /** |
| 750 * Enables mDNS device discovery. | 771 * Enables mDNS device discovery. |
| 751 */ | 772 */ |
| 752 MediaRouteProvider.prototype.enableMdnsDiscovery = function() { | 773 MediaRouteProvider.prototype.enableMdnsDiscovery = function() { |
| 753 this.handlers_.enableMdnsDiscovery(); | 774 this.handlers_.enableMdnsDiscovery(); |
| 754 }; | 775 }; |
| 755 | 776 |
| 777 /** |
| 778 * Requests that the provider manager search its providers for a sink matching |
| 779 * |searchCriteria| that is compatible with |sourceUrn|. If a sink is found, a |
| 780 * route is created with the remaining parameters the same as createRoute(). |
| 781 * The route will be returned by this function as for createRoute() but the |
| 782 * sink will be returned through the normal sink update process and its ID |
| 783 * will be returned through onSearchSinkIdReceived(). |
| 784 * @param {string} sinkId Sink ID of the pseudo sink generating the request. |
| 785 * @param {string} sourceUrn Media source to be used with the sink. |
| 786 * @param {!SinkSearchCriteria} searchCriteria Search criteria for the route |
| 787 * providers. |
| 788 * @param {!string} presentationId Presentation ID from the site |
| 789 * requesting presentation. TODO(mfoltz): Remove. |
| 790 * @param {!string} origin Origin of site requesting presentation. |
| 791 * @param {!number} tabId ID of tab requesting presentation. |
| 792 * @param {!number} timeoutMillis If positive, the timeout duration for the |
| 793 * request, measured in seconds. Otherwise, the default duration will be |
| 794 * used. |
| 795 * @param {!boolean} offTheRecord If true, the route is being requested by |
| 796 * an off the record (incognito) profile. |
| 797 * @return {!Promise.<!Object>} A Promise resolving to an object describing |
| 798 * the newly created media route, or rejecting with an error message on |
| 799 * failure. |
| 800 */ |
| 801 MediaRouteProvider.prototype.searchSinksAndCreateRoute = function( |
| 802 sinkId, sourceUrn, searchCriteria, presentationId, origin, tabId, |
| 803 timeoutMillis, offTheRecord) { |
| 804 return this.handlers_ |
| 805 .searchSinksAndCreateRoute( |
| 806 sinkId, sourceUrn, searchCriteria, presentationId, origin, tabId, |
| 807 timeoutMillis, offTheRecord) |
| 808 .then( |
| 809 function(route) { return toSuccessRouteResponse_(route); }, |
| 810 function(err) { return toErrorRouteResponse_(err); }); |
| 811 }; |
| 812 |
| 756 mediaRouter = new MediaRouter(connector.bindHandleToProxy( | 813 mediaRouter = new MediaRouter(connector.bindHandleToProxy( |
| 757 serviceProvider.connectToService( | 814 serviceProvider.connectToService( |
| 758 mediaRouterMojom.MediaRouter.name), | 815 mediaRouterMojom.MediaRouter.name), |
| 759 mediaRouterMojom.MediaRouter)); | 816 mediaRouterMojom.MediaRouter)); |
| 760 | 817 |
| 761 return mediaRouter; | 818 return mediaRouter; |
| 762 }); | 819 }); |
| 763 | 820 |
| OLD | NEW |