Index: remoting/webapp/crd/js/client_plugin_impl.js |
diff --git a/remoting/webapp/crd/js/client_plugin_impl.js b/remoting/webapp/crd/js/client_plugin_impl.js |
index 3560e7b8df1070e6de590a79716a59e0322e7248..412568c77f7b8dcff688515e486232dd1aa399c1 100644 |
--- a/remoting/webapp/crd/js/client_plugin_impl.js |
+++ b/remoting/webapp/crd/js/client_plugin_impl.js |
@@ -93,9 +93,14 @@ remoting.ClientPluginImpl = function(container, |
window.setTimeout(this.showPluginForClickToPlay_.bind(this), 500); |
} |
+ /** @private */ |
this.hostDesktop_ = new remoting.ClientPlugin.HostDesktopImpl( |
this, this.postMessage_.bind(this)); |
+ /** @private */ |
+ this.extensions_ = new remoting.ProtocolExtensionManager( |
+ this.sendClientMessage.bind(this)); |
+ |
/** @private {remoting.CredentialsProvider} */ |
this.credentials_ = null; |
@@ -226,7 +231,11 @@ remoting.ClientPluginImpl.prototype.handleMessageMethod_ = function(message) { |
var error = remoting.ClientSession.ConnectionError.fromString( |
base.getStringAttr(message.data, 'error')); |
handler.onConnectionStatusUpdate(state, error); |
- |
+ // TODO(kelvinp): Refactor the ClientSession.State into its own file as |
garykac
2015/04/07 22:14:16
Or have an onConnected, onDisconnected,... message
kelvinp
2015/04/08 00:26:02
Even if we break onConnectionStatus into OnConnect
|
+ // the plugin should not depend on ClientSession. |
+ if (state === remoting.ClientSession.State.CONNECTED) { |
+ this.extensions_.start(); |
+ } |
} else if (message.method == 'onRouteChanged') { |
var channel = base.getStringAttr(message.data, 'channel'); |
var connectionType = base.getStringAttr(message.data, 'connectionType'); |
@@ -245,7 +254,7 @@ remoting.ClientPluginImpl.prototype.handleMessageMethod_ = function(message) { |
} else if (message.method == 'extensionMessage') { |
var extMsgType = base.getStringAttr(message.data, 'type'); |
var extMsgData = base.getStringAttr(message.data, 'data'); |
- handler.onExtensionMessage(extMsgType, extMsgData); |
+ this.extensions_.onProtocolExtensionMessage(extMsgType, extMsgData); |
garykac
2015/04/07 22:14:16
Since this no longer requires a connectionEventHan
kelvinp
2015/04/08 00:26:02
Done.
|
} |
} |
@@ -383,6 +392,9 @@ remoting.ClientPluginImpl.prototype.dispose = function() { |
this.plugin_.parentNode.removeChild(this.plugin_); |
this.plugin_ = null; |
} |
+ |
+ base.dispose(this.extensions_); |
+ this.extensions_ = null; |
}; |
/** |
@@ -791,6 +803,10 @@ remoting.ClientPluginImpl.prototype.hostDesktop = function() { |
return this.hostDesktop_; |
}; |
+remoting.ClientPluginImpl.prototype.extensions = function() { |
+ return this.extensions_; |
+}; |
+ |
/** |
* If we haven't yet received a "hello" message from the plugin, change its |
* size so that the user can confirm it if click-to-play is enabled, or can |