| 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_interfaces', | 10 'content/public/renderer/frame_interfaces', |
| 11 'chrome/browser/media/router/mojo/media_router.mojom', | 11 'chrome/browser/media/router/mojo/media_router.mojom', |
| 12 'extensions/common/mojo/keep_alive.mojom', | 12 'extensions/common/mojo/keep_alive.mojom', |
| 13 'mojo/common/common_custom_types.mojom', |
| 13 'mojo/public/js/connection', | 14 'mojo/public/js/connection', |
| 14 'mojo/public/js/router', | 15 'mojo/public/js/router', |
| 15 ], function(bindings, | 16 ], function(bindings, |
| 16 core, | 17 core, |
| 17 frameInterfaces, | 18 frameInterfaces, |
| 18 mediaRouterMojom, | 19 mediaRouterMojom, |
| 19 keepAliveMojom, | 20 keepAliveMojom, |
| 21 commonCustomTypesMojom, |
| 20 connector, | 22 connector, |
| 21 routerModule) { | 23 routerModule) { |
| 22 'use strict'; | 24 'use strict'; |
| 23 | 25 |
| 24 /** | 26 /** |
| 25 * Converts a media sink to a MediaSink Mojo object. | 27 * Converts a media sink to a MediaSink Mojo object. |
| 26 * @param {!MediaSink} sink A media sink. | 28 * @param {!MediaSink} sink A media sink. |
| 27 * @return {!mediaRouterMojom.MediaSink} A Mojo MediaSink object. | 29 * @return {!mediaRouterMojom.MediaSink} A Mojo MediaSink object. |
| 28 */ | 30 */ |
| 29 function sinkToMojo_(sink) { | 31 function sinkToMojo_(sink) { |
| (...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 /** | 594 /** |
| 593 * Requests that |sinkId| render the media referenced by |sourceUrn|. If the | 595 * Requests that |sinkId| render the media referenced by |sourceUrn|. If the |
| 594 * request is from the Presentation API, then origin and tabId will | 596 * request is from the Presentation API, then origin and tabId will |
| 595 * be populated. | 597 * be populated. |
| 596 * @param {!string} sourceUrn Media source to render. | 598 * @param {!string} sourceUrn Media source to render. |
| 597 * @param {!string} sinkId Media sink ID. | 599 * @param {!string} sinkId Media sink ID. |
| 598 * @param {!string} presentationId Presentation ID from the site | 600 * @param {!string} presentationId Presentation ID from the site |
| 599 * requesting presentation. TODO(mfoltz): Remove. | 601 * requesting presentation. TODO(mfoltz): Remove. |
| 600 * @param {!string} origin Origin of site requesting presentation. | 602 * @param {!string} origin Origin of site requesting presentation. |
| 601 * @param {!number} tabId ID of tab requesting presentation. | 603 * @param {!number} tabId ID of tab requesting presentation. |
| 602 * @param {!number} timeoutMillis If positive, the timeout duration for the | 604 * @param {!TimeDelta} timeout If positive, the timeout duration for the |
| 603 * request, measured in seconds. Otherwise, the default duration will be | 605 * request. Otherwise, the default duration will be used. |
| 604 * used. | |
| 605 * @param {!boolean} incognito If true, the route is being requested by | 606 * @param {!boolean} incognito If true, the route is being requested by |
| 606 * an incognito profile. | 607 * an incognito profile. |
| 607 * @return {!Promise.<!Object>} A Promise resolving to an object describing | 608 * @return {!Promise.<!Object>} A Promise resolving to an object describing |
| 608 * the newly created media route, or rejecting with an error message on | 609 * the newly created media route, or rejecting with an error message on |
| 609 * failure. | 610 * failure. |
| 610 */ | 611 */ |
| 611 MediaRouteProvider.prototype.createRoute = | 612 MediaRouteProvider.prototype.createRoute = |
| 612 function(sourceUrn, sinkId, presentationId, origin, tabId, | 613 function(sourceUrn, sinkId, presentationId, origin, tabId, |
| 613 timeoutMillis, incognito) { | 614 timeout, incognito) { |
| 614 return this.handlers_.createRoute( | 615 return this.handlers_.createRoute( |
| 615 sourceUrn, sinkId, presentationId, origin, tabId, timeoutMillis, | 616 sourceUrn, sinkId, presentationId, origin, tabId, |
| 616 incognito) | 617 Math.floor(timeout.microseconds / 1000), incognito) |
| 617 .then(function(route) { | 618 .then(function(route) { |
| 618 return toSuccessRouteResponse_(route); | 619 return toSuccessRouteResponse_(route); |
| 619 }, | 620 }, |
| 620 function(err) { | 621 function(err) { |
| 621 return toErrorRouteResponse_(err); | 622 return toErrorRouteResponse_(err); |
| 622 }); | 623 }); |
| 623 }; | 624 }; |
| 624 | 625 |
| 625 /** | 626 /** |
| 626 * Handles a request via the Presentation API to join an existing route given | 627 * Handles a request via the Presentation API to join an existing route given |
| 627 * by |sourceUrn| and |presentationId|. |origin| and |tabId| are used for | 628 * by |sourceUrn| and |presentationId|. |origin| and |tabId| are used for |
| 628 * validating same-origin/tab scope. | 629 * validating same-origin/tab scope. |
| 629 * @param {!string} sourceUrn Media source to render. | 630 * @param {!string} sourceUrn Media source to render. |
| 630 * @param {!string} presentationId Presentation ID to join. | 631 * @param {!string} presentationId Presentation ID to join. |
| 631 * @param {!string} origin Origin of site requesting join. | 632 * @param {!string} origin Origin of site requesting join. |
| 632 * @param {!number} tabId ID of tab requesting join. | 633 * @param {!number} tabId ID of tab requesting join. |
| 633 * @param {!number} timeoutMillis If positive, the timeout duration for the | 634 * @param {!TimeDelta} timeout If positive, the timeout duration for the |
| 634 * request, measured in seconds. Otherwise, the default duration will be | 635 * request. Otherwise, the default duration will be used. |
| 635 * used. | |
| 636 * @param {!boolean} incognito If true, the route is being requested by | 636 * @param {!boolean} incognito If true, the route is being requested by |
| 637 * an incognito profile. | 637 * an incognito profile. |
| 638 * @return {!Promise.<!Object>} A Promise resolving to an object describing | 638 * @return {!Promise.<!Object>} A Promise resolving to an object describing |
| 639 * the newly created media route, or rejecting with an error message on | 639 * the newly created media route, or rejecting with an error message on |
| 640 * failure. | 640 * failure. |
| 641 */ | 641 */ |
| 642 MediaRouteProvider.prototype.joinRoute = | 642 MediaRouteProvider.prototype.joinRoute = |
| 643 function(sourceUrn, presentationId, origin, tabId, timeoutMillis, | 643 function(sourceUrn, presentationId, origin, tabId, timeout, |
| 644 incognito) { | 644 incognito) { |
| 645 return this.handlers_.joinRoute( | 645 return this.handlers_.joinRoute( |
| 646 sourceUrn, presentationId, origin, tabId, timeoutMillis, incognito) | 646 sourceUrn, presentationId, origin, tabId, |
| 647 Math.floor(timeout.microseconds / 1000), incognito) |
| 647 .then(function(route) { | 648 .then(function(route) { |
| 648 return toSuccessRouteResponse_(route); | 649 return toSuccessRouteResponse_(route); |
| 649 }, | 650 }, |
| 650 function(err) { | 651 function(err) { |
| 651 return toErrorRouteResponse_(err); | 652 return toErrorRouteResponse_(err); |
| 652 }); | 653 }); |
| 653 }; | 654 }; |
| 654 | 655 |
| 655 /** | 656 /** |
| 656 * Handles a request via the Presentation API to join an existing route given | 657 * Handles a request via the Presentation API to join an existing route given |
| 657 * by |sourceUrn| and |routeId|. |origin| and |tabId| are used for | 658 * by |sourceUrn| and |routeId|. |origin| and |tabId| are used for |
| 658 * validating same-origin/tab scope. | 659 * validating same-origin/tab scope. |
| 659 * @param {!string} sourceUrn Media source to render. | 660 * @param {!string} sourceUrn Media source to render. |
| 660 * @param {!string} routeId Route ID to join. | 661 * @param {!string} routeId Route ID to join. |
| 661 * @param {!string} presentationId Presentation ID to join. | 662 * @param {!string} presentationId Presentation ID to join. |
| 662 * @param {!string} origin Origin of site requesting join. | 663 * @param {!string} origin Origin of site requesting join. |
| 663 * @param {!number} tabId ID of tab requesting join. | 664 * @param {!number} tabId ID of tab requesting join. |
| 664 * @param {!number} timeoutMillis If positive, the timeout duration for the | 665 * @param {!TimeDelta} timeout If positive, the timeout duration for the |
| 665 * request, measured in seconds. Otherwise, the default duration will be | 666 * request. Otherwise, the default duration will be used. |
| 666 * used. | |
| 667 * @param {!boolean} incognito If true, the route is being requested by | 667 * @param {!boolean} incognito If true, the route is being requested by |
| 668 * an incognito profile. | 668 * an incognito profile. |
| 669 * @return {!Promise.<!Object>} A Promise resolving to an object describing | 669 * @return {!Promise.<!Object>} A Promise resolving to an object describing |
| 670 * the newly created media route, or rejecting with an error message on | 670 * the newly created media route, or rejecting with an error message on |
| 671 * failure. | 671 * failure. |
| 672 */ | 672 */ |
| 673 MediaRouteProvider.prototype.connectRouteByRouteId = | 673 MediaRouteProvider.prototype.connectRouteByRouteId = |
| 674 function(sourceUrn, routeId, presentationId, origin, tabId, | 674 function(sourceUrn, routeId, presentationId, origin, tabId, |
| 675 timeoutMillis, incognito) { | 675 timeout, incognito) { |
| 676 return this.handlers_.connectRouteByRouteId( | 676 return this.handlers_.connectRouteByRouteId( |
| 677 sourceUrn, routeId, presentationId, origin, tabId, timeoutMillis, | 677 sourceUrn, routeId, presentationId, origin, tabId, |
| 678 incognito) | 678 Math.floor(timeout.microseconds / 1000), incognito) |
| 679 .then(function(route) { | 679 .then(function(route) { |
| 680 return toSuccessRouteResponse_(route); | 680 return toSuccessRouteResponse_(route); |
| 681 }, | 681 }, |
| 682 function(err) { | 682 function(err) { |
| 683 return toErrorRouteResponse_(err); | 683 return toErrorRouteResponse_(err); |
| 684 }); | 684 }); |
| 685 }; | 685 }; |
| 686 | 686 |
| 687 /** | 687 /** |
| 688 * Terminates the route specified by |routeId|. | 688 * Terminates the route specified by |routeId|. |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 855 }); | 855 }); |
| 856 }; | 856 }; |
| 857 | 857 |
| 858 mediaRouter = new MediaRouter(connector.bindHandleToProxy( | 858 mediaRouter = new MediaRouter(connector.bindHandleToProxy( |
| 859 frameInterfaces.getInterface(mediaRouterMojom.MediaRouter.name), | 859 frameInterfaces.getInterface(mediaRouterMojom.MediaRouter.name), |
| 860 mediaRouterMojom.MediaRouter)); | 860 mediaRouterMojom.MediaRouter)); |
| 861 | 861 |
| 862 return mediaRouter; | 862 return mediaRouter; |
| 863 }); | 863 }); |
| 864 | 864 |
| OLD | NEW |