Chromium Code Reviews| Index: remoting/webapp/client_session.js |
| diff --git a/remoting/webapp/client_session.js b/remoting/webapp/client_session.js |
| index 5284e53b66a36799f820b146ac6b5a0b8bda6f32..455abd433bf6143116d26754624c9a61c1a14ffc 100644 |
| --- a/remoting/webapp/client_session.js |
| +++ b/remoting/webapp/client_session.js |
| @@ -228,6 +228,36 @@ remoting.ClientSession.prototype.error_ = |
| remoting.ClientSession.prototype.PLUGIN_ID = 'session-client-plugin'; |
| /** |
| + * Set of capabilities for which hasCapability_() can be used to test. |
| + * |
| + * @enum {string} |
| + */ |
| +remoting.ClientSession.Capability = { |
| + SEND_INITIAL_RESOLUTION: 'sendInitialResolution' |
|
Jamie
2013/04/15 23:40:23
These capabilities should be commented somewhere.
alexeypa (please no reviews)
2013/04/15 23:56:31
Done.
|
| +}; |
| + |
| +/** |
| + * The set of capabilities negotiated between the client and host. |
| + * @type {Array.<string>} |
| + * @private |
| + */ |
| +remoting.ClientSession.prototype.capabilities_ = null; |
| + |
| +/** |
| + * @param {remoting.ClientSession.Capability} capability The capability to test |
| + * for. |
| + * @return {boolean} True if the capability has been negotiated between |
| + * the client and host. |
| + * @private |
| + */ |
| +remoting.ClientSession.prototype.hasCapability_ = function(capability) { |
| + if (this.capabilities_ == null) |
| + return false; |
| + |
| + return this.capabilities_.indexOf(capability) > -1; |
| +}; |
| + |
| +/** |
| * @param {Element} container The element to add the plugin to. |
| * @param {string} id Id to use for the plugin element . |
| * @return {remoting.ClientPlugin} Create plugin object for the locally |
| @@ -369,6 +399,8 @@ remoting.ClientSession.prototype.onPluginInitialized_ = function(initialized) { |
| this.onConnectionReady_.bind(this); |
| this.plugin.onDesktopSizeUpdateHandler = |
| this.onDesktopSizeChanged_.bind(this); |
| + this.plugin.onSetCapabilitiesHandler = |
| + this.onSetCapabilities_.bind(this); |
| this.connectPluginToWcs_(); |
| }; |
| @@ -761,6 +793,30 @@ remoting.ClientSession.prototype.onConnectionReady_ = function(ready) { |
| } |
| /** |
| + * This is a callback that gets called when the plugin report capabilities |
| + * negotiated with the host. |
|
Jamie
2013/04/15 23:40:23
This could be more simply phrased: "Called when th
alexeypa (please no reviews)
2013/04/15 23:56:31
Done.
|
| + * |
| + * @param {!Array.<string>} capabilities The set of capabilities negotiated |
| + * between the client and host. |
| + * @return {void} Nothing. |
| + * @private |
| + */ |
| +remoting.ClientSession.prototype.onSetCapabilities_ = function(capabilities) { |
| + if (this.capabilities_ != null) { |
| + console.error('ERROR: onSetCapabilities_() is called more than once'); |
|
Jamie
2013/04/15 23:40:23
Nit: No need for ERROR--the console shows errors i
alexeypa (please no reviews)
2013/04/15 23:56:31
Done.
|
| + return; |
| + } |
| + |
| + this.capabilities_ = capabilities; |
| + if (this.hasCapability_( |
| + remoting.ClientSession.Capability.SEND_INITIAL_RESOLUTION)) { |
| + this.plugin.notifyClientResolution(window.innerWidth, |
| + window.innerHeight, |
| + window.devicePixelRatio); |
| + } |
| +}; |
| + |
| +/** |
| * @private |
| * @param {remoting.ClientSession.State} newState The new state for the session. |
| * @return {void} Nothing. |