| 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 'content/public/renderer/frame_interfaces', | 8 'content/public/renderer/frame_interfaces', |
| 9 'chrome/browser/media/router/mojo/media_router.mojom', | 9 'chrome/browser/media/router/mojo/media_router.mojom', |
| 10 'extensions/common/mojo/keep_alive.mojom', | 10 'extensions/common/mojo/keep_alive.mojom', |
| 11 'mojo/common/time.mojom', | 11 'mojo/common/time.mojom', |
| 12 'mojo/public/js/bindings', | 12 'mojo/public/js/bindings', |
| 13 'url/mojo/url.mojom', |
| 13 ], function(frameInterfaces, | 14 ], function(frameInterfaces, |
| 14 mediaRouterMojom, | 15 mediaRouterMojom, |
| 15 keepAliveMojom, | 16 keepAliveMojom, |
| 16 timeMojom, | 17 timeMojom, |
| 17 bindings) { | 18 bindings) { |
| 18 'use strict'; | 19 'use strict'; |
| 19 | 20 |
| 20 /** | 21 /** |
| 21 * Converts a media sink to a MediaSink Mojo object. | 22 * Converts a media sink to a MediaSink Mojo object. |
| 22 * @param {!MediaSink} sink A media sink. | 23 * @param {!MediaSink} sink A media sink. |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 | 476 |
| 476 /** | 477 /** |
| 477 * @type {function()} | 478 * @type {function()} |
| 478 */ | 479 */ |
| 479 this.updateMediaSinks = null; | 480 this.updateMediaSinks = null; |
| 480 | 481 |
| 481 /** | 482 /** |
| 482 * @type {function(!string, !string, !SinkSearchCriteria): !string} | 483 * @type {function(!string, !string, !SinkSearchCriteria): !string} |
| 483 */ | 484 */ |
| 484 this.searchSinks = null; | 485 this.searchSinks = null; |
| 486 |
| 487 /** |
| 488 * @type {function()} |
| 489 */ |
| 490 this.onSinksDiscovered = null; |
| 485 }; | 491 }; |
| 486 | 492 |
| 487 /** | 493 /** |
| 488 * Routes calls from Media Router to the provider manager extension. | 494 * Routes calls from Media Router to the provider manager extension. |
| 489 * Registered with the MediaRouter stub. | 495 * Registered with the MediaRouter stub. |
| 490 * @param {!MediaRouter} MediaRouter proxy to call into the | 496 * @param {!MediaRouter} MediaRouter proxy to call into the |
| 491 * Media Router mojo interface. | 497 * Media Router mojo interface. |
| 492 * @constructor | 498 * @constructor |
| 493 */ | 499 */ |
| 494 function MediaRouteProvider(mediaRouter) { | 500 function MediaRouteProvider(mediaRouter) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 'detachRoute', | 532 'detachRoute', |
| 527 'terminateRoute', | 533 'terminateRoute', |
| 528 'joinRoute', | 534 'joinRoute', |
| 529 'createRoute', | 535 'createRoute', |
| 530 'stopObservingMediaSinks', | 536 'stopObservingMediaSinks', |
| 531 'startObservingMediaRoutes', | 537 'startObservingMediaRoutes', |
| 532 'connectRouteByRouteId', | 538 'connectRouteByRouteId', |
| 533 'enableMdnsDiscovery', | 539 'enableMdnsDiscovery', |
| 534 'updateMediaSinks', | 540 'updateMediaSinks', |
| 535 'searchSinks', | 541 'searchSinks', |
| 542 'onSinksDiscovered', |
| 536 'onBeforeInvokeHandler' | 543 'onBeforeInvokeHandler' |
| 537 ]; | 544 ]; |
| 538 requiredHandlers.forEach(function(nextHandler) { | 545 requiredHandlers.forEach(function(nextHandler) { |
| 539 if (handlers[nextHandler] === undefined) { | 546 if (handlers[nextHandler] === undefined) { |
| 540 console.error(nextHandler + ' handler not registered.'); | 547 console.error(nextHandler + ' handler not registered.'); |
| 541 } | 548 } |
| 542 }); | 549 }); |
| 543 } | 550 } |
| 544 | 551 |
| 545 /** | 552 /** |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 796 // to be missing this API. | 803 // to be missing this API. |
| 797 if (!this.handlers_.searchSinks) { | 804 if (!this.handlers_.searchSinks) { |
| 798 return Promise.resolve({'sink_id': ''}); | 805 return Promise.resolve({'sink_id': ''}); |
| 799 } | 806 } |
| 800 this.handlers_.onBeforeInvokeHandler(); | 807 this.handlers_.onBeforeInvokeHandler(); |
| 801 return Promise.resolve({ | 808 return Promise.resolve({ |
| 802 'sink_id': this.handlers_.searchSinks(sinkId, sourceUrn, searchCriteria) | 809 'sink_id': this.handlers_.searchSinks(sinkId, sourceUrn, searchCriteria) |
| 803 }); | 810 }); |
| 804 }; | 811 }; |
| 805 | 812 |
| 813 /** |
| 814 * Notifies the provider manager that MediaRouter has discovered a list of |
| 815 * sinks. |
| 816 * @param {!Array<!mediaRouterMojom.MediaSink>} sinks |
| 817 */ |
| 818 MediaRouteProvider.prototype.onSinksDiscovered = function(sinks) { |
| 819 this.handlers_.onBeforeInvokeHandler(); |
| 820 this.handlers_.onSinksDiscovered(sinks); |
| 821 }; |
| 822 |
| 806 mediaRouter = new MediaRouter(new mediaRouterMojom.MediaRouterPtr( | 823 mediaRouter = new MediaRouter(new mediaRouterMojom.MediaRouterPtr( |
| 807 frameInterfaces.getInterface(mediaRouterMojom.MediaRouter.name))); | 824 frameInterfaces.getInterface(mediaRouterMojom.MediaRouter.name))); |
| 808 | 825 |
| 809 return mediaRouter; | 826 return mediaRouter; |
| 810 }); | 827 }); |
| OLD | NEW |