Index: remoting/webapp/crd/js/host.js |
diff --git a/remoting/webapp/crd/js/host.js b/remoting/webapp/crd/js/host.js |
index 15014c7d4b98780476e58999847d081014add72d..96733aa5761f43a4751e70453999fa069e0177b2 100644 |
--- a/remoting/webapp/crd/js/host.js |
+++ b/remoting/webapp/crd/js/host.js |
@@ -7,14 +7,17 @@ |
* The deserialized form of the chromoting host as returned by Apiary. |
*/ |
-'use strict'; |
- |
-/** @suppress {duplicate} */ |
var remoting = remoting || {}; |
+(function() { |
+ |
+'use strict'; |
+ |
/** |
* Note that the object has more fields than are detailed below--these |
* are just the ones that we refer to directly. |
+ * |
+ * TODO(kelvinp):Make fields private and expose them via getters. |
Jamie
2015/02/18 00:33:10
This is basically a struct; I don't think there's
|
* @constructor |
*/ |
remoting.Host = function() { |
@@ -36,6 +39,59 @@ remoting.Host = function() { |
this.updatedTime = ''; |
/** @type {string} */ |
this.hostOfflineReason = ''; |
+ /** @type {remoting.Host.Options} */ |
Jamie
2015/02/18 00:33:10
Either make this private, or remove the getter. Si
|
+ this.options_ = new remoting.Host.Options(this.hostId); |
+}; |
+ |
+/** @return {remoting.Host.Options} */ |
+remoting.Host.prototype.options = function() { |
+ return this.options_; |
+}; |
+ |
+/** |
+ * @constructor |
+ * @param {string} hostId |
+ * @struct |
+ */ |
+remoting.Host.Options = function(hostId) { |
+ /** @private */ |
+ this.hostId_ = hostId; |
+ /** @private */ |
+ this.isInitialized_ = false; |
+ /** @type {boolean} */ |
+ this.shrinkToFit = false; |
+ /** @type {boolean} */ |
+ this.resizeToClient = false; |
+ /** @type {string} */ |
+ this.remapKeys = ''; |
+ /** @type {number} */ |
+ this.desktopScale = 1; |
+}; |
+ |
+remoting.Host.Options.prototype.save = function() { |
+ base.debug.assert(this.isInitialized_); |
+ remoting.HostSettings.save(this.hostId_, this); |
+}; |
+ |
+ |
+/** @return {Promise} A promise that resolves when the settings are loaded. */ |
+remoting.Host.Options.prototype.load = function() { |
+ var that = this; |
+ if (this.isInitialized_) { |
+ return Promise.resolve(); |
+ } |
+ return base.Promise.as(remoting.HostSettings.load, [this.hostId_]).then( |
+ /** |
+ * @param {Object.<string|boolean|number>} options |
+ */ |
+ function(options) { |
+ that.isInitialized_ = true; |
+ that.resizeToClient = |
+ getBooleanAttr(options, 'resizeToClient', false); |
+ that.shrinkToFit = getBooleanAttr(options, 'shrinkToFit', false); |
+ that.desktopScale = getNumberAttr(options, 'desktopScale', 1); |
+ that.remapKeys = getStringAttr(options, 'remapKeys', ''); |
+ }); |
}; |
/** |
@@ -62,3 +118,5 @@ remoting.Host.needsUpdate = function(host, webappVersion) { |
} |
return (parseInt(webappVersion, 10) - hostMajorVersion) > 1; |
}; |
+ |
+})(); |