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

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

Issue 918783002: CRD Viewport Management refactor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase + plumbing remoting.Host into clientSession Created 5 years, 10 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
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;
};
+
+})();

Powered by Google App Engine
This is Rietveld 408576698