Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: extensions/renderer/resources/media_router_bindings.js

Issue 2779203003: [Media Router] Export Mojom definitions in media_router_bindings.js. (Closed)
Patch Set: Add MediaController / MediaStatusObsever into bindigns Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_controller.mojom',
imcheng 2017/03/29 23:37:33 Note: I will change this if Takumi's patch to move
9 'chrome/browser/media/router/mojo/media_router.mojom', 10 'chrome/browser/media/router/mojo/media_router.mojom',
11 'chrome/browser/media/router/mojo/media_status.mojom',
10 'extensions/common/mojo/keep_alive.mojom', 12 'extensions/common/mojo/keep_alive.mojom',
11 'mojo/common/time.mojom', 13 'mojo/common/time.mojom',
12 'mojo/public/js/bindings', 14 'mojo/public/js/bindings',
15 'net/interfaces/ip_address.mojom',
13 'url/mojo/origin.mojom', 16 'url/mojo/origin.mojom',
17 'url/mojo/url.mojom',
14 ], function(frameInterfaces, 18 ], function(frameInterfaces,
19 mediaControllerMojom,
15 mediaRouterMojom, 20 mediaRouterMojom,
21 mediaStatusMojom,
16 keepAliveMojom, 22 keepAliveMojom,
17 timeMojom, 23 timeMojom,
18 bindings, 24 bindings,
19 originMojom) { 25 ipAddressMojom,
26 originMojom,
27 urlMojom) {
20 'use strict'; 28 'use strict';
21 29
22 /** 30 /**
23 * Converts a media sink to a MediaSink Mojo object. 31 * Converts a media sink to a MediaSink Mojo object.
24 * @param {!MediaSink} sink A media sink. 32 * @param {!MediaSink} sink A media sink.
25 * @return {!mediaRouterMojom.MediaSink} A Mojo MediaSink object. 33 * @return {!mediaRouterMojom.MediaSink} A Mojo MediaSink object.
26 */ 34 */
27 function sinkToMojo_(sink) { 35 function sinkToMojo_(sink) {
28 return new mediaRouterMojom.MediaSink({ 36 return new mediaRouterMojom.MediaSink({
29 'name': sink.friendlyName, 37 'name': sink.friendlyName,
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 * @type {function()} 519 * @type {function()}
512 */ 520 */
513 this.enableMdnsDiscovery = null; 521 this.enableMdnsDiscovery = null;
514 522
515 /** 523 /**
516 * @type {function()} 524 * @type {function()}
517 */ 525 */
518 this.updateMediaSinks = null; 526 this.updateMediaSinks = null;
519 527
520 /** 528 /**
521 * @type {function(!string, !string, !SinkSearchCriteria): !string} 529 * @type {function(string, string, !SinkSearchCriteria): string}
522 */ 530 */
523 this.searchSinks = null; 531 this.searchSinks = null;
532
533 /**
534 * @type {function(string, !bindings.InterfaceRequest): !Promise<boolean>}
535 */
536 this.createMediaRouteController = null;
537
538 /**
539 * @type {function(string, !mediaStatusMojom.MediaStatusObserverPtr)}
540 */
541 this.setMediaRouteStatusObserver = null;
524 }; 542 };
525 543
526 /** 544 /**
527 * Routes calls from Media Router to the provider manager extension. 545 * Routes calls from Media Router to the provider manager extension.
528 * Registered with the MediaRouter stub. 546 * Registered with the MediaRouter stub.
529 * @param {!MediaRouter} MediaRouter proxy to call into the 547 * @param {!MediaRouter} MediaRouter proxy to call into the
530 * Media Router mojo interface. 548 * Media Router mojo interface.
531 * @constructor 549 * @constructor
532 */ 550 */
533 function MediaRouteProvider(mediaRouter) { 551 function MediaRouteProvider(mediaRouter) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 'detachRoute', 583 'detachRoute',
566 'terminateRoute', 584 'terminateRoute',
567 'joinRoute', 585 'joinRoute',
568 'createRoute', 586 'createRoute',
569 'stopObservingMediaSinks', 587 'stopObservingMediaSinks',
570 'startObservingMediaRoutes', 588 'startObservingMediaRoutes',
571 'connectRouteByRouteId', 589 'connectRouteByRouteId',
572 'enableMdnsDiscovery', 590 'enableMdnsDiscovery',
573 'updateMediaSinks', 591 'updateMediaSinks',
574 'searchSinks', 592 'searchSinks',
593 'createMediaRouteController',
594 'setMediaRouteStatusObserver',
575 'onBeforeInvokeHandler' 595 'onBeforeInvokeHandler'
576 ]; 596 ];
577 requiredHandlers.forEach(function(nextHandler) { 597 requiredHandlers.forEach(function(nextHandler) {
578 if (handlers[nextHandler] === undefined) { 598 if (handlers[nextHandler] === undefined) {
579 console.error(nextHandler + ' handler not registered.'); 599 console.error(nextHandler + ' handler not registered.');
580 } 600 }
581 }); 601 });
582 } 602 }
583 603
584 /** 604 /**
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 // to be missing this API. 855 // to be missing this API.
836 if (!this.handlers_.searchSinks) { 856 if (!this.handlers_.searchSinks) {
837 return Promise.resolve({'sink_id': ''}); 857 return Promise.resolve({'sink_id': ''});
838 } 858 }
839 this.handlers_.onBeforeInvokeHandler(); 859 this.handlers_.onBeforeInvokeHandler();
840 return Promise.resolve({ 860 return Promise.resolve({
841 'sink_id': this.handlers_.searchSinks(sinkId, sourceUrn, searchCriteria) 861 'sink_id': this.handlers_.searchSinks(sinkId, sourceUrn, searchCriteria)
842 }); 862 });
843 }; 863 };
844 864
865
866 /**
867 * Creates a controller for the given route and binds the given
868 * InterfaceRequest to it.
869 * @param {string} routeId
870 * @param {!bindings.InterfaceRequest} controllerRequest
871 * @return {!Promise<!{success: boolean}>} Resolves to true if a controller
872 * is created. Resolves to false if a controller cannot be created, or if
873 * the controller is already bound.
874 */
875 MediaRouteProvider.prototype.createMediaRouteController = function(
876 routeId, controllerRequest) {
877 // TODO(imcheng): Remove this check when M59 is in stable.
878 if (!this.handlers_.createMediaRouteController) {
879 return Promise.resolve({success: false});
880 }
881
882 this.handlers_.onBeforeInvokeHandler();
883 this.handlers_.createMediaRouteController(routeId, controllerRequest)
884 .then(controller => {success: true},
885 e => {success: false});
886 }
887
888 /**
889 * Sets the MediaStatus oberver for a given route. MediaStatus updates are
890 * notified via the given observer interface.
891 * @param {string} routeId
892 * @param {!mediaStatusMojom.MediaStatusObserverPtr} observer
893 */
894 MediaRouteProvider.prototype.setMediaRouteStatusObserver = function(
895 routeId, observer) {
896 // TODO(imcheng): Remove this check when M59 is in stable.
897 if (!this.handlers_.setMediaRouteStatusObserver) {
898 return;
899 }
900 this.handlers_.onBeforeInvokeHandler();
901 this.handlers_.setMediaRouteStatusObserver(routeId, observer);
902 };
903
845 mediaRouter = new MediaRouter(new mediaRouterMojom.MediaRouterPtr( 904 mediaRouter = new MediaRouter(new mediaRouterMojom.MediaRouterPtr(
846 frameInterfaces.getInterface(mediaRouterMojom.MediaRouter.name))); 905 frameInterfaces.getInterface(mediaRouterMojom.MediaRouter.name)));
847 906
848 return mediaRouter; 907 return {
908 Binding: bindings.Binding,
909 DialMediaSink: mediaRouterMojom.DialMediaSink,
910 CastMediaSink: mediaRouterMojom.CastMediaSink,
911 IPAddress: ipAddressMojom.IPAddress,
912 InterfacePtrController: bindings.InterfacePtrController,
913 InterfaceRequest: bindings.InterfaceRequest,
914 MediaController: mediaControllerMojom.MediaController,
915 MediaStatus: mediaStatusMojom.MediaStatus,
916 MediaStatusObserverPtr: mediaStatusMojom.MediaStatusObserverPtr,
917 Sink: mediaRouterMojom.MediaSink,
918 SinkExtraData: mediaRouterMojom.MediaSinkExtraData,
919 Url: urlMojom.Url,
920 mediaRouterService: mediaRouter
921 };
849 }); 922 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698