| 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', |
| (...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 } | 538 } |
| 539 MediaRouteProvider.prototype = Object.create( | 539 MediaRouteProvider.prototype = Object.create( |
| 540 mediaRouterMojom.MediaRouteProvider.stubClass.prototype); | 540 mediaRouterMojom.MediaRouteProvider.stubClass.prototype); |
| 541 | 541 |
| 542 /* | 542 /* |
| 543 * Sets the callback handler used to invoke methods in the provider manager. | 543 * Sets the callback handler used to invoke methods in the provider manager. |
| 544 * | 544 * |
| 545 * @param {!MediaRouterHandlers} handlers | 545 * @param {!MediaRouterHandlers} handlers |
| 546 */ | 546 */ |
| 547 MediaRouteProvider.prototype.setHandlers = function(handlers) { | 547 MediaRouteProvider.prototype.setHandlers = function(handlers) { |
| 548 // TODO(mfoltz): Remove when component that supports this method is |
| 549 // rolled out to all Chrome channels in M56. |
| 550 if (!handlers['onBeforeInvokeHandler']) |
| 551 handlers['onBeforeInvokeHandler'] = () => {}; |
| 548 this.handlers_ = handlers; | 552 this.handlers_ = handlers; |
| 549 var requiredHandlers = [ | 553 var requiredHandlers = [ |
| 550 'stopObservingMediaRoutes', | 554 'stopObservingMediaRoutes', |
| 551 'startObservingMediaRoutes', | 555 'startObservingMediaRoutes', |
| 552 'sendRouteMessage', | 556 'sendRouteMessage', |
| 553 'sendRouteBinaryMessage', | 557 'sendRouteBinaryMessage', |
| 554 'startListeningForRouteMessages', | 558 'startListeningForRouteMessages', |
| 555 'stopListeningForRouteMessages', | 559 'stopListeningForRouteMessages', |
| 556 'detachRoute', | 560 'detachRoute', |
| 557 'terminateRoute', | 561 'terminateRoute', |
| 558 'joinRoute', | 562 'joinRoute', |
| 559 'createRoute', | 563 'createRoute', |
| 560 'stopObservingMediaSinks', | 564 'stopObservingMediaSinks', |
| 561 'startObservingMediaRoutes', | 565 'startObservingMediaRoutes', |
| 562 'connectRouteByRouteId', | 566 'connectRouteByRouteId', |
| 563 'enableMdnsDiscovery', | 567 'enableMdnsDiscovery', |
| 564 'updateMediaSinks', | 568 'updateMediaSinks', |
| 565 'searchSinks', | 569 'searchSinks', |
| 570 'onBeforeInvokeHandler' |
| 566 ]; | 571 ]; |
| 567 requiredHandlers.forEach(function(nextHandler) { | 572 requiredHandlers.forEach(function(nextHandler) { |
| 568 if (handlers[nextHandler] === undefined) { | 573 if (handlers[nextHandler] === undefined) { |
| 569 console.error(nextHandler + ' handler not registered.'); | 574 console.error(nextHandler + ' handler not registered.'); |
| 570 } | 575 } |
| 571 }); | 576 }); |
| 572 } | 577 } |
| 573 | 578 |
| 574 /** | 579 /** |
| 575 * Starts querying for sinks capable of displaying the media source | 580 * Starts querying for sinks capable of displaying the media source |
| 576 * designated by |sourceUrn|. Results are returned by calling | 581 * designated by |sourceUrn|. Results are returned by calling |
| 577 * OnSinksReceived. | 582 * OnSinksReceived. |
| 578 * @param {!string} sourceUrn | 583 * @param {!string} sourceUrn |
| 579 */ | 584 */ |
| 580 MediaRouteProvider.prototype.startObservingMediaSinks = | 585 MediaRouteProvider.prototype.startObservingMediaSinks = |
| 581 function(sourceUrn) { | 586 function(sourceUrn) { |
| 587 this.handlers_.onBeforeInvokeHandler(); |
| 582 this.handlers_.startObservingMediaSinks(sourceUrn); | 588 this.handlers_.startObservingMediaSinks(sourceUrn); |
| 583 }; | 589 }; |
| 584 | 590 |
| 585 /** | 591 /** |
| 586 * Stops querying for sinks capable of displaying |sourceUrn|. | 592 * Stops querying for sinks capable of displaying |sourceUrn|. |
| 587 * @param {!string} sourceUrn | 593 * @param {!string} sourceUrn |
| 588 */ | 594 */ |
| 589 MediaRouteProvider.prototype.stopObservingMediaSinks = | 595 MediaRouteProvider.prototype.stopObservingMediaSinks = |
| 590 function(sourceUrn) { | 596 function(sourceUrn) { |
| 597 this.handlers_.onBeforeInvokeHandler(); |
| 591 this.handlers_.stopObservingMediaSinks(sourceUrn); | 598 this.handlers_.stopObservingMediaSinks(sourceUrn); |
| 592 }; | 599 }; |
| 593 | 600 |
| 594 /** | 601 /** |
| 595 * Requests that |sinkId| render the media referenced by |sourceUrn|. If the | 602 * Requests that |sinkId| render the media referenced by |sourceUrn|. If the |
| 596 * request is from the Presentation API, then origin and tabId will | 603 * request is from the Presentation API, then origin and tabId will |
| 597 * be populated. | 604 * be populated. |
| 598 * @param {!string} sourceUrn Media source to render. | 605 * @param {!string} sourceUrn Media source to render. |
| 599 * @param {!string} sinkId Media sink ID. | 606 * @param {!string} sinkId Media sink ID. |
| 600 * @param {!string} presentationId Presentation ID from the site | 607 * @param {!string} presentationId Presentation ID from the site |
| 601 * requesting presentation. TODO(mfoltz): Remove. | 608 * requesting presentation. TODO(mfoltz): Remove. |
| 602 * @param {!string} origin Origin of site requesting presentation. | 609 * @param {!string} origin Origin of site requesting presentation. |
| 603 * @param {!number} tabId ID of tab requesting presentation. | 610 * @param {!number} tabId ID of tab requesting presentation. |
| 604 * @param {!TimeDelta} timeout If positive, the timeout duration for the | 611 * @param {!TimeDelta} timeout If positive, the timeout duration for the |
| 605 * request. Otherwise, the default duration will be used. | 612 * request. Otherwise, the default duration will be used. |
| 606 * @param {!boolean} incognito If true, the route is being requested by | 613 * @param {!boolean} incognito If true, the route is being requested by |
| 607 * an incognito profile. | 614 * an incognito profile. |
| 608 * @return {!Promise.<!Object>} A Promise resolving to an object describing | 615 * @return {!Promise.<!Object>} A Promise resolving to an object describing |
| 609 * the newly created media route, or rejecting with an error message on | 616 * the newly created media route, or rejecting with an error message on |
| 610 * failure. | 617 * failure. |
| 611 */ | 618 */ |
| 612 MediaRouteProvider.prototype.createRoute = | 619 MediaRouteProvider.prototype.createRoute = |
| 613 function(sourceUrn, sinkId, presentationId, origin, tabId, | 620 function(sourceUrn, sinkId, presentationId, origin, tabId, |
| 614 timeout, incognito) { | 621 timeout, incognito) { |
| 622 this.handlers_.onBeforeInvokeHandler(); |
| 615 return this.handlers_.createRoute( | 623 return this.handlers_.createRoute( |
| 616 sourceUrn, sinkId, presentationId, origin, tabId, | 624 sourceUrn, sinkId, presentationId, origin, tabId, |
| 617 Math.floor(timeout.microseconds / 1000), incognito) | 625 Math.floor(timeout.microseconds / 1000), incognito) |
| 618 .then(function(route) { | 626 .then(function(route) { |
| 619 return toSuccessRouteResponse_(route); | 627 return toSuccessRouteResponse_(route); |
| 620 }, | 628 }, |
| 621 function(err) { | 629 function(err) { |
| 622 return toErrorRouteResponse_(err); | 630 return toErrorRouteResponse_(err); |
| 623 }); | 631 }); |
| 624 }; | 632 }; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 635 * request. Otherwise, the default duration will be used. | 643 * request. Otherwise, the default duration will be used. |
| 636 * @param {!boolean} incognito If true, the route is being requested by | 644 * @param {!boolean} incognito If true, the route is being requested by |
| 637 * an incognito profile. | 645 * an incognito profile. |
| 638 * @return {!Promise.<!Object>} A Promise resolving to an object describing | 646 * @return {!Promise.<!Object>} A Promise resolving to an object describing |
| 639 * the newly created media route, or rejecting with an error message on | 647 * the newly created media route, or rejecting with an error message on |
| 640 * failure. | 648 * failure. |
| 641 */ | 649 */ |
| 642 MediaRouteProvider.prototype.joinRoute = | 650 MediaRouteProvider.prototype.joinRoute = |
| 643 function(sourceUrn, presentationId, origin, tabId, timeout, | 651 function(sourceUrn, presentationId, origin, tabId, timeout, |
| 644 incognito) { | 652 incognito) { |
| 653 this.handlers_.onBeforeInvokeHandler(); |
| 645 return this.handlers_.joinRoute( | 654 return this.handlers_.joinRoute( |
| 646 sourceUrn, presentationId, origin, tabId, | 655 sourceUrn, presentationId, origin, tabId, |
| 647 Math.floor(timeout.microseconds / 1000), incognito) | 656 Math.floor(timeout.microseconds / 1000), incognito) |
| 648 .then(function(route) { | 657 .then(function(route) { |
| 649 return toSuccessRouteResponse_(route); | 658 return toSuccessRouteResponse_(route); |
| 650 }, | 659 }, |
| 651 function(err) { | 660 function(err) { |
| 652 return toErrorRouteResponse_(err); | 661 return toErrorRouteResponse_(err); |
| 653 }); | 662 }); |
| 654 }; | 663 }; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 666 * request. Otherwise, the default duration will be used. | 675 * request. Otherwise, the default duration will be used. |
| 667 * @param {!boolean} incognito If true, the route is being requested by | 676 * @param {!boolean} incognito If true, the route is being requested by |
| 668 * an incognito profile. | 677 * an incognito profile. |
| 669 * @return {!Promise.<!Object>} A Promise resolving to an object describing | 678 * @return {!Promise.<!Object>} A Promise resolving to an object describing |
| 670 * the newly created media route, or rejecting with an error message on | 679 * the newly created media route, or rejecting with an error message on |
| 671 * failure. | 680 * failure. |
| 672 */ | 681 */ |
| 673 MediaRouteProvider.prototype.connectRouteByRouteId = | 682 MediaRouteProvider.prototype.connectRouteByRouteId = |
| 674 function(sourceUrn, routeId, presentationId, origin, tabId, | 683 function(sourceUrn, routeId, presentationId, origin, tabId, |
| 675 timeout, incognito) { | 684 timeout, incognito) { |
| 685 this.handlers_.onBeforeInvokeHandler(); |
| 676 return this.handlers_.connectRouteByRouteId( | 686 return this.handlers_.connectRouteByRouteId( |
| 677 sourceUrn, routeId, presentationId, origin, tabId, | 687 sourceUrn, routeId, presentationId, origin, tabId, |
| 678 Math.floor(timeout.microseconds / 1000), incognito) | 688 Math.floor(timeout.microseconds / 1000), incognito) |
| 679 .then(function(route) { | 689 .then(function(route) { |
| 680 return toSuccessRouteResponse_(route); | 690 return toSuccessRouteResponse_(route); |
| 681 }, | 691 }, |
| 682 function(err) { | 692 function(err) { |
| 683 return toErrorRouteResponse_(err); | 693 return toErrorRouteResponse_(err); |
| 684 }); | 694 }); |
| 685 }; | 695 }; |
| 686 | 696 |
| 687 /** | 697 /** |
| 688 * Terminates the route specified by |routeId|. | 698 * Terminates the route specified by |routeId|. |
| 689 * @param {!string} routeId | 699 * @param {!string} routeId |
| 690 * @return {!Promise<!Object>} A Promise resolving to an object describing | 700 * @return {!Promise<!Object>} A Promise resolving to an object describing |
| 691 * the result of the terminate operation, or rejecting with an error | 701 * the result of the terminate operation, or rejecting with an error |
| 692 * message and code if the operation failed. | 702 * message and code if the operation failed. |
| 693 */ | 703 */ |
| 694 MediaRouteProvider.prototype.terminateRoute = function(routeId) { | 704 MediaRouteProvider.prototype.terminateRoute = function(routeId) { |
| 705 this.handlers_.onBeforeInvokeHandler(); |
| 695 // TODO(crbug.com/627967): Remove code path that doesn't expect a Promise | 706 // TODO(crbug.com/627967): Remove code path that doesn't expect a Promise |
| 696 // in M56. | 707 // in M56. |
| 697 var maybePromise = this.handlers_.terminateRoute(routeId); | 708 var maybePromise = this.handlers_.terminateRoute(routeId); |
| 698 var successResult = { | 709 var successResult = { |
| 699 result_code: mediaRouterMojom.RouteRequestResultCode.OK | 710 result_code: mediaRouterMojom.RouteRequestResultCode.OK |
| 700 }; | 711 }; |
| 701 if (maybePromise) { | 712 if (maybePromise) { |
| 702 return maybePromise.then( | 713 return maybePromise.then( |
| 703 function() { return successResult; }, | 714 function() { return successResult; }, |
| 704 function(err) { return toErrorRouteResponse_(err); } | 715 function(err) { return toErrorRouteResponse_(err); } |
| 705 ); | 716 ); |
| 706 } else { | 717 } else { |
| 707 return Promise.resolve(successResult); | 718 return Promise.resolve(successResult); |
| 708 } | 719 } |
| 709 }; | 720 }; |
| 710 | 721 |
| 711 /** | 722 /** |
| 712 * Posts a message to the route designated by |routeId|. | 723 * Posts a message to the route designated by |routeId|. |
| 713 * @param {!string} routeId | 724 * @param {!string} routeId |
| 714 * @param {!string} message | 725 * @param {!string} message |
| 715 * @return {!Promise.<boolean>} Resolved with true if the message was sent, | 726 * @return {!Promise.<boolean>} Resolved with true if the message was sent, |
| 716 * or false on failure. | 727 * or false on failure. |
| 717 */ | 728 */ |
| 718 MediaRouteProvider.prototype.sendRouteMessage = function( | 729 MediaRouteProvider.prototype.sendRouteMessage = function( |
| 719 routeId, message) { | 730 routeId, message) { |
| 731 this.handlers_.onBeforeInvokeHandler(); |
| 720 return this.handlers_.sendRouteMessage(routeId, message) | 732 return this.handlers_.sendRouteMessage(routeId, message) |
| 721 .then(function() { | 733 .then(function() { |
| 722 return {'sent': true}; | 734 return {'sent': true}; |
| 723 }, function() { | 735 }, function() { |
| 724 return {'sent': false}; | 736 return {'sent': false}; |
| 725 }); | 737 }); |
| 726 }; | 738 }; |
| 727 | 739 |
| 728 /** | 740 /** |
| 729 * Sends a binary message to the route designated by |routeId|. | 741 * Sends a binary message to the route designated by |routeId|. |
| 730 * @param {!string} routeId | 742 * @param {!string} routeId |
| 731 * @param {!Uint8Array} data | 743 * @param {!Uint8Array} data |
| 732 * @return {!Promise.<boolean>} Resolved with true if the data was sent, | 744 * @return {!Promise.<boolean>} Resolved with true if the data was sent, |
| 733 * or false on failure. | 745 * or false on failure. |
| 734 */ | 746 */ |
| 735 MediaRouteProvider.prototype.sendRouteBinaryMessage = function( | 747 MediaRouteProvider.prototype.sendRouteBinaryMessage = function( |
| 736 routeId, data) { | 748 routeId, data) { |
| 749 this.handlers_.onBeforeInvokeHandler(); |
| 737 return this.handlers_.sendRouteBinaryMessage(routeId, data) | 750 return this.handlers_.sendRouteBinaryMessage(routeId, data) |
| 738 .then(function() { | 751 .then(function() { |
| 739 return {'sent': true}; | 752 return {'sent': true}; |
| 740 }, function() { | 753 }, function() { |
| 741 return {'sent': false}; | 754 return {'sent': false}; |
| 742 }); | 755 }); |
| 743 }; | 756 }; |
| 744 | 757 |
| 745 /** | 758 /** |
| 746 * Listen for messages from a route. | 759 * Listen for messages from a route. |
| 747 * @param {!string} routeId | 760 * @param {!string} routeId |
| 748 */ | 761 */ |
| 749 MediaRouteProvider.prototype.startListeningForRouteMessages = function( | 762 MediaRouteProvider.prototype.startListeningForRouteMessages = function( |
| 750 routeId) { | 763 routeId) { |
| 764 this.handlers_.onBeforeInvokeHandler(); |
| 751 if (this.handlers_.startListeningForRouteMessages) { | 765 if (this.handlers_.startListeningForRouteMessages) { |
| 752 this.handlers_.startListeningForRouteMessages(routeId); | 766 this.handlers_.startListeningForRouteMessages(routeId); |
| 753 } else { | 767 } else { |
| 754 // Old API. | 768 // Old API. |
| 755 this.listenForRouteMessagesOld(routeId); | 769 this.listenForRouteMessagesOld(routeId); |
| 756 } | 770 } |
| 757 }; | 771 }; |
| 758 | 772 |
| 759 | 773 |
| 760 /** | 774 /** |
| 761 * A hack to adapt new MR messaging API to old extension messaging API. | 775 * A hack to adapt new MR messaging API to old extension messaging API. |
| 762 * TODO(imcheng): Remove in M55 (crbug.com/626395). | 776 * TODO(imcheng): Remove in M55 (crbug.com/626395). |
| 763 * @param {!string} routeId | 777 * @param {!string} routeId |
| 764 */ | 778 */ |
| 765 MediaRouteProvider.prototype.listenForRouteMessagesOld = function(routeId) { | 779 MediaRouteProvider.prototype.listenForRouteMessagesOld = function(routeId) { |
| 780 this.handlers_.onBeforeInvokeHandler(); |
| 766 this.handlers_.listenForRouteMessages(routeId) | 781 this.handlers_.listenForRouteMessages(routeId) |
| 767 .then(function(messages) { | 782 .then(function(messages) { |
| 768 // If messages is empty, then stopListeningForRouteMessages has been | 783 // If messages is empty, then stopListeningForRouteMessages has been |
| 769 // called. We don't need to send it back to MR. | 784 // called. We don't need to send it back to MR. |
| 770 if (messages.length > 0) { | 785 if (messages.length > 0) { |
| 771 // Send the messages back to MR, and listen for next batch of | 786 // Send the messages back to MR, and listen for next batch of |
| 772 // messages. | 787 // messages. |
| 773 this.mediaRouter_.onRouteMessagesReceived(routeId, messages); | 788 this.mediaRouter_.onRouteMessagesReceived(routeId, messages); |
| 774 this.listenForRouteMessagesOld(routeId); | 789 this.listenForRouteMessagesOld(routeId); |
| 775 } | 790 } |
| 776 }.bind(this), function() { | 791 }.bind(this), function() { |
| 777 // Ignore rejections. | 792 // Ignore rejections. |
| 778 }.bind(this)); | 793 }.bind(this)); |
| 779 }; | 794 }; |
| 780 | 795 |
| 781 /** | 796 /** |
| 782 * @param {!string} routeId | 797 * @param {!string} routeId |
| 783 */ | 798 */ |
| 784 MediaRouteProvider.prototype.stopListeningForRouteMessages = function( | 799 MediaRouteProvider.prototype.stopListeningForRouteMessages = function( |
| 785 routeId) { | 800 routeId) { |
| 801 this.handlers_.onBeforeInvokeHandler(); |
| 786 this.handlers_.stopListeningForRouteMessages(routeId); | 802 this.handlers_.stopListeningForRouteMessages(routeId); |
| 787 }; | 803 }; |
| 788 | 804 |
| 789 /** | 805 /** |
| 790 * Indicates that the presentation connection that was connected to |routeId| | 806 * Indicates that the presentation connection that was connected to |routeId| |
| 791 * is no longer connected to it. | 807 * is no longer connected to it. |
| 792 * @param {!string} routeId | 808 * @param {!string} routeId |
| 793 */ | 809 */ |
| 794 MediaRouteProvider.prototype.detachRoute = function( | 810 MediaRouteProvider.prototype.detachRoute = function( |
| 795 routeId) { | 811 routeId) { |
| 796 this.handlers_.detachRoute(routeId); | 812 this.handlers_.detachRoute(routeId); |
| 797 }; | 813 }; |
| 798 | 814 |
| 799 /** | 815 /** |
| 800 * Requests that the provider manager start sending information about active | 816 * Requests that the provider manager start sending information about active |
| 801 * media routes to the Media Router. | 817 * media routes to the Media Router. |
| 802 * @param {!string} sourceUrn | 818 * @param {!string} sourceUrn |
| 803 */ | 819 */ |
| 804 MediaRouteProvider.prototype.startObservingMediaRoutes = function(sourceUrn) { | 820 MediaRouteProvider.prototype.startObservingMediaRoutes = function(sourceUrn) { |
| 821 this.handlers_.onBeforeInvokeHandler(); |
| 805 this.handlers_.startObservingMediaRoutes(sourceUrn); | 822 this.handlers_.startObservingMediaRoutes(sourceUrn); |
| 806 }; | 823 }; |
| 807 | 824 |
| 808 /** | 825 /** |
| 809 * Requests that the provider manager stop sending information about active | 826 * Requests that the provider manager stop sending information about active |
| 810 * media routes to the Media Router. | 827 * media routes to the Media Router. |
| 811 * @param {!string} sourceUrn | 828 * @param {!string} sourceUrn |
| 812 */ | 829 */ |
| 813 MediaRouteProvider.prototype.stopObservingMediaRoutes = function(sourceUrn) { | 830 MediaRouteProvider.prototype.stopObservingMediaRoutes = function(sourceUrn) { |
| 831 this.handlers_.onBeforeInvokeHandler(); |
| 814 this.handlers_.stopObservingMediaRoutes(sourceUrn); | 832 this.handlers_.stopObservingMediaRoutes(sourceUrn); |
| 815 }; | 833 }; |
| 816 | 834 |
| 817 /** | 835 /** |
| 818 * Enables mDNS device discovery. | 836 * Enables mDNS device discovery. |
| 819 */ | 837 */ |
| 820 MediaRouteProvider.prototype.enableMdnsDiscovery = function() { | 838 MediaRouteProvider.prototype.enableMdnsDiscovery = function() { |
| 839 this.handlers_.onBeforeInvokeHandler(); |
| 821 this.handlers_.enableMdnsDiscovery(); | 840 this.handlers_.enableMdnsDiscovery(); |
| 822 }; | 841 }; |
| 823 | 842 |
| 824 /** | 843 /** |
| 825 * Requests that the provider manager update media sinks. | 844 * Requests that the provider manager update media sinks. |
| 826 * @param {!string} sourceUrn | 845 * @param {!string} sourceUrn |
| 827 */ | 846 */ |
| 828 MediaRouteProvider.prototype.updateMediaSinks = function(sourceUrn) { | 847 MediaRouteProvider.prototype.updateMediaSinks = function(sourceUrn) { |
| 848 this.handlers_.onBeforeInvokeHandler(); |
| 829 this.handlers_.updateMediaSinks(sourceUrn); | 849 this.handlers_.updateMediaSinks(sourceUrn); |
| 830 }; | 850 }; |
| 831 | 851 |
| 832 /** | 852 /** |
| 833 * Requests that the provider manager search its providers for a sink matching | 853 * Requests that the provider manager search its providers for a sink matching |
| 834 * |searchCriteria| that is compatible with |sourceUrn|. If a sink is found | 854 * |searchCriteria| that is compatible with |sourceUrn|. If a sink is found |
| 835 * that can be used immediately for route creation, its ID is returned. | 855 * that can be used immediately for route creation, its ID is returned. |
| 836 * Otherwise the empty string is returned. | 856 * Otherwise the empty string is returned. |
| 837 * | 857 * |
| 838 * @param {string} sinkId Sink ID of the pseudo sink generating the request. | 858 * @param {string} sinkId Sink ID of the pseudo sink generating the request. |
| 839 * @param {string} sourceUrn Media source to be used with the sink. | 859 * @param {string} sourceUrn Media source to be used with the sink. |
| 840 * @param {!SinkSearchCriteria} searchCriteria Search criteria for the route | 860 * @param {!SinkSearchCriteria} searchCriteria Search criteria for the route |
| 841 * providers. | 861 * providers. |
| 842 * @return {!Promise.<!{sink_id: !string}>} A Promise resolving to either the | 862 * @return {!Promise.<!{sink_id: !string}>} A Promise resolving to either the |
| 843 * sink ID of the sink found by the search that can be used for route | 863 * sink ID of the sink found by the search that can be used for route |
| 844 * creation, or the empty string if no route can be immediately created. | 864 * creation, or the empty string if no route can be immediately created. |
| 845 */ | 865 */ |
| 846 MediaRouteProvider.prototype.searchSinks = function( | 866 MediaRouteProvider.prototype.searchSinks = function( |
| 847 sinkId, sourceUrn, searchCriteria) { | 867 sinkId, sourceUrn, searchCriteria) { |
| 848 // TODO(btolsch): Remove this check when we no longer expect old extensions | 868 // TODO(btolsch): Remove this check when we no longer expect old extensions |
| 849 // to be missing this API. | 869 // to be missing this API. |
| 850 if (!this.handlers_.searchSinks) { | 870 if (!this.handlers_.searchSinks) { |
| 851 return Promise.resolve({'sink_id': ''}); | 871 return Promise.resolve({'sink_id': ''}); |
| 852 } | 872 } |
| 873 this.handlers_.onBeforeInvokeHandler(); |
| 853 return Promise.resolve({ | 874 return Promise.resolve({ |
| 854 'sink_id': this.handlers_.searchSinks(sinkId, sourceUrn, searchCriteria) | 875 'sink_id': this.handlers_.searchSinks(sinkId, sourceUrn, searchCriteria) |
| 855 }); | 876 }); |
| 856 }; | 877 }; |
| 857 | 878 |
| 858 mediaRouter = new MediaRouter(connector.bindHandleToProxy( | 879 mediaRouter = new MediaRouter(connector.bindHandleToProxy( |
| 859 frameInterfaces.getInterface(mediaRouterMojom.MediaRouter.name), | 880 frameInterfaces.getInterface(mediaRouterMojom.MediaRouter.name), |
| 860 mediaRouterMojom.MediaRouter)); | 881 mediaRouterMojom.MediaRouter)); |
| 861 | 882 |
| 862 return mediaRouter; | 883 return mediaRouter; |
| 863 }); | 884 }); |
| 864 | |
| OLD | NEW |