| Index: extensions/renderer/resources/media_router_bindings.js
|
| diff --git a/extensions/renderer/resources/media_router_bindings.js b/extensions/renderer/resources/media_router_bindings.js
|
| index a54fb9843830df8a02bfd309ef2b7e614968677c..c5c7286806473459add9348f52093657c435841b 100644
|
| --- a/extensions/renderer/resources/media_router_bindings.js
|
| +++ b/extensions/renderer/resources/media_router_bindings.js
|
| @@ -8,6 +8,7 @@ define('media_router_bindings', [
|
| 'mojo/public/js/bindings',
|
| 'mojo/public/js/core',
|
| 'content/public/renderer/frame_service_registry',
|
| + 'chrome/browser/media/router/mojo/media_remoter.mojom',
|
| 'chrome/browser/media/router/mojo/media_router.mojom',
|
| 'extensions/common/mojo/keep_alive.mojom',
|
| 'mojo/public/js/connection',
|
| @@ -15,6 +16,7 @@ define('media_router_bindings', [
|
| ], function(bindings,
|
| core,
|
| serviceProvider,
|
| + mediaRemoterMojom,
|
| mediaRouterMojom,
|
| keepAliveMojom,
|
| connector,
|
| @@ -421,6 +423,26 @@ define('media_router_bindings', [
|
| };
|
|
|
| /**
|
| + * Creates a MediaRemotingSession that manages content remoting from the given
|
| + * media source. Only one session can be created for the same source; and an
|
| + * attempt to create a second before MediaRemotingSession.Terminate() is
|
| + * called will cause a null handle to be returned.
|
| + * @param {!string} sourceUrn
|
| + * @param {!MediaRemotingProvider} provider
|
| + * @return {!Promise<MediaRemotingSession>} A proxy interface to the remote
|
| + * MediaRemotingSession. On failure, the proxy is not bound.
|
| + */
|
| + MediaRouter.prototype.createRemotingSession =
|
| + function(sourceUrn, provider) {
|
| + return this.service_.createRemotingSession(sourceUrn, provider).then(
|
| + function(result) {
|
| + return connector.bindHandleToProxy(
|
| + result.remoting_session,
|
| + mediaRemoterMojom.MediaRemotingSession);
|
| + });
|
| + };
|
| +
|
| + /**
|
| * Object containing callbacks set by the provider manager.
|
| *
|
| * @constructor
|
| @@ -842,6 +864,69 @@ define('media_router_bindings', [
|
| });
|
| };
|
|
|
| + /**
|
| + * Routes calls from the MediaRemotingSession in the browser process to the
|
| + * provider manager extension.
|
| + * @param {!object} Delegate that provides the MediaRemotingProvider
|
| + * implementation, which itself contains state relative to a specific
|
| + * MediaRemotingSession.
|
| + * @constructor
|
| + */
|
| + function MediaRemotingProvider(delegate) {
|
| + mediaRemoterMojom.MediaRemotingProvider.stubClass.call(this);
|
| +
|
| + this.delegate_ = delegate;
|
| + const requiredMethods = [
|
| + 'startMediaServices',
|
| + 'stopMediaServices',
|
| + 'sendMessageToRemote',
|
| + 'onSessionTerminated',
|
| + ];
|
| + requiredMethods.forEach(function(name) {
|
| + if (!delegate || !(delegate[name] instanceof Function)) {
|
| + console.error(name + ' method not implemented.');
|
| + }
|
| + });
|
| + };
|
| + MediaRemotingProvider.prototype = Object.create(
|
| + mediaRemoterMojom.MediaRemotingProvider.stubClass.prototype);
|
| +
|
| + /**
|
| + * Notifies the provider that remote media services have started.
|
| + */
|
| + MediaRemotingProvider.prototype.startMediaServices() {
|
| + this.delegate_.startMediaServices();
|
| + }
|
| +
|
| + /**
|
| + * Notifies the provider that remote media services have stopped.
|
| + * @param{?string=} errorReason If specified, a human-readable string
|
| + * indicating remoting was stopped due to an error; otherwise, it is stopping
|
| + * normally.
|
| + */
|
| + MediaRemotingProvider.prototype.stopMediaServices(errorReason) {
|
| + this.delegate_.stopMediaServices(errorReason);
|
| + }
|
| +
|
| + /**
|
| + * Forwards a message, via the provider, to the remote's media services.
|
| + * @param{!Object} message An array of byte values (can be any type of object
|
| + * that supports array-like operations, such as: string, Array, TypedArray).
|
| + */
|
| + MediaRemotingProvider.prototype.sendMessageToRemote(message) {
|
| + this.delegate_.sendMessageToRemote(message);
|
| + }
|
| +
|
| + /**
|
| + * Notifies the provider that the MediaRemotingSession has been terminated.
|
| + * @param{?string=} errorReason If specified, a human-readable string
|
| + * indicating that the session was terminated due to an error; otherwise, it
|
| + * is terminating normally.
|
| + */
|
| + MediaRemotingProvider.prototype.onSessionTerminated(errorReason) {
|
| + this.delegate_.onSessionTerminated(errorReason);
|
| + }
|
| +
|
| mediaRouter = new MediaRouter(connector.bindHandleToProxy(
|
| serviceProvider.connectToService(
|
| mediaRouterMojom.MediaRouter.name),
|
| @@ -849,4 +934,3 @@ define('media_router_bindings', [
|
|
|
| return mediaRouter;
|
| });
|
| -
|
|
|