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 * Class representing the host-list portion of the home screen UI. | 7 * Class representing the host-list portion of the home screen UI. |
8 */ | 8 */ |
9 | 9 |
10 'use strict'; | 10 'use strict'; |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
282 var canChangeLocalHostState = | 282 var canChangeLocalHostState = |
283 (state != remoting.HostController.State.NOT_IMPLEMENTED) && | 283 (state != remoting.HostController.State.NOT_IMPLEMENTED) && |
284 (state != remoting.HostController.State.UNKNOWN) && | 284 (state != remoting.HostController.State.UNKNOWN) && |
285 (state != remoting.HostController.State.NOT_INSTALLED || | 285 (state != remoting.HostController.State.NOT_INSTALLED || |
286 remoting.isMe2MeInstallable()) && | 286 remoting.isMe2MeInstallable()) && |
287 (enabled || this.lastError_ == ''); | 287 (enabled || this.lastError_ == ''); |
288 | 288 |
289 remoting.updateModalUi(enabled ? 'enabled' : 'disabled', 'data-daemon-state'); | 289 remoting.updateModalUi(enabled ? 'enabled' : 'disabled', 'data-daemon-state'); |
290 var element = document.getElementById('daemon-control'); | 290 var element = document.getElementById('daemon-control'); |
291 element.hidden = !canChangeLocalHostState; | 291 element.hidden = !canChangeLocalHostState; |
292 element = document.getElementById('host-list-empty-hosting-supported'); | 292 |
293 element.hidden = !canChangeLocalHostState; | 293 if (noHostsRegistered) { |
294 element = document.getElementById('host-list-empty-hosting-unsupported'); | 294 this.showHostListEmptyMessage_(canChangeLocalHostState); |
295 element.hidden = canChangeLocalHostState; | 295 } |
296 }; | 296 }; |
297 | 297 |
298 /** | 298 /** |
299 * Displays a message to the user when the host list is empty. | |
300 * | |
301 * @param {boolean} hostingSupported | |
302 * @return {void} | |
303 * @private | |
304 */ | |
305 remoting.HostList.prototype.showHostListEmptyMessage_ = function( | |
306 hostingSupported) { | |
307 var that = this; | |
308 remoting.AppsV2Migration.hasHostsInV1App().then( | |
309 /** | |
310 * @param {{ email: string, fullName: string}} previousIdentity | |
Jamie
2015/01/20 22:32:01
Nit: No space before "email". Or it might be clean
kelvinp
2015/01/21 21:16:21
Done.
| |
311 * @this {remoting.HostList} | |
312 */ | |
313 function(previousIdentity) { | |
314 that.noHosts_.innerHTML = remoting.AppsV2Migration.buildMigrationTips( | |
315 previousIdentity.email, previousIdentity.fullName); | |
316 }, | |
317 function() { | |
318 var buttonLabel = l10n.getTranslationOrError( | |
319 /*i18n-content*/'HOME_DAEMON_START_BUTTON'); | |
320 if (hostingSupported) { | |
321 that.noHosts_.innerText = l10n.getTranslationOrError( | |
322 /*i18n-content*/'HOST_LIST_EMPTY_HOSTING_SUPPORTED', | |
323 [buttonLabel]); | |
324 } else { | |
325 that.noHosts_.innerText = l10n.getTranslationOrError( | |
326 /*i18n-content*/'HOST_LIST_EMPTY_HOSTING_UNSUPPORTED', | |
327 [buttonLabel]); | |
328 } | |
329 } | |
330 ); | |
331 }; | |
332 | |
333 /** | |
299 * Remove a host from the list, and deregister it. | 334 * Remove a host from the list, and deregister it. |
300 * @param {remoting.HostTableEntry} hostTableEntry The host to be removed. | 335 * @param {remoting.HostTableEntry} hostTableEntry The host to be removed. |
301 * @return {void} Nothing. | 336 * @return {void} Nothing. |
302 * @private | 337 * @private |
303 */ | 338 */ |
304 remoting.HostList.prototype.deleteHost_ = function(hostTableEntry) { | 339 remoting.HostList.prototype.deleteHost_ = function(hostTableEntry) { |
305 this.table_.removeChild(hostTableEntry.tableRow); | 340 this.table_.removeChild(hostTableEntry.tableRow); |
306 var index = this.hostTableEntries_.indexOf(hostTableEntry); | 341 var index = this.hostTableEntries_.indexOf(hostTableEntry); |
307 if (index != -1) { | 342 if (index != -1) { |
308 this.hostTableEntries_.splice(index, 1); | 343 this.hostTableEntries_.splice(index, 1); |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
455 } | 490 } |
456 }; | 491 }; |
457 | 492 |
458 /** | 493 /** |
459 * Save the host list to local storage. | 494 * Save the host list to local storage. |
460 */ | 495 */ |
461 remoting.HostList.prototype.save_ = function() { | 496 remoting.HostList.prototype.save_ = function() { |
462 var items = {}; | 497 var items = {}; |
463 items[remoting.HostList.HOSTS_KEY] = JSON.stringify(this.hosts_); | 498 items[remoting.HostList.HOSTS_KEY] = JSON.stringify(this.hosts_); |
464 chrome.storage.local.set(items); | 499 chrome.storage.local.set(items); |
500 remoting.AppsV2Migration.savePreferences(this.hosts_.length !== 0); | |
465 }; | 501 }; |
466 | 502 |
467 /** | 503 /** |
468 * Key name under which Me2Me hosts are cached. | 504 * Key name under which Me2Me hosts are cached. |
469 */ | 505 */ |
470 remoting.HostList.HOSTS_KEY = 'me2me-cached-hosts'; | 506 remoting.HostList.HOSTS_KEY = 'me2me-cached-hosts'; |
471 | 507 |
472 /** @type {remoting.HostList} */ | 508 /** @type {remoting.HostList} */ |
473 remoting.hostList = null; | 509 remoting.hostList = null; |
OLD | NEW |