Chromium Code Reviews| 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 'use strict'; | 5 'use strict'; |
| 6 | 6 |
| 7 /** @suppress {duplicate} */ | 7 /** @suppress {duplicate} */ |
| 8 var remoting = remoting || {}; | 8 var remoting = remoting || {}; |
| 9 | 9 |
| 10 /** @constructor */ | 10 /** @constructor */ |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 73 this.plugin_.getUsageStatsConsent(callback); | 73 this.plugin_.getUsageStatsConsent(callback); |
| 74 }; | 74 }; |
| 75 | 75 |
| 76 /** | 76 /** |
| 77 * Show or hide daemon-specific parts of the UI. | 77 * Show or hide daemon-specific parts of the UI. |
| 78 * @return {void} Nothing. | 78 * @return {void} Nothing. |
| 79 */ | 79 */ |
| 80 remoting.HostController.prototype.updateDom = function() { | 80 remoting.HostController.prototype.updateDom = function() { |
| 81 var match = ''; | 81 var match = ''; |
| 82 var state = this.state(); | 82 var state = this.state(); |
| 83 switch (state) { | 83 var enabled = (state == remoting.HostController.State.STARTED); |
| 84 case remoting.HostController.State.STARTED: | 84 var supported = (state != remoting.HostController.State.NOT_IMPLEMENTED); |
| 85 remoting.updateModalUi('enabled', 'data-daemon-state'); | 85 remoting.updateModalUi(enabled ? 'enabled' : 'disabled', 'data-daemon-state'); |
| 86 break; | 86 document.getElementById('daemon-control').hidden = !supported; |
| 87 case remoting.HostController.State.NOT_IMPLEMENTED: | 87 document.getElementById('host-list-empty-instructions').hidden = supported; |
| 88 document.getElementById('start-daemon').disabled = true; | |
| 89 document.getElementById('start-daemon-message').innerText = | |
| 90 chrome.i18n.getMessage( | |
| 91 /*i18n-content*/'HOME_DAEMON_DISABLED_MESSAGE'); | |
| 92 // No break; | |
| 93 case remoting.HostController.State.STOPPED: | |
| 94 case remoting.HostController.State.NOT_INSTALLED: | |
| 95 remoting.updateModalUi('disabled', 'data-daemon-state'); | |
| 96 break; | |
| 97 } | |
| 98 }; | 88 }; |
| 99 | 89 |
| 100 /** | 90 /** |
| 101 * Set tool-tips for the 'connect' action. We can't just set this on the | 91 * Set tool-tips for the 'connect' action. We can't just set this on the |
| 102 * parent element because the button has no tool-tip, and therefore would | 92 * parent element because the button has no tool-tip, and therefore would |
| 103 * inherit connectStr. | 93 * inherit connectStr. |
| 104 * | 94 * |
| 105 * return {void} Nothing. | 95 * return {void} Nothing. |
| 106 */ | 96 */ |
| 107 remoting.HostController.prototype.setTooltips = function() { | 97 remoting.HostController.prototype.setTooltips = function() { |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 267 * @param {string} configStr The host configuration, JSON encoded to a string. | 257 * @param {string} configStr The host configuration, JSON encoded to a string. |
| 268 * @return {Object.<string,string>|null} The host configuration. | 258 * @return {Object.<string,string>|null} The host configuration. |
| 269 */ | 259 */ |
| 270 function parseHostConfig_(configStr) { | 260 function parseHostConfig_(configStr) { |
| 271 var config = /** @type {Object.<string,string>} */ jsonParseSafe(configStr); | 261 var config = /** @type {Object.<string,string>} */ jsonParseSafe(configStr); |
| 272 if (config && | 262 if (config && |
| 273 typeof config['host_id'] == 'string' && | 263 typeof config['host_id'] == 'string' && |
| 274 typeof config['xmpp_login'] == 'string') { | 264 typeof config['xmpp_login'] == 'string') { |
| 275 return config; | 265 return config; |
| 276 } else { | 266 } else { |
| 277 if (configStr != '{}') { | 267 if (configStr != '{}') { |
|
Wez
2012/06/29 21:40:51
Under what circumstances do we see empty host conf
Jamie
2012/06/29 21:56:27
If there's no host registered you get this.
| |
| 278 console.error('Invalid getDaemonConfig response.'); | 268 console.error('Invalid getDaemonConfig response.'); |
| 279 } | 269 } |
| 280 } | 270 } |
| 281 return null; | 271 return null; |
| 282 } | 272 } |
| 283 | 273 |
| 284 /** | 274 /** |
| 285 * @param {string} newPin The new PIN to set | 275 * @param {string} newPin The new PIN to set |
| 286 * @param {function(remoting.HostController.AsyncResult):void} callback | 276 * @param {function(remoting.HostController.AsyncResult):void} callback |
| 287 * Callback to be called when finished. | 277 * Callback to be called when finished. |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 374 try { | 364 try { |
| 375 this.plugin_.getDaemonConfig(onConfig); | 365 this.plugin_.getDaemonConfig(onConfig); |
| 376 } catch (err) { | 366 } catch (err) { |
| 377 this.setHost(null); | 367 this.setHost(null); |
| 378 onDone(); | 368 onDone(); |
| 379 } | 369 } |
| 380 }; | 370 }; |
| 381 | 371 |
| 382 /** @type {remoting.HostController} */ | 372 /** @type {remoting.HostController} */ |
| 383 remoting.hostController = null; | 373 remoting.hostController = null; |
| OLD | NEW |