Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Side by Side Diff: remoting/webapp/crd/js/host_list.js

Issue 955283002: Converted remoting.Error from an enum to a class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « remoting/webapp/crd/js/host_installer.js ('k') | remoting/webapp/crd/js/host_list_api_impl.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 30 matching lines...) Expand all
41 this.errorMsg_ = errorMsg; 41 this.errorMsg_ = errorMsg;
42 /** @private {Element} */ 42 /** @private {Element} */
43 this.errorButton_ = errorButton; 43 this.errorButton_ = errorButton;
44 /** @private {HTMLElement} */ 44 /** @private {HTMLElement} */
45 this.loadingIndicator_ = loadingIndicator; 45 this.loadingIndicator_ = loadingIndicator;
46 /** @private {Array<remoting.HostTableEntry>} */ 46 /** @private {Array<remoting.HostTableEntry>} */
47 this.hostTableEntries_ = []; 47 this.hostTableEntries_ = [];
48 /** @private {Array<remoting.Host>} */ 48 /** @private {Array<remoting.Host>} */
49 this.hosts_ = []; 49 this.hosts_ = [];
50 /** @private {!remoting.Error} */ 50 /** @private {!remoting.Error} */
51 this.lastError_ = remoting.Error.NONE; 51 this.lastError_ = remoting.Error.none();
52 /** @private {remoting.LocalHostSection} */ 52 /** @private {remoting.LocalHostSection} */
53 this.localHostSection_ = new remoting.LocalHostSection( 53 this.localHostSection_ = new remoting.LocalHostSection(
54 /** @type {HTMLElement} */ (document.querySelector('.daemon-control')), 54 /** @type {HTMLElement} */ (document.querySelector('.daemon-control')),
55 new remoting.LocalHostSection.Controller( 55 new remoting.LocalHostSection.Controller(
56 this, new remoting.HostSetupDialog(remoting.hostController))); 56 this, new remoting.HostSetupDialog(remoting.hostController)));
57 57
58 /** @private {number} */ 58 /** @private {number} */
59 this.webappMajorVersion_ = parseInt(chrome.runtime.getManifest().version, 10); 59 this.webappMajorVersion_ = parseInt(chrome.runtime.getManifest().version, 10);
60 60
61 this.errorButton_.addEventListener('click', 61 this.errorButton_.addEventListener('click',
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 * Handle the results of the host list request. A success response will 150 * Handle the results of the host list request. A success response will
151 * include a JSON-encoded list of host descriptions, which we display if we're 151 * include a JSON-encoded list of host descriptions, which we display if we're
152 * able to successfully parse it. 152 * able to successfully parse it.
153 * 153 *
154 * @param {function(boolean):void} onDone The callback passed to |refresh|. 154 * @param {function(boolean):void} onDone The callback passed to |refresh|.
155 * @param {Array<remoting.Host>} hosts The list of hosts for the user. 155 * @param {Array<remoting.Host>} hosts The list of hosts for the user.
156 * @return {void} Nothing. 156 * @return {void} Nothing.
157 * @private 157 * @private
158 */ 158 */
159 remoting.HostList.prototype.onHostListResponse_ = function(onDone, hosts) { 159 remoting.HostList.prototype.onHostListResponse_ = function(onDone, hosts) {
160 this.lastError_ = remoting.Error.NONE; 160 this.lastError_ = remoting.Error.none();
161 this.hosts_ = hosts; 161 this.hosts_ = hosts;
162 this.sortHosts_(); 162 this.sortHosts_();
163 this.save_(); 163 this.save_();
164 this.loadingIndicator_.classList.remove('loading'); 164 this.loadingIndicator_.classList.remove('loading');
165 onDone(true); 165 onDone(true);
166 }; 166 };
167 167
168 /** 168 /**
169 * Sort the internal list of hosts. 169 * Sort the internal list of hosts.
170 * 170 *
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 this.table_.innerText = ''; 206 this.table_.innerText = '';
207 this.errorMsg_.innerText = ''; 207 this.errorMsg_.innerText = '';
208 this.hostTableEntries_ = []; 208 this.hostTableEntries_ = [];
209 209
210 var noHostsRegistered = (this.hosts_.length == 0); 210 var noHostsRegistered = (this.hosts_.length == 0);
211 this.table_.hidden = noHostsRegistered; 211 this.table_.hidden = noHostsRegistered;
212 this.noHosts_.hidden = !noHostsRegistered; 212 this.noHosts_.hidden = !noHostsRegistered;
213 213
214 if (this.lastError_.isError()) { 214 if (this.lastError_.isError()) {
215 l10n.localizeElementFromTag(this.errorMsg_, this.lastError_.tag); 215 l10n.localizeElementFromTag(this.errorMsg_, this.lastError_.tag);
216 if (this.lastError_.tag == remoting.Error.Tag.AUTHENTICATION_FAILED) { 216 if (this.lastError_.hasTag(remoting.Error.Tag.AUTHENTICATION_FAILED)) {
217 l10n.localizeElementFromTag(this.errorButton_, 217 l10n.localizeElementFromTag(this.errorButton_,
218 /*i18n-content*/'SIGN_IN_BUTTON'); 218 /*i18n-content*/'SIGN_IN_BUTTON');
219 } else { 219 } else {
220 l10n.localizeElementFromTag(this.errorButton_, 220 l10n.localizeElementFromTag(this.errorButton_,
221 /*i18n-content*/'RETRY'); 221 /*i18n-content*/'RETRY');
222 } 222 }
223 } else { 223 } else {
224 for (var i = 0; i < this.hosts_.length; ++i) { 224 for (var i = 0; i < this.hosts_.length; ++i) {
225 /** @type {remoting.Host} */ 225 /** @type {remoting.Host} */
226 var host = this.hosts_[i]; 226 var host = this.hosts_[i];
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 this.lastError_.isError()); 389 this.lastError_.isError());
390 }; 390 };
391 391
392 /** 392 /**
393 * Called when the user clicks the button next to the error message. The action 393 * Called when the user clicks the button next to the error message. The action
394 * depends on the error. 394 * depends on the error.
395 * 395 *
396 * @private 396 * @private
397 */ 397 */
398 remoting.HostList.prototype.onErrorClick_ = function() { 398 remoting.HostList.prototype.onErrorClick_ = function() {
399 if (this.lastError_.tag == remoting.Error.Tag.AUTHENTICATION_FAILED) { 399 if (this.lastError_.hasTag(remoting.Error.Tag.AUTHENTICATION_FAILED)) {
400 remoting.handleAuthFailureAndRelaunch(); 400 remoting.handleAuthFailureAndRelaunch();
401 } else { 401 } else {
402 this.refresh(remoting.updateLocalHostState); 402 this.refresh(remoting.updateLocalHostState);
403 } 403 }
404 }; 404 };
405 405
406 /** 406 /**
407 * Save the host list to local storage. 407 * Save the host list to local storage.
408 */ 408 */
409 remoting.HostList.prototype.save_ = function() { 409 remoting.HostList.prototype.save_ = function() {
410 var items = {}; 410 var items = {};
411 items[remoting.HostList.HOSTS_KEY] = JSON.stringify(this.hosts_); 411 items[remoting.HostList.HOSTS_KEY] = JSON.stringify(this.hosts_);
412 chrome.storage.local.set(items); 412 chrome.storage.local.set(items);
413 if (this.hosts_.length !== 0) { 413 if (this.hosts_.length !== 0) {
414 remoting.AppsV2Migration.saveUserInfo(); 414 remoting.AppsV2Migration.saveUserInfo();
415 } 415 }
416 }; 416 };
417 417
418 /** 418 /**
419 * Key name under which Me2Me hosts are cached. 419 * Key name under which Me2Me hosts are cached.
420 */ 420 */
421 remoting.HostList.HOSTS_KEY = 'me2me-cached-hosts'; 421 remoting.HostList.HOSTS_KEY = 'me2me-cached-hosts';
422 422
423 /** @type {remoting.HostList} */ 423 /** @type {remoting.HostList} */
424 remoting.hostList = null; 424 remoting.hostList = null;
OLDNEW
« no previous file with comments | « remoting/webapp/crd/js/host_installer.js ('k') | remoting/webapp/crd/js/host_list_api_impl.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698