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

Side by Side Diff: remoting/webapp/crd/js/host.js

Issue 1133913002: [Chromoting] Move shared webapp JS files from crd/js -> base/js (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 unified diff | Download patch
« no previous file with comments | « remoting/webapp/crd/js/format_iq.js ('k') | remoting/webapp/crd/js/host_desktop.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 /**
6 * @fileoverview
7 * The deserialized form of the chromoting host as returned by Apiary.
8 */
9
10 'use strict';
11
12 /** @suppress {duplicate} */
13 var remoting = remoting || {};
14
15 (function() {
16
17 'use strict';
18
19 /**
20 * @param {!string} hostId
21 *
22 * TODO(kelvinp):Make fields private and expose them via getters.
23 * @constructor
24 */
25 remoting.Host = function(hostId) {
26 /** @const {string} */
27 this.hostId = hostId;
28 /** @type {string} */
29 this.hostName = '';
30 /** @type {string} */
31 this.status = '';
32 /** @type {string} */
33 this.jabberId = '';
34 /** @type {string} */
35 this.publicKey = '';
36 /** @type {string} */
37 this.hostVersion = '';
38 /** @type {Array<string>} */
39 this.tokenUrlPatterns = [];
40 /** @type {string} */
41 this.updatedTime = '';
42 /** @type {string} */
43 this.hostOfflineReason = '';
44 /** @type {remoting.Host.Options} */
45 this.options = new remoting.Host.Options(hostId);
46 };
47
48 /**
49 * @constructor
50 * @param {!string} hostId
51 * @struct
52 */
53 remoting.Host.Options = function(hostId) {
54 /** @private @const */
55 this.hostId_ = hostId;
56 /** @type {boolean} */
57 this.shrinkToFit = true;
58 /** @type {boolean} */
59 this.resizeToClient = true;
60 /** @type {string} */
61 this.remapKeys = '';
62 /** @type {number} */
63 this.desktopScale = 1;
64 /** @type {remoting.PairingInfo} */
65 this.pairingInfo = {clientId: '', sharedSecret: ''};
66 };
67
68 remoting.Host.Options.prototype.save = function() {
69 // TODO(kelvinp): Migrate pairingInfo to use this class as well and get rid of
70 // remoting.HostSettings.
71 remoting.HostSettings.save(this.hostId_, this);
72 };
73
74
75 /** @return {Promise} A promise that resolves when the settings are loaded. */
76 remoting.Host.Options.prototype.load = function() {
77 var that = this;
78 return base.Promise.as(remoting.HostSettings.load, [this.hostId_]).then(
79 /**
80 * @param {Object.<string|boolean|number>} options
81 */
82 function(options) {
83 // Must be defaulted to true so that app-remoting can resize the host
84 // upon launching.
85 // TODO(kelvinp): Uses a separate host options for app-remoting that
86 // hardcodes resizeToClient to true.
87 that.resizeToClient =
88 base.getBooleanAttr(options, 'resizeToClient', true);
89 that.shrinkToFit = base.getBooleanAttr(options, 'shrinkToFit', true);
90 that.desktopScale = base.getNumberAttr(options, 'desktopScale', 1);
91 that.remapKeys = base.getStringAttr(options, 'remapKeys', '');
92 that.pairingInfo =
93 /** @type {remoting.PairingInfo} */ (
94 base.getObjectAttr(options, 'pairingInfo', that.pairingInfo));
95 });
96 };
97
98 /**
99 * Determine whether a host needs to be manually updated. This is the case if
100 * the host's major version number is more than 1 lower than that of the web-
101 * app (a difference of 1 is tolerated due to the different update mechanisms)
102 * and if the host is on-line (off-line hosts are not expected to auto-update).
103 *
104 * @param {remoting.Host} host The host information from the directory.
105 * @param {string|number} webappVersion The version number of the web-app, in
106 * either dotted-decimal notation notation, or directly represented by the
107 * major version.
108 * @return {boolean} True if the host is on-line but out-of-date.
109 */
110 remoting.Host.needsUpdate = function(host, webappVersion) {
111 if (host.status != 'ONLINE') {
112 return false;
113 }
114 var hostMajorVersion = parseInt(host.hostVersion, 10);
115 if (isNaN(hostMajorVersion)) {
116 // Host versions 26 and higher include the version number in heartbeats,
117 // so if it's missing then the host is at most version 25.
118 hostMajorVersion = 25;
119 }
120 return (parseInt(webappVersion, 10) - hostMajorVersion) > 1;
121 };
122
123 })();
OLDNEW
« no previous file with comments | « remoting/webapp/crd/js/format_iq.js ('k') | remoting/webapp/crd/js/host_desktop.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698