| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @fileoverview | 6 * @fileoverview |
| 7 * The deserialized form of the chromoting host as returned by Apiary. | 7 * The deserialized form of the chromoting host as returned by Apiary. |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 'use strict'; | 10 'use strict'; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 return base.Promise.as(remoting.HostSettings.load, [this.hostId_]).then( | 79 return base.Promise.as(remoting.HostSettings.load, [this.hostId_]).then( |
| 80 /** | 80 /** |
| 81 * @param {Object.<string|boolean|number>} options | 81 * @param {Object.<string|boolean|number>} options |
| 82 */ | 82 */ |
| 83 function(options) { | 83 function(options) { |
| 84 // Must be defaulted to true so that app-remoting can resize the host | 84 // Must be defaulted to true so that app-remoting can resize the host |
| 85 // upon launching. | 85 // upon launching. |
| 86 // TODO(kelvinp): Uses a separate host options for app-remoting that | 86 // TODO(kelvinp): Uses a separate host options for app-remoting that |
| 87 // hardcodes resizeToClient to true. | 87 // hardcodes resizeToClient to true. |
| 88 that.resizeToClient = | 88 that.resizeToClient = |
| 89 getBooleanAttr(options, 'resizeToClient', true); | 89 base.getBooleanAttr(options, 'resizeToClient', true); |
| 90 that.shrinkToFit = getBooleanAttr(options, 'shrinkToFit', true); | 90 that.shrinkToFit = base.getBooleanAttr(options, 'shrinkToFit', true); |
| 91 that.desktopScale = getNumberAttr(options, 'desktopScale', 1); | 91 that.desktopScale = base.getNumberAttr(options, 'desktopScale', 1); |
| 92 that.remapKeys = getStringAttr(options, 'remapKeys', ''); | 92 that.remapKeys = base.getStringAttr(options, 'remapKeys', ''); |
| 93 that.pairingInfo = | 93 that.pairingInfo = |
| 94 /** @type {remoting.PairingInfo} */ ( | 94 /** @type {remoting.PairingInfo} */ ( |
| 95 getObjectAttr(options, 'pairingInfo', that.pairingInfo)); | 95 base.getObjectAttr(options, 'pairingInfo', that.pairingInfo)); |
| 96 }); | 96 }); |
| 97 }; | 97 }; |
| 98 | 98 |
| 99 /** | 99 /** |
| 100 * Determine whether a host needs to be manually updated. This is the case if | 100 * Determine whether a host needs to be manually updated. This is the case if |
| 101 * the host's major version number is more than 1 lower than that of the web- | 101 * the host's major version number is more than 1 lower than that of the web- |
| 102 * app (a difference of 1 is tolerated due to the different update mechanisms) | 102 * app (a difference of 1 is tolerated due to the different update mechanisms) |
| 103 * and if the host is on-line (off-line hosts are not expected to auto-update). | 103 * and if the host is on-line (off-line hosts are not expected to auto-update). |
| 104 * | 104 * |
| 105 * @param {remoting.Host} host The host information from the directory. | 105 * @param {remoting.Host} host The host information from the directory. |
| 106 * @param {string|number} webappVersion The version number of the web-app, in | 106 * @param {string|number} webappVersion The version number of the web-app, in |
| 107 * either dotted-decimal notation notation, or directly represented by the | 107 * either dotted-decimal notation notation, or directly represented by the |
| 108 * major version. | 108 * major version. |
| 109 * @return {boolean} True if the host is on-line but out-of-date. | 109 * @return {boolean} True if the host is on-line but out-of-date. |
| 110 */ | 110 */ |
| 111 remoting.Host.needsUpdate = function(host, webappVersion) { | 111 remoting.Host.needsUpdate = function(host, webappVersion) { |
| 112 if (host.status != 'ONLINE') { | 112 if (host.status != 'ONLINE') { |
| 113 return false; | 113 return false; |
| 114 } | 114 } |
| 115 var hostMajorVersion = parseInt(host.hostVersion, 10); | 115 var hostMajorVersion = parseInt(host.hostVersion, 10); |
| 116 if (isNaN(hostMajorVersion)) { | 116 if (isNaN(hostMajorVersion)) { |
| 117 // Host versions 26 and higher include the version number in heartbeats, | 117 // Host versions 26 and higher include the version number in heartbeats, |
| 118 // so if it's missing then the host is at most version 25. | 118 // so if it's missing then the host is at most version 25. |
| 119 hostMajorVersion = 25; | 119 hostMajorVersion = 25; |
| 120 } | 120 } |
| 121 return (parseInt(webappVersion, 10) - hostMajorVersion) > 1; | 121 return (parseInt(webappVersion, 10) - hostMajorVersion) > 1; |
| 122 }; | 122 }; |
| 123 | 123 |
| 124 })(); | 124 })(); |
| OLD | NEW |