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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 | 48 |
49 /** | 49 /** |
50 * @constructor | 50 * @constructor |
51 * @param {string} hostId | 51 * @param {string} hostId |
52 * @struct | 52 * @struct |
53 */ | 53 */ |
54 remoting.Host.Options = function(hostId) { | 54 remoting.Host.Options = function(hostId) { |
55 /** @private */ | 55 /** @private */ |
56 this.hostId_ = hostId; | 56 this.hostId_ = hostId; |
57 /** @type {boolean} */ | 57 /** @type {boolean} */ |
58 this.shrinkToFit = false; | 58 this.shrinkToFit = true; |
59 /** @type {boolean} */ | 59 /** @type {boolean} */ |
60 this.resizeToClient = false; | 60 this.resizeToClient = true; |
61 /** @type {string} */ | 61 /** @type {string} */ |
62 this.remapKeys = ''; | 62 this.remapKeys = ''; |
63 /** @type {number} */ | 63 /** @type {number} */ |
64 this.desktopScale = 1; | 64 this.desktopScale = 1; |
65 }; | 65 }; |
66 | 66 |
67 remoting.Host.Options.prototype.save = function() { | 67 remoting.Host.Options.prototype.save = function() { |
68 // TODO(kelvinp): Migrate pairingInfo to use this class as well and get rid of | 68 // TODO(kelvinp): Migrate pairingInfo to use this class as well and get rid of |
69 // remoting.HostSettings. | 69 // remoting.HostSettings. |
70 remoting.HostSettings.save(this.hostId_, this); | 70 remoting.HostSettings.save(this.hostId_, this); |
71 }; | 71 }; |
72 | 72 |
73 | 73 |
74 /** @return {Promise} A promise that resolves when the settings are loaded. */ | 74 /** @return {Promise} A promise that resolves when the settings are loaded. */ |
75 remoting.Host.Options.prototype.load = function() { | 75 remoting.Host.Options.prototype.load = function() { |
76 var that = this; | 76 var that = this; |
77 return base.Promise.as(remoting.HostSettings.load, [this.hostId_]).then( | 77 return base.Promise.as(remoting.HostSettings.load, [this.hostId_]).then( |
78 /** | 78 /** |
79 * @param {Object.<string|boolean|number>} options | 79 * @param {Object.<string|boolean|number>} options |
80 */ | 80 */ |
81 function(options) { | 81 function(options) { |
| 82 // Must be defaulted to true so that app-remoting can resize the host |
| 83 // upon launching. |
| 84 // TODO(kelvinp): Uses a separate host options for app-remoting that |
| 85 // hardcodes resizeToClient to true. |
82 that.resizeToClient = | 86 that.resizeToClient = |
83 getBooleanAttr(options, 'resizeToClient', false); | 87 getBooleanAttr(options, 'resizeToClient', true); |
84 that.shrinkToFit = getBooleanAttr(options, 'shrinkToFit', false); | 88 that.shrinkToFit = getBooleanAttr(options, 'shrinkToFit', true); |
85 that.desktopScale = getNumberAttr(options, 'desktopScale', 1); | 89 that.desktopScale = getNumberAttr(options, 'desktopScale', 1); |
86 that.remapKeys = getStringAttr(options, 'remapKeys', ''); | 90 that.remapKeys = getStringAttr(options, 'remapKeys', ''); |
87 }); | 91 }); |
88 }; | 92 }; |
89 | 93 |
90 /** | 94 /** |
91 * Determine whether a host needs to be manually updated. This is the case if | 95 * Determine whether a host needs to be manually updated. This is the case if |
92 * the host's major version number is more than 1 lower than that of the web- | 96 * the host's major version number is more than 1 lower than that of the web- |
93 * app (a difference of 1 is tolerated due to the different update mechanisms) | 97 * app (a difference of 1 is tolerated due to the different update mechanisms) |
94 * and if the host is on-line (off-line hosts are not expected to auto-update). | 98 * and if the host is on-line (off-line hosts are not expected to auto-update). |
(...skipping 11 matching lines...) Expand all Loading... |
106 var hostMajorVersion = parseInt(host.hostVersion, 10); | 110 var hostMajorVersion = parseInt(host.hostVersion, 10); |
107 if (isNaN(hostMajorVersion)) { | 111 if (isNaN(hostMajorVersion)) { |
108 // Host versions 26 and higher include the version number in heartbeats, | 112 // Host versions 26 and higher include the version number in heartbeats, |
109 // so if it's missing then the host is at most version 25. | 113 // so if it's missing then the host is at most version 25. |
110 hostMajorVersion = 25; | 114 hostMajorVersion = 25; |
111 } | 115 } |
112 return (parseInt(webappVersion, 10) - hostMajorVersion) > 1; | 116 return (parseInt(webappVersion, 10) - hostMajorVersion) > 1; |
113 }; | 117 }; |
114 | 118 |
115 })(); | 119 })(); |
OLD | NEW |