| 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 mediaRouterObserver; | 5 var mediaRouterObserver; |
| 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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 | 272 |
| 273 /** | 273 /** |
| 274 * Object containing callbacks set by the provider manager. | 274 * Object containing callbacks set by the provider manager. |
| 275 * TODO(mfoltz): Better named ProviderManagerDelegate? | 275 * TODO(mfoltz): Better named ProviderManagerDelegate? |
| 276 * | 276 * |
| 277 * @constructor | 277 * @constructor |
| 278 * @struct | 278 * @struct |
| 279 */ | 279 */ |
| 280 function MediaRouterHandlers() { | 280 function MediaRouterHandlers() { |
| 281 /** | 281 /** |
| 282 * @type {function(!string, !string, !string=, !string=, !number=} | 282 * @type {function(!string, !string, !string, !string, !number} |
| 283 */ | 283 */ |
| 284 this.createRoute = null; | 284 this.createRoute = null; |
| 285 | 285 |
| 286 /** | 286 /** |
| 287 * @type {function(!string, !string, !string, !number)} | 287 * @type {function(!string, !string, !string, !number)} |
| 288 */ | 288 */ |
| 289 this.joinRoute = null; | 289 this.joinRoute = null; |
| 290 | 290 |
| 291 /** | 291 /** |
| 292 * @type {function(string)} | 292 * @type {function(string)} |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 * Stops querying for sinks capable of displaying |sourceUrn|. | 382 * Stops querying for sinks capable of displaying |sourceUrn|. |
| 383 * @param {!string} sourceUrn | 383 * @param {!string} sourceUrn |
| 384 */ | 384 */ |
| 385 MediaRouter.prototype.stopObservingMediaSinks = | 385 MediaRouter.prototype.stopObservingMediaSinks = |
| 386 function(sourceUrn) { | 386 function(sourceUrn) { |
| 387 this.handlers_.stopObservingMediaSinks(sourceUrn); | 387 this.handlers_.stopObservingMediaSinks(sourceUrn); |
| 388 }; | 388 }; |
| 389 | 389 |
| 390 /** | 390 /** |
| 391 * Requests that |sinkId| render the media referenced by |sourceUrn|. If the | 391 * Requests that |sinkId| render the media referenced by |sourceUrn|. If the |
| 392 * request is from the Presentation API, then opt_origin and opt_tabId will | 392 * request is from the Presentation API, then origin and tabId will |
| 393 * be populated. | 393 * be populated. |
| 394 * @param {!string} sourceUrn The media source to render. | 394 * @param {!string} sourceUrn Media source to render. |
| 395 * @param {!string} sinkId The media sink ID. | 395 * @param {!string} sinkId Media sink ID. |
| 396 * @param {!string=} opt_presentationId Presentation ID from the site | 396 * @param {!string} presentationId Presentation ID from the site |
| 397 * requesting presentation. TODO(mfoltz): Remove. | 397 * requesting presentation. TODO(mfoltz): Remove. |
| 398 * @param {!string=} opt_origin The origin of the site requesting | 398 * @param {!string} origin Origin of site requesting presentation. |
| 399 * presentation. | 399 * @param {!number} tabId ID of tab requesting presentation. |
| 400 * @param {!number=} opt_tabId ID of the tab that requested presentation. | |
| 401 * @return {!Promise.<!Object>} A Promise resolving to an object describing | 400 * @return {!Promise.<!Object>} A Promise resolving to an object describing |
| 402 * the newly created media route. | 401 * the newly created media route, or rejecting with an error message on |
| 402 * failure. |
| 403 */ | 403 */ |
| 404 MediaRouter.prototype.createRoute = | 404 MediaRouter.prototype.createRoute = |
| 405 function(sourceUrn, sinkId, opt_presentationId, opt_origin, opt_tabId) { | 405 function(sourceUrn, sinkId, presentationId, origin, tabId) { |
| 406 return this.handlers_.createRoute( | 406 return this.handlers_.createRoute( |
| 407 sourceUrn, sinkId, opt_presentationId, opt_origin, opt_tabId) | 407 sourceUrn, sinkId, presentationId, origin, tabId) |
| 408 .then(function(route) { | 408 .then(function(route) { |
| 409 // Sink name is not used, so it is omitted here. | 409 // Sink name is not used, so it is omitted here. |
| 410 return {route: routeToMojo_(route, "")}; | 410 return {route: routeToMojo_(route, "")}; |
| 411 }.bind(this)) | 411 }.bind(this)) |
| 412 .catch(function(err) { | 412 .catch(function(err) { |
| 413 return {error_text: err.message}; | 413 return {error_text: 'Error creating route: ' + err.message}; |
| 414 }); | 414 }); |
| 415 }; | 415 }; |
| 416 | 416 |
| 417 /** | 417 /** |
| 418 * Handles a request via the Presentation API to join an existing route given | 418 * Handles a request via the Presentation API to join an existing route given |
| 419 * by |sourceUrn| and |presentationId|. |origin| and |tabId| are used so the | 419 * by |sourceUrn| and |presentationId|. |origin| and |tabId| are used for |
| 420 * media route provider can limit the scope by origin or tab. | 420 * validating same-origin/tab scope. |
| 421 * @param {!string} sourceUrn The media source to render. | 421 * @param {!string} sourceUrn Media source to render. |
| 422 * @param {!string} presentationId The presentation ID to join. | 422 * @param {!string} presentationId Presentation ID to join. |
| 423 * @param {!string} origin The origin of the site requesting join. | 423 * @param {!string} origin Origin of site requesting join. |
| 424 * @param {!number} tabId The ID of the tab requesting join. | 424 * @param {!number} tabId ID of tab requesting join. |
| 425 * @return {!Promise.<!Object>} Resolved with the route on success, | 425 * @return {!Promise.<!Object>} A Promise resolving to an object describing |
| 426 * or with an error message on failure. | 426 * the newly created media route, or rejecting with an error message on |
| 427 * failure. |
| 427 */ | 428 */ |
| 428 MediaRouter.prototype.joinRoute = | 429 MediaRouter.prototype.joinRoute = |
| 429 function(sourceUrn, presentationId, origin, tabId) { | 430 function(sourceUrn, presentationId, origin, tabId) { |
| 430 return this.handlers_.joinRoute(sourceUrn, presentationId, origin, tabId) | 431 return this.handlers_.joinRoute(sourceUrn, presentationId, origin, tabId) |
| 431 .then(function(newRoute) { | 432 .then(function(newRoute) { |
| 432 return {route: routeToMojo_(newRoute)}; | 433 return {route: routeToMojo_(newRoute)}; |
| 433 }, | 434 }, |
| 434 function(err) { | 435 function(err) { |
| 435 return {error_text: 'Error joining route: ' + err.message}; | 436 return {error_text: 'Error joining route: ' + err.message}; |
| 436 }); | 437 }); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 }; | 479 }; |
| 479 | 480 |
| 480 mediaRouterObserver = new MediaRouterObserver(connector.bindHandleToProxy( | 481 mediaRouterObserver = new MediaRouterObserver(connector.bindHandleToProxy( |
| 481 serviceProvider.connectToService( | 482 serviceProvider.connectToService( |
| 482 mediaRouterMojom.MediaRouterObserver.name), | 483 mediaRouterMojom.MediaRouterObserver.name), |
| 483 mediaRouterMojom.MediaRouterObserver)); | 484 mediaRouterMojom.MediaRouterObserver)); |
| 484 | 485 |
| 485 return mediaRouterObserver; | 486 return mediaRouterObserver; |
| 486 }); | 487 }); |
| 487 | 488 |
| OLD | NEW |