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

Unified Diff: remoting/webapp/crd/js/client_plugin_impl.js

Issue 1067133002: Move ProtocolExtensionManager from SessionConnector into its own class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and Reviewer's feedback Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/webapp/crd/js/client_plugin.js ('k') | remoting/webapp/crd/js/client_session.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..c3808b4bd98d49e6853a1279ac0e467f65115e82 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
+ // 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');
@@ -242,10 +251,6 @@ remoting.ClientPluginImpl.prototype.handleMessageMethod_ = function(message) {
base.getStringAttr(message.data, 'capabilities'));
handler.onSetCapabilities(capabilities);
- } else if (message.method == 'extensionMessage') {
- var extMsgType = base.getStringAttr(message.data, 'type');
- var extMsgData = base.getStringAttr(message.data, 'data');
- handler.onExtensionMessage(extMsgType, extMsgData);
}
}
@@ -372,6 +377,11 @@ remoting.ClientPluginImpl.prototype.handleMessageMethod_ = function(message) {
this.debugRegionHandler_(
/** @type {{rects: Array<(Array<number>)>}} **/(message.data));
}
+ } else if (message.method == 'extensionMessage') {
+ var extMsgType = base.getStringAttr(message.data, 'type');
+ var extMsgData = base.getStringAttr(message.data, 'data');
+ this.extensions_.onProtocolExtensionMessage(extMsgType, extMsgData);
+
}
};
@@ -383,6 +393,9 @@ remoting.ClientPluginImpl.prototype.dispose = function() {
this.plugin_.parentNode.removeChild(this.plugin_);
this.plugin_ = null;
}
+
+ base.dispose(this.extensions_);
+ this.extensions_ = null;
};
/**
@@ -791,6 +804,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
« no previous file with comments | « remoting/webapp/crd/js/client_plugin.js ('k') | remoting/webapp/crd/js/client_session.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698