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

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

Issue 1415103006: Non-Local Join for Media Router and Presentation API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing ChromeOS System Tray Test Created 4 years, 11 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
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 'mojo/public/js/bindings', 8 'mojo/public/js/bindings',
9 'mojo/public/js/core', 9 'mojo/public/js/core',
10 'content/public/renderer/service_provider', 10 'content/public/renderer/service_provider',
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 'secondary_actions': secondaryActions, 273 'secondary_actions': secondaryActions,
274 'help_url': issue.helpUrl, 274 'help_url': issue.helpUrl,
275 'is_blocking': issue.isBlocking 275 'is_blocking': issue.isBlocking
276 })); 276 }));
277 }; 277 };
278 278
279 /** 279 /**
280 * Called by the provider manager when the set of active routes 280 * Called by the provider manager when the set of active routes
281 * has been updated. 281 * has been updated.
282 * @param {!Array<MediaRoute>} routes The active set of media routes. 282 * @param {!Array<MediaRoute>} routes The active set of media routes.
283 * @param {string=} opt_sourceUrn The sourceUrn associated with this route
284 * query. This parameter is optional and can be empty.
285 * @param {Array<string>=} opt_joinableRouteIds The active set of joinable
286 * media routes. This parameter is optional and can be empty.
283 */ 287 */
284 MediaRouter.prototype.onRoutesUpdated = function(routes) { 288 MediaRouter.prototype.onRoutesUpdated =
285 this.service_.onRoutesUpdated(routes.map(routeToMojo_)); 289 function(routes, opt_sourceUrn, opt_joinableRouteIds) {
290 // TODO(boetger): This check allows backward compatibility with the Cast SDK
291 // and can be removed when the Cast SDK is updated.
292 if (typeof(opt_sourceUrn) != 'string') {
293 opt_sourceUrn = '';
294 }
295
296 this.service_.onRoutesUpdated(
297 routes.map(routeToMojo_),
298 opt_sourceUrn || '',
299 opt_joinableRouteIds || []);
286 }; 300 };
287 301
288 /** 302 /**
289 * Called by the provider manager when sink availability has been updated. 303 * Called by the provider manager when sink availability has been updated.
290 * @param {!mediaRouterMojom.MediaRouter.SinkAvailability} availability 304 * @param {!mediaRouterMojom.MediaRouter.SinkAvailability} availability
291 * The new sink availability. 305 * The new sink availability.
292 */ 306 */
293 MediaRouter.prototype.onSinkAvailabilityUpdated = function(availability) { 307 MediaRouter.prototype.onSinkAvailabilityUpdated = function(availability) {
294 this.service_.onSinkAvailabilityUpdated(availability); 308 this.service_.onSinkAvailabilityUpdated(availability);
295 }; 309 };
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 380
367 /** 381 /**
368 * @type {function()} 382 * @type {function()}
369 */ 383 */
370 this.startObservingMediaRoutes = null; 384 this.startObservingMediaRoutes = null;
371 385
372 /** 386 /**
373 * @type {function()} 387 * @type {function()}
374 */ 388 */
375 this.stopObservingMediaRoutes = null; 389 this.stopObservingMediaRoutes = null;
390
391 /**
392 * @type {function()}
393 */
394 this.connectRouteByRouteId = null;
376 }; 395 };
377 396
378 /** 397 /**
379 * Routes calls from Media Router to the provider manager extension. 398 * Routes calls from Media Router to the provider manager extension.
380 * Registered with the MediaRouter stub. 399 * Registered with the MediaRouter stub.
381 * @param {!MediaRouter} MediaRouter proxy to call into the 400 * @param {!MediaRouter} MediaRouter proxy to call into the
382 * Media Router mojo interface. 401 * Media Router mojo interface.
383 * @constructor 402 * @constructor
384 */ 403 */
385 function MediaRouteProvider(mediaRouter) { 404 function MediaRouteProvider(mediaRouter) {
(...skipping 26 matching lines...) Expand all
412 'startObservingMediaRoutes', 431 'startObservingMediaRoutes',
413 'sendRouteMessage', 432 'sendRouteMessage',
414 'sendRouteBinaryMessage', 433 'sendRouteBinaryMessage',
415 'listenForRouteMessages', 434 'listenForRouteMessages',
416 'stopListeningForRouteMessages', 435 'stopListeningForRouteMessages',
417 'detachRoute', 436 'detachRoute',
418 'terminateRoute', 437 'terminateRoute',
419 'joinRoute', 438 'joinRoute',
420 'createRoute', 439 'createRoute',
421 'stopObservingMediaSinks', 440 'stopObservingMediaSinks',
422 'startObservingMediaRoutes' 441 'startObservingMediaRoutes',
442 'connectRouteByRouteId'
423 ]; 443 ];
424 requiredHandlers.forEach(function(nextHandler) { 444 requiredHandlers.forEach(function(nextHandler) {
425 if (handlers[nextHandler] === undefined) { 445 if (handlers[nextHandler] === undefined) {
426 console.error(nextHandler + ' handler not registered.'); 446 console.error(nextHandler + ' handler not registered.');
427 } 447 }
428 }); 448 });
429 } 449 }
430 450
431 /** 451 /**
432 * Starts querying for sinks capable of displaying the media source 452 * Starts querying for sinks capable of displaying the media source
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 return this.handlers_.joinRoute(sourceUrn, presentationId, origin, tabId) 511 return this.handlers_.joinRoute(sourceUrn, presentationId, origin, tabId)
492 .then(function(newRoute) { 512 .then(function(newRoute) {
493 return {route: routeToMojo_(newRoute)}; 513 return {route: routeToMojo_(newRoute)};
494 }, 514 },
495 function(err) { 515 function(err) {
496 return {error_text: 'Error joining route: ' + err.message}; 516 return {error_text: 'Error joining route: ' + err.message};
497 }); 517 });
498 }; 518 };
499 519
500 /** 520 /**
521 * Handles a request via the Presentation API to join an existing route given
522 * by |sourceUrn| and |routeId|. |origin| and |tabId| are used for
523 * validating same-origin/tab scope.
524 * @param {!string} sourceUrn Media source to render.
525 * @param {!string} routeId Route ID to join.
526 * @param {!string} presentationId Presentation ID to join.
527 * @param {!string} origin Origin of site requesting join.
528 * @param {!number} tabId ID of tab requesting join.
529 * @return {!Promise.<!Object>} A Promise resolving to an object describing
530 * the newly created media route, or rejecting with an error message on
531 * failure.
532 */
533 MediaRouteProvider.prototype.connectRouteByRouteId =
534 function(sourceUrn, routeId, presentationId, origin, tabId) {
535 return this.handlers_.connectRouteByRouteId(
536 sourceUrn, routeId, presentationId, origin, tabId)
537 .then(function(newRoute) {
538 return {route: routeToMojo_(newRoute)};
539 },
540 function(err) {
541 return {error_text: 'Error joining route: ' + err.message};
542 });
543 };
544
545 /**
501 * Terminates the route specified by |routeId|. 546 * Terminates the route specified by |routeId|.
502 * @param {!string} routeId 547 * @param {!string} routeId
503 */ 548 */
504 MediaRouteProvider.prototype.terminateRoute = function(routeId) { 549 MediaRouteProvider.prototype.terminateRoute = function(routeId) {
505 this.handlers_.terminateRoute(routeId); 550 this.handlers_.terminateRoute(routeId);
506 }; 551 };
507 552
508 /** 553 /**
509 * Posts a message to the route designated by |routeId|. 554 * Posts a message to the route designated by |routeId|.
510 * @param {!string} routeId 555 * @param {!string} routeId
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 * @param {!string} routeId 616 * @param {!string} routeId
572 */ 617 */
573 MediaRouteProvider.prototype.detachRoute = function( 618 MediaRouteProvider.prototype.detachRoute = function(
574 routeId) { 619 routeId) {
575 this.handlers_.detachRoute(routeId); 620 this.handlers_.detachRoute(routeId);
576 }; 621 };
577 622
578 /** 623 /**
579 * Requests that the provider manager start sending information about active 624 * Requests that the provider manager start sending information about active
580 * media routes to the Media Router. 625 * media routes to the Media Router.
626 * @param {!string} sourceUrn
581 */ 627 */
582 MediaRouteProvider.prototype.startObservingMediaRoutes = function() { 628 MediaRouteProvider.prototype.startObservingMediaRoutes = function(sourceUrn) {
583 this.handlers_.startObservingMediaRoutes(); 629 this.handlers_.startObservingMediaRoutes(sourceUrn);
584 }; 630 };
585 631
586 /** 632 /**
587 * Requests that the provider manager stop sending information about active 633 * Requests that the provider manager stop sending information about active
588 * media routes to the Media Router. 634 * media routes to the Media Router.
635 * @param {!string} sourceUrn
589 */ 636 */
590 MediaRouteProvider.prototype.stopObservingMediaRoutes = function() { 637 MediaRouteProvider.prototype.stopObservingMediaRoutes = function(sourceUrn) {
591 this.handlers_.stopObservingMediaRoutes(); 638 this.handlers_.stopObservingMediaRoutes(sourceUrn);
592 }; 639 };
593 640
594 mediaRouter = new MediaRouter(connector.bindHandleToProxy( 641 mediaRouter = new MediaRouter(connector.bindHandleToProxy(
595 serviceProvider.connectToService( 642 serviceProvider.connectToService(
596 mediaRouterMojom.MediaRouter.name), 643 mediaRouterMojom.MediaRouter.name),
597 mediaRouterMojom.MediaRouter)); 644 mediaRouterMojom.MediaRouter));
598 645
599 return mediaRouter; 646 return mediaRouter;
600 }); 647 });
601 648
OLDNEW
« no previous file with comments | « chrome/test/data/webui/media_router/route_details_tests.js ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698