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

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

Issue 1020743002: [Chromoting] Move app-specific code out of remoting.js (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make isMe2MeInstallable private 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/desktop_remoting.js ('k') | remoting/webapp/crd/js/host_setup_dialog.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';
11 11
12 /** @suppress {duplicate} */ 12 /** @suppress {duplicate} */
13 var remoting = remoting || {}; 13 var remoting = remoting || {};
14 14
15 /** 15 /**
16 * Create a host list consisting of the specified HTML elements, which should 16 * Create a host list consisting of the specified HTML elements, which should
17 * have a common parent that contains only host-list UI as it will be hidden 17 * have a common parent that contains only host-list UI as it will be hidden
18 * if the host-list is empty. 18 * if the host-list is empty.
19 * 19 *
20 * @constructor 20 * @constructor
21 * @param {Element} table The HTML <div> to contain host-list. 21 * @param {Element} table The HTML <div> to contain host-list.
22 * @param {Element} noHosts The HTML <div> containing the "no hosts" message. 22 * @param {Element} noHosts The HTML <div> containing the "no hosts" message.
23 * @param {Element} errorMsg The HTML <div> to display error messages. 23 * @param {Element} errorMsg The HTML <div> to display error messages.
24 * @param {Element} errorButton The HTML <button> to display the error 24 * @param {Element} errorButton The HTML <button> to display the error
25 * resolution action. 25 * resolution action.
26 * @param {HTMLElement} loadingIndicator The HTML <span> to update while the 26 * @param {HTMLElement} loadingIndicator The HTML <span> to update while the
27 * host list is being loaded. The first element of this span should be 27 * host list is being loaded. The first element of this span should be
28 * the reload button. 28 * the reload button.
29 * @param {function(!remoting.Error)} onError Function to call when an error
30 * occurs.
29 */ 31 */
30 remoting.HostList = function(table, noHosts, errorMsg, errorButton, 32 remoting.HostList = function(table, noHosts, errorMsg, errorButton,
31 loadingIndicator) { 33 loadingIndicator, onError) {
32 /** @private {Element} */ 34 /** @private {Element} */
33 this.table_ = table; 35 this.table_ = table;
34 /** 36 /**
35 * TODO(jamiewalch): This should be doable using CSS's sibling selector, 37 * TODO(jamiewalch): This should be doable using CSS's sibling selector,
36 * but it doesn't work right now (crbug.com/135050). 38 * but it doesn't work right now (crbug.com/135050).
37 * @private {Element} 39 * @private {Element}
38 */ 40 */
39 this.noHosts_ = noHosts; 41 this.noHosts_ = noHosts;
40 /** @private {Element} */ 42 /** @private {Element} */
41 this.errorMsg_ = errorMsg; 43 this.errorMsg_ = errorMsg;
42 /** @private {Element} */ 44 /** @private {Element} */
43 this.errorButton_ = errorButton; 45 this.errorButton_ = errorButton;
44 /** @private {HTMLElement} */ 46 /** @private {HTMLElement} */
45 this.loadingIndicator_ = loadingIndicator; 47 this.loadingIndicator_ = loadingIndicator;
48 this.onError_ = onError;
49
46 /** @private {Array<remoting.HostTableEntry>} */ 50 /** @private {Array<remoting.HostTableEntry>} */
47 this.hostTableEntries_ = []; 51 this.hostTableEntries_ = [];
48 /** @private {Array<remoting.Host>} */ 52 /** @private {Array<remoting.Host>} */
49 this.hosts_ = []; 53 this.hosts_ = [];
50 /** @private {!remoting.Error} */ 54 /** @private {!remoting.Error} */
51 this.lastError_ = remoting.Error.none(); 55 this.lastError_ = remoting.Error.none();
52 /** @private {remoting.LocalHostSection} */ 56 /** @private {remoting.LocalHostSection} */
53 this.localHostSection_ = new remoting.LocalHostSection( 57 this.localHostSection_ = new remoting.LocalHostSection(
54 /** @type {HTMLElement} */ (document.querySelector('.daemon-control')), 58 /** @type {HTMLElement} */ (document.querySelector('.daemon-control')),
55 new remoting.LocalHostSection.Controller( 59 new remoting.LocalHostSection.Controller(
56 this, new remoting.HostSetupDialog(remoting.hostController))); 60 this,
61 new remoting.HostSetupDialog(remoting.hostController, onError)));
57 62
58 /** @private {number} */ 63 /** @private {number} */
59 this.webappMajorVersion_ = parseInt(chrome.runtime.getManifest().version, 10); 64 this.webappMajorVersion_ = parseInt(chrome.runtime.getManifest().version, 10);
60 65
61 this.errorButton_.addEventListener('click', 66 this.errorButton_.addEventListener('click',
62 this.onErrorClick_.bind(this), 67 this.onErrorClick_.bind(this),
63 false); 68 false);
64 var reloadButton = this.loadingIndicator_.firstElementChild; 69 var reloadButton = this.loadingIndicator_.firstElementChild;
65 /** @type {remoting.HostList} */ 70 /** @type {remoting.HostList} */
66 var that = this; 71 var that = this;
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 * @return {void} Nothing. 293 * @return {void} Nothing.
289 * @private 294 * @private
290 */ 295 */
291 remoting.HostList.prototype.deleteHost_ = function(hostTableEntry) { 296 remoting.HostList.prototype.deleteHost_ = function(hostTableEntry) {
292 this.table_.removeChild(hostTableEntry.element()); 297 this.table_.removeChild(hostTableEntry.element());
293 var index = this.hostTableEntries_.indexOf(hostTableEntry); 298 var index = this.hostTableEntries_.indexOf(hostTableEntry);
294 if (index != -1) { 299 if (index != -1) {
295 this.hostTableEntries_.splice(index, 1); 300 this.hostTableEntries_.splice(index, 1);
296 } 301 }
297 remoting.hostListApi.remove(hostTableEntry.host.hostId, base.doNothing, 302 remoting.hostListApi.remove(hostTableEntry.host.hostId, base.doNothing,
298 remoting.showErrorMessage); 303 this.onError_);
299 }; 304 };
300 305
301 /** 306 /**
302 * Prepare a host for renaming by replacing its name with an edit box. 307 * Prepare a host for renaming by replacing its name with an edit box.
303 * @param {remoting.HostTableEntry} hostTableEntry The host to be renamed. 308 * @param {remoting.HostTableEntry} hostTableEntry The host to be renamed.
304 * @return {void} Nothing. 309 * @return {void} Nothing.
305 */ 310 */
306 remoting.HostList.prototype.renameHost = function(hostTableEntry) { 311 remoting.HostList.prototype.renameHost = function(hostTableEntry) {
307 for (var i = 0; i < this.hosts_.length; ++i) { 312 for (var i = 0; i < this.hosts_.length; ++i) {
308 if (this.hosts_[i].hostId == hostTableEntry.host.hostId) { 313 if (this.hosts_[i].hostId == hostTableEntry.host.hostId) {
309 this.hosts_[i].hostName = hostTableEntry.host.hostName; 314 this.hosts_[i].hostName = hostTableEntry.host.hostName;
310 break; 315 break;
311 } 316 }
312 } 317 }
313 this.save_(); 318 this.save_();
314 319
315 remoting.hostListApi.put(hostTableEntry.host.hostId, 320 remoting.hostListApi.put(hostTableEntry.host.hostId,
316 hostTableEntry.host.hostName, 321 hostTableEntry.host.hostName,
317 hostTableEntry.host.publicKey, 322 hostTableEntry.host.publicKey,
318 function() {}, 323 function() {},
319 remoting.showErrorMessage); 324 this.onError_);
320 }; 325 };
321 326
322 /** 327 /**
323 * Unregister a host. 328 * Unregister a host.
324 * @param {string} hostId The id of the host to be removed. 329 * @param {string} hostId The id of the host to be removed.
325 * @param {function(void)=} opt_onDone 330 * @param {function(void)=} opt_onDone
326 * @return {void} Nothing. 331 * @return {void} Nothing.
327 */ 332 */
328 remoting.HostList.prototype.unregisterHostById = function(hostId, opt_onDone) { 333 remoting.HostList.prototype.unregisterHostById = function(hostId, opt_onDone) {
329 var that = this; 334 var that = this;
330 var onDone = opt_onDone || base.doNothing; 335 var onDone = opt_onDone || base.doNothing;
331 336
332 var host = this.getHostForId(hostId); 337 var host = this.getHostForId(hostId);
333 if (!host) { 338 if (!host) {
334 console.log('Skipping host un-registration as the host is not registered ' + 339 console.log('Skipping host un-registration as the host is not registered ' +
335 'under the current account'); 340 'under the current account');
336 onDone(); 341 onDone();
337 return; 342 return;
338 } 343 }
339 344
340 var onRemoved = function() { 345 var onRemoved = function() {
341 that.refresh(function() { 346 that.refresh(function() {
342 that.display(); 347 that.display();
343 onDone(); 348 onDone();
344 }); 349 });
345 }; 350 };
346 remoting.hostListApi.remove(hostId, onRemoved, remoting.showErrorMessage); 351 remoting.hostListApi.remove(hostId, onRemoved, this.onError_);
347 }; 352 };
348 353
349 /** 354 /**
350 * Set the state of the local host and localHostId if any. 355 * Set the state of the local host and localHostId if any.
351 * 356 *
352 * @param {remoting.HostController.State} state State of the local host. 357 * @param {remoting.HostController.State} state State of the local host.
353 * @param {string?} hostId ID of the local host, or null. 358 * @param {string?} hostId ID of the local host, or null.
354 * @return {void} Nothing. 359 * @return {void} Nothing.
355 */ 360 */
356 remoting.HostList.prototype.setLocalHostStateAndId = function(state, hostId) { 361 remoting.HostList.prototype.setLocalHostStateAndId = function(state, hostId) {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 } 420 }
416 }; 421 };
417 422
418 /** 423 /**
419 * Key name under which Me2Me hosts are cached. 424 * Key name under which Me2Me hosts are cached.
420 */ 425 */
421 remoting.HostList.HOSTS_KEY = 'me2me-cached-hosts'; 426 remoting.HostList.HOSTS_KEY = 'me2me-cached-hosts';
422 427
423 /** @type {remoting.HostList} */ 428 /** @type {remoting.HostList} */
424 remoting.hostList = null; 429 remoting.hostList = null;
OLDNEW
« no previous file with comments | « remoting/webapp/crd/js/desktop_remoting.js ('k') | remoting/webapp/crd/js/host_setup_dialog.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698