| 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 'media_route_id': route.id, | 71 'media_route_id': route.id, |
| 72 'media_source': route.mediaSource, | 72 'media_source': route.mediaSource, |
| 73 'media_sink_id': route.sinkId, | 73 'media_sink_id': route.sinkId, |
| 74 'description': route.description, | 74 'description': route.description, |
| 75 'icon_url': route.iconUrl, | 75 'icon_url': route.iconUrl, |
| 76 'is_local': route.isLocal, | 76 'is_local': route.isLocal, |
| 77 'custom_controller_path': route.customControllerPath, | 77 'custom_controller_path': route.customControllerPath, |
| 78 // Begin newly added properties, followed by the milestone they were | 78 // Begin newly added properties, followed by the milestone they were |
| 79 // added. The guard should be safe to remove N+2 milestones later. | 79 // added. The guard should be safe to remove N+2 milestones later. |
| 80 'for_display': route.forDisplay, // M47 | 80 'for_display': route.forDisplay, // M47 |
| 81 'off_the_record': !!route.offTheRecord // M50 | 81 'incognito': !!route.offTheRecord // M50 |
| 82 }); | 82 }); |
| 83 } | 83 } |
| 84 | 84 |
| 85 /** | 85 /** |
| 86 * Converts a route message to a RouteMessage Mojo object. | 86 * Converts a route message to a RouteMessage Mojo object. |
| 87 * @param {!RouteMessage} message | 87 * @param {!RouteMessage} message |
| 88 * @return {!mediaRouterMojom.RouteMessage} A Mojo RouteMessage object. | 88 * @return {!mediaRouterMojom.RouteMessage} A Mojo RouteMessage object. |
| 89 */ | 89 */ |
| 90 function messageToMojo_(message) { | 90 function messageToMojo_(message) { |
| 91 if ("string" == typeof message.message) { | 91 if ("string" == typeof message.message) { |
| (...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 * be populated. | 596 * be populated. |
| 597 * @param {!string} sourceUrn Media source to render. | 597 * @param {!string} sourceUrn Media source to render. |
| 598 * @param {!string} sinkId Media sink ID. | 598 * @param {!string} sinkId Media sink ID. |
| 599 * @param {!string} presentationId Presentation ID from the site | 599 * @param {!string} presentationId Presentation ID from the site |
| 600 * requesting presentation. TODO(mfoltz): Remove. | 600 * requesting presentation. TODO(mfoltz): Remove. |
| 601 * @param {!string} origin Origin of site requesting presentation. | 601 * @param {!string} origin Origin of site requesting presentation. |
| 602 * @param {!number} tabId ID of tab requesting presentation. | 602 * @param {!number} tabId ID of tab requesting presentation. |
| 603 * @param {!number} timeoutMillis If positive, the timeout duration for the | 603 * @param {!number} timeoutMillis If positive, the timeout duration for the |
| 604 * request, measured in seconds. Otherwise, the default duration will be | 604 * request, measured in seconds. Otherwise, the default duration will be |
| 605 * used. | 605 * used. |
| 606 * @param {!boolean} offTheRecord If true, the route is being requested by | 606 * @param {!boolean} incognito If true, the route is being requested by |
| 607 * an off the record (incognito) profile. | 607 * an incognito profile. |
| 608 * @return {!Promise.<!Object>} A Promise resolving to an object describing | 608 * @return {!Promise.<!Object>} A Promise resolving to an object describing |
| 609 * 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 |
| 610 * failure. | 610 * failure. |
| 611 */ | 611 */ |
| 612 MediaRouteProvider.prototype.createRoute = | 612 MediaRouteProvider.prototype.createRoute = |
| 613 function(sourceUrn, sinkId, presentationId, origin, tabId, | 613 function(sourceUrn, sinkId, presentationId, origin, tabId, |
| 614 timeoutMillis, offTheRecord) { | 614 timeoutMillis, incognito) { |
| 615 return this.handlers_.createRoute( | 615 return this.handlers_.createRoute( |
| 616 sourceUrn, sinkId, presentationId, origin, tabId, timeoutMillis, | 616 sourceUrn, sinkId, presentationId, origin, tabId, timeoutMillis, |
| 617 offTheRecord) | 617 incognito) |
| 618 .then(function(route) { | 618 .then(function(route) { |
| 619 return toSuccessRouteResponse_(route); | 619 return toSuccessRouteResponse_(route); |
| 620 }, | 620 }, |
| 621 function(err) { | 621 function(err) { |
| 622 return toErrorRouteResponse_(err); | 622 return toErrorRouteResponse_(err); |
| 623 }); | 623 }); |
| 624 }; | 624 }; |
| 625 | 625 |
| 626 /** | 626 /** |
| 627 * 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 |
| 628 * by |sourceUrn| and |presentationId|. |origin| and |tabId| are used for | 628 * by |sourceUrn| and |presentationId|. |origin| and |tabId| are used for |
| 629 * validating same-origin/tab scope. | 629 * validating same-origin/tab scope. |
| 630 * @param {!string} sourceUrn Media source to render. | 630 * @param {!string} sourceUrn Media source to render. |
| 631 * @param {!string} presentationId Presentation ID to join. | 631 * @param {!string} presentationId Presentation ID to join. |
| 632 * @param {!string} origin Origin of site requesting join. | 632 * @param {!string} origin Origin of site requesting join. |
| 633 * @param {!number} tabId ID of tab requesting join. | 633 * @param {!number} tabId ID of tab requesting join. |
| 634 * @param {!number} timeoutMillis If positive, the timeout duration for the | 634 * @param {!number} timeoutMillis If positive, the timeout duration for the |
| 635 * request, measured in seconds. Otherwise, the default duration will be | 635 * request, measured in seconds. Otherwise, the default duration will be |
| 636 * used. | 636 * used. |
| 637 * @param {!boolean} offTheRecord If true, the route is being requested by | 637 * @param {!boolean} incognito If true, the route is being requested by |
| 638 * an off the record (incognito) profile. | 638 * an incognito profile. |
| 639 * @return {!Promise.<!Object>} A Promise resolving to an object describing | 639 * @return {!Promise.<!Object>} A Promise resolving to an object describing |
| 640 * the newly created media route, or rejecting with an error message on | 640 * the newly created media route, or rejecting with an error message on |
| 641 * failure. | 641 * failure. |
| 642 */ | 642 */ |
| 643 MediaRouteProvider.prototype.joinRoute = | 643 MediaRouteProvider.prototype.joinRoute = |
| 644 function(sourceUrn, presentationId, origin, tabId, timeoutMillis, | 644 function(sourceUrn, presentationId, origin, tabId, timeoutMillis, |
| 645 offTheRecord) { | 645 incognito) { |
| 646 return this.handlers_.joinRoute( | 646 return this.handlers_.joinRoute( |
| 647 sourceUrn, presentationId, origin, tabId, timeoutMillis, offTheRecord) | 647 sourceUrn, presentationId, origin, tabId, timeoutMillis, incognito) |
| 648 .then(function(route) { | 648 .then(function(route) { |
| 649 return toSuccessRouteResponse_(route); | 649 return toSuccessRouteResponse_(route); |
| 650 }, | 650 }, |
| 651 function(err) { | 651 function(err) { |
| 652 return toErrorRouteResponse_(err); | 652 return toErrorRouteResponse_(err); |
| 653 }); | 653 }); |
| 654 }; | 654 }; |
| 655 | 655 |
| 656 /** | 656 /** |
| 657 * 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 |
| 658 * by |sourceUrn| and |routeId|. |origin| and |tabId| are used for | 658 * by |sourceUrn| and |routeId|. |origin| and |tabId| are used for |
| 659 * validating same-origin/tab scope. | 659 * validating same-origin/tab scope. |
| 660 * @param {!string} sourceUrn Media source to render. | 660 * @param {!string} sourceUrn Media source to render. |
| 661 * @param {!string} routeId Route ID to join. | 661 * @param {!string} routeId Route ID to join. |
| 662 * @param {!string} presentationId Presentation ID to join. | 662 * @param {!string} presentationId Presentation ID to join. |
| 663 * @param {!string} origin Origin of site requesting join. | 663 * @param {!string} origin Origin of site requesting join. |
| 664 * @param {!number} tabId ID of tab requesting join. | 664 * @param {!number} tabId ID of tab requesting join. |
| 665 * @param {!number} timeoutMillis If positive, the timeout duration for the | 665 * @param {!number} timeoutMillis If positive, the timeout duration for the |
| 666 * request, measured in seconds. Otherwise, the default duration will be | 666 * request, measured in seconds. Otherwise, the default duration will be |
| 667 * used. | 667 * used. |
| 668 * @param {!boolean} offTheRecord If true, the route is being requested by | 668 * @param {!boolean} incognito If true, the route is being requested by |
| 669 * an off the record (incognito) profile. | 669 * an incognito profile. |
| 670 * @return {!Promise.<!Object>} A Promise resolving to an object describing | 670 * @return {!Promise.<!Object>} A Promise resolving to an object describing |
| 671 * the newly created media route, or rejecting with an error message on | 671 * the newly created media route, or rejecting with an error message on |
| 672 * failure. | 672 * failure. |
| 673 */ | 673 */ |
| 674 MediaRouteProvider.prototype.connectRouteByRouteId = | 674 MediaRouteProvider.prototype.connectRouteByRouteId = |
| 675 function(sourceUrn, routeId, presentationId, origin, tabId, | 675 function(sourceUrn, routeId, presentationId, origin, tabId, |
| 676 timeoutMillis, offTheRecord) { | 676 timeoutMillis, incognito) { |
| 677 return this.handlers_.connectRouteByRouteId( | 677 return this.handlers_.connectRouteByRouteId( |
| 678 sourceUrn, routeId, presentationId, origin, tabId, timeoutMillis, | 678 sourceUrn, routeId, presentationId, origin, tabId, timeoutMillis, |
| 679 offTheRecord) | 679 incognito) |
| 680 .then(function(route) { | 680 .then(function(route) { |
| 681 return toSuccessRouteResponse_(route); | 681 return toSuccessRouteResponse_(route); |
| 682 }, | 682 }, |
| 683 function(err) { | 683 function(err) { |
| 684 return toErrorRouteResponse_(err); | 684 return toErrorRouteResponse_(err); |
| 685 }); | 685 }); |
| 686 }; | 686 }; |
| 687 | 687 |
| 688 /** | 688 /** |
| 689 * Terminates the route specified by |routeId|. | 689 * Terminates the route specified by |routeId|. |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 857 }; | 857 }; |
| 858 | 858 |
| 859 mediaRouter = new MediaRouter(connector.bindHandleToProxy( | 859 mediaRouter = new MediaRouter(connector.bindHandleToProxy( |
| 860 serviceProvider.connectToService( | 860 serviceProvider.connectToService( |
| 861 mediaRouterMojom.MediaRouter.name), | 861 mediaRouterMojom.MediaRouter.name), |
| 862 mediaRouterMojom.MediaRouter)); | 862 mediaRouterMojom.MediaRouter)); |
| 863 | 863 |
| 864 return mediaRouter; | 864 return mediaRouter; |
| 865 }); | 865 }); |
| 866 | 866 |
| OLD | NEW |