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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 this.localHost = host; | 272 this.localHost = host; |
273 this.setTooltips(); | 273 this.setTooltips(); |
274 /** @type {remoting.HostController} */ | 274 /** @type {remoting.HostController} */ |
275 var that = this; | 275 var that = this; |
276 if (host) { | 276 if (host) { |
277 /** @param {remoting.HostTableEntry} host */ | 277 /** @param {remoting.HostTableEntry} host */ |
278 var renameHost = function(host) { | 278 var renameHost = function(host) { |
279 remoting.hostList.renameHost(host); | 279 remoting.hostList.renameHost(host); |
280 that.setTooltips(); | 280 that.setTooltips(); |
281 }; | 281 }; |
282 /** @type {remoting.HostTableEntry} @private */ | 282 if (!this.hostTableEntry_) { |
283 this.hostTableEntry_ = new remoting.HostTableEntry(); | 283 /** @type {remoting.HostTableEntry} @private */ |
284 this.hostTableEntry_.init(host, | 284 this.hostTableEntry_ = new remoting.HostTableEntry(); |
285 document.getElementById('this-host-connect'), | 285 this.hostTableEntry_.init(host, |
286 document.getElementById('this-host-name'), | 286 document.getElementById('this-host-connect'), |
287 document.getElementById('this-host-rename'), | 287 document.getElementById('this-host-name'), |
288 renameHost); | 288 document.getElementById('this-host-rename'), |
| 289 renameHost); |
| 290 } else { |
| 291 // TODO(jamiewalch): This is hack to prevent multiple click handlers being |
| 292 // registered for the same DOM elements if this method is called more than |
| 293 // once. A better solution would be to let HostTable create the daemon row |
| 294 // like it creates the rows for non-local hosts. |
| 295 this.hostTableEntry_.host = host; |
| 296 } |
289 } else { | 297 } else { |
290 this.hostTableEntry_ = null; | 298 this.hostTableEntry_ = null; |
291 } | 299 } |
292 }; | 300 }; |
293 | 301 |
294 /** | 302 /** |
295 * Update the internal state so that the local host can be correctly filtered | 303 * Update the internal state so that the local host can be correctly filtered |
296 * out of the host list. | 304 * out of the host list. |
297 * | 305 * |
298 * @param {remoting.HostList} hostList The new host list, returned by the | 306 * @param {remoting.HostList} hostList The new host list, returned by the |
299 * Chromoting service. | 307 * Chromoting service. |
300 * @param {function():void} onDone Completion callback. TODO(jamiewalch): For | 308 * @param {function():void} onDone Completion callback. TODO(jamiewalch): For |
301 * now, this is synchronous and reads the host id from local storage. In | 309 * now, this is synchronous and reads the host id from local storage. In |
302 * the future, it will asynchronously read the host id from the plugin | 310 * the future, it will asynchronously read the host id from the plugin |
303 * (crbug.com/121518). | 311 * (crbug.com/121518). |
304 */ | 312 */ |
305 remoting.HostController.prototype.onHostListRefresh = | 313 remoting.HostController.prototype.onHostListRefresh = |
306 function(hostList, onDone) { | 314 function(hostList, onDone) { |
307 var hostId = window.localStorage.getItem('me2me-host-id'); | 315 var hostId = window.localStorage.getItem('me2me-host-id'); |
308 if (hostId && typeof(hostId) == 'string') { | 316 if (hostId && typeof(hostId) == 'string') { |
309 this.setHost(hostList.getHostForId(/** @type{string} */(hostId))); | 317 this.setHost(hostList.getHostForId(/** @type{string} */(hostId))); |
310 } else { | 318 } else { |
311 this.setHost(null); | 319 this.setHost(null); |
312 } | 320 } |
313 onDone(); | 321 onDone(); |
314 }; | 322 }; |
315 | 323 |
316 /** @type {remoting.HostController} */ | 324 /** @type {remoting.HostController} */ |
317 remoting.hostController = null; | 325 remoting.hostController = null; |
OLD | NEW |