| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 * @type {Element} | 50 * @type {Element} |
| 51 * @private | 51 * @private |
| 52 */ | 52 */ |
| 53 this.errorButton_ = errorButton; | 53 this.errorButton_ = errorButton; |
| 54 /** | 54 /** |
| 55 * @type {HTMLElement} | 55 * @type {HTMLElement} |
| 56 * @private | 56 * @private |
| 57 */ | 57 */ |
| 58 this.loadingIndicator_ = loadingIndicator; | 58 this.loadingIndicator_ = loadingIndicator; |
| 59 /** | 59 /** |
| 60 * @type {Array.<remoting.HostTableEntry>} | 60 * @type {Array<remoting.HostTableEntry>} |
| 61 * @private | 61 * @private |
| 62 */ | 62 */ |
| 63 this.hostTableEntries_ = []; | 63 this.hostTableEntries_ = []; |
| 64 /** | 64 /** |
| 65 * @type {Array.<remoting.Host>} | 65 * @type {Array<remoting.Host>} |
| 66 * @private | 66 * @private |
| 67 */ | 67 */ |
| 68 this.hosts_ = []; | 68 this.hosts_ = []; |
| 69 /** | 69 /** |
| 70 * @type {string} | 70 * @type {string} |
| 71 * @private | 71 * @private |
| 72 */ | 72 */ |
| 73 this.lastError_ = ''; | 73 this.lastError_ = ''; |
| 74 /** | 74 /** |
| 75 * @type {remoting.Host?} | 75 * @type {remoting.Host?} |
| (...skipping 28 matching lines...) Expand all Loading... |
| 104 | 104 |
| 105 /** | 105 /** |
| 106 * Load the host-list asynchronously from local storage. | 106 * Load the host-list asynchronously from local storage. |
| 107 * | 107 * |
| 108 * @param {function():void} onDone Completion callback. | 108 * @param {function():void} onDone Completion callback. |
| 109 */ | 109 */ |
| 110 remoting.HostList.prototype.load = function(onDone) { | 110 remoting.HostList.prototype.load = function(onDone) { |
| 111 // Load the cache of the last host-list, if present. | 111 // Load the cache of the last host-list, if present. |
| 112 /** @type {remoting.HostList} */ | 112 /** @type {remoting.HostList} */ |
| 113 var that = this; | 113 var that = this; |
| 114 /** @param {Object.<string>} items */ | 114 /** @param {Object<string>} items */ |
| 115 var storeHostList = function(items) { | 115 var storeHostList = function(items) { |
| 116 if (items[remoting.HostList.HOSTS_KEY]) { | 116 if (items[remoting.HostList.HOSTS_KEY]) { |
| 117 var cached = base.jsonParseSafe(items[remoting.HostList.HOSTS_KEY]); | 117 var cached = base.jsonParseSafe(items[remoting.HostList.HOSTS_KEY]); |
| 118 if (cached) { | 118 if (cached) { |
| 119 that.hosts_ = /** @type {Array.<remoting.Host>} */ (cached); | 119 that.hosts_ = /** @type {Array<remoting.Host>} */ (cached); |
| 120 } else { | 120 } else { |
| 121 console.error('Invalid value for ' + remoting.HostList.HOSTS_KEY); | 121 console.error('Invalid value for ' + remoting.HostList.HOSTS_KEY); |
| 122 } | 122 } |
| 123 } | 123 } |
| 124 onDone(); | 124 onDone(); |
| 125 }; | 125 }; |
| 126 chrome.storage.local.get(remoting.HostList.HOSTS_KEY, storeHostList); | 126 chrome.storage.local.get(remoting.HostList.HOSTS_KEY, storeHostList); |
| 127 }; | 127 }; |
| 128 | 128 |
| 129 /** | 129 /** |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 remoting.hostListApi.get(this.onHostListResponse_.bind(this, onDone), | 175 remoting.hostListApi.get(this.onHostListResponse_.bind(this, onDone), |
| 176 onError); | 176 onError); |
| 177 }; | 177 }; |
| 178 | 178 |
| 179 /** | 179 /** |
| 180 * Handle the results of the host list request. A success response will | 180 * Handle the results of the host list request. A success response will |
| 181 * include a JSON-encoded list of host descriptions, which we display if we're | 181 * include a JSON-encoded list of host descriptions, which we display if we're |
| 182 * able to successfully parse it. | 182 * able to successfully parse it. |
| 183 * | 183 * |
| 184 * @param {function(boolean):void} onDone The callback passed to |refresh|. | 184 * @param {function(boolean):void} onDone The callback passed to |refresh|. |
| 185 * @param {Array.<remoting.Host>} hosts The list of hosts for the user. | 185 * @param {Array<remoting.Host>} hosts The list of hosts for the user. |
| 186 * @return {void} Nothing. | 186 * @return {void} Nothing. |
| 187 * @private | 187 * @private |
| 188 */ | 188 */ |
| 189 remoting.HostList.prototype.onHostListResponse_ = function(onDone, hosts) { | 189 remoting.HostList.prototype.onHostListResponse_ = function(onDone, hosts) { |
| 190 this.lastError_ = ''; | 190 this.lastError_ = ''; |
| 191 this.hosts_ = hosts; | 191 this.hosts_ = hosts; |
| 192 this.sortHosts_(); | 192 this.sortHosts_(); |
| 193 this.save_(); | 193 this.save_(); |
| 194 this.loadingIndicator_.classList.remove('loading'); | 194 this.loadingIndicator_.classList.remove('loading'); |
| 195 onDone(this.lastError_ == ''); | 195 onDone(this.lastError_ == ''); |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 } | 500 } |
| 501 }; | 501 }; |
| 502 | 502 |
| 503 /** | 503 /** |
| 504 * Key name under which Me2Me hosts are cached. | 504 * Key name under which Me2Me hosts are cached. |
| 505 */ | 505 */ |
| 506 remoting.HostList.HOSTS_KEY = 'me2me-cached-hosts'; | 506 remoting.HostList.HOSTS_KEY = 'me2me-cached-hosts'; |
| 507 | 507 |
| 508 /** @type {remoting.HostList} */ | 508 /** @type {remoting.HostList} */ |
| 509 remoting.hostList = null; | 509 remoting.hostList = null; |
| OLD | NEW |