diff options
author | jamiewalch@google.com <jamiewalch@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-13 23:34:35 +0000 |
---|---|---|
committer | jamiewalch@google.com <jamiewalch@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-13 23:34:35 +0000 |
commit | 08265d3f2aa70fd5f9bd290bb093dace758cd134 (patch) | |
tree | e4380fd1297d0b24e25db9e1594fe585e209ad26 /remoting | |
parent | 777211164945d2daf2d887c6f54d38ffd050ecff (diff) | |
download | chromium_src-08265d3f2aa70fd5f9bd290bb093dace758cd134.zip chromium_src-08265d3f2aa70fd5f9bd290bb093dace758cd134.tar.gz chromium_src-08265d3f2aa70fd5f9bd290bb093dace758cd134.tar.bz2 |
Don't register more than one 'connect' event handler per HostTableEntry. Don't create more than one HostTableEntry for the daemon UI.
BUG=121509
TEST=Manual
Review URL: https://chromiumcodereview.appspot.com/10081027
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132295 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r-- | remoting/webapp/host_controller.js | 22 | ||||
-rw-r--r-- | remoting/webapp/host_table_entry.js | 25 |
2 files changed, 32 insertions, 15 deletions
diff --git a/remoting/webapp/host_controller.js b/remoting/webapp/host_controller.js index 2b41096..e139575 100644 --- a/remoting/webapp/host_controller.js +++ b/remoting/webapp/host_controller.js @@ -279,13 +279,21 @@ remoting.HostController.prototype.setHost = function(host) { remoting.hostList.renameHost(host); that.setTooltips(); }; - /** @type {remoting.HostTableEntry} @private */ - this.hostTableEntry_ = new remoting.HostTableEntry(); - this.hostTableEntry_.init(host, - document.getElementById('this-host-connect'), - document.getElementById('this-host-name'), - document.getElementById('this-host-rename'), - renameHost); + if (!this.hostTableEntry_) { + /** @type {remoting.HostTableEntry} @private */ + this.hostTableEntry_ = new remoting.HostTableEntry(); + this.hostTableEntry_.init(host, + document.getElementById('this-host-connect'), + document.getElementById('this-host-name'), + document.getElementById('this-host-rename'), + renameHost); + } else { + // TODO(jamiewalch): This is hack to prevent multiple click handlers being + // registered for the same DOM elements if this method is called more than + // once. A better solution would be to let HostTable create the daemon row + // like it creates the rows for non-local hosts. + this.hostTableEntry_.host = host; + } } else { this.hostTableEntry_ = null; } diff --git a/remoting/webapp/host_table_entry.js b/remoting/webapp/host_table_entry.js index 789db2c..9ea7fb3 100644 --- a/remoting/webapp/host_table_entry.js +++ b/remoting/webapp/host_table_entry.js @@ -53,8 +53,8 @@ remoting.HostTableEntry = function() { this.onConfirmDeleteReference_ = function() {}; /** @type {function():void} @private */ this.onCancelDeleteReference_ = function() {}; - /** @type {function():void} @private */ - this.onConnectReference_ = function() {}; + /** @type {function():void?} @private */ + this.onConnectReference_ = null; }; /** @@ -145,10 +145,6 @@ remoting.HostTableEntry.prototype.init = function( }; opt_deleteButton.addEventListener('click', confirmDelete, false); } - var hostUrl = chrome.extension.getURL('main.html') + - '?mode=me2me&hostId=' + encodeURIComponent(host.hostId); - this.onConnectReference_ = function() { window.location.assign(hostUrl); }; - this.updateStatus(); }; @@ -163,12 +159,25 @@ remoting.HostTableEntry.prototype.init = function( remoting.HostTableEntry.prototype.updateStatus = function(opt_forEdit) { var clickToConnect = this.host.status == 'ONLINE' && !opt_forEdit; if (clickToConnect) { - this.tableRow.addEventListener('click', this.onConnectReference_, false); + if (!this.onConnectReference_) { + /** @type {remoting.HostTableEntry} */ + var that = this; + this.onConnectReference_ = function() { + var hostUrl = chrome.extension.getURL('main.html') + + '?mode=me2me&hostId=' + encodeURIComponent(that.host.hostId); + window.location.assign(hostUrl); + }; + this.tableRow.addEventListener('click', this.onConnectReference_, false); + } this.tableRow.classList.add('clickable'); this.tableRow.title = chrome.i18n.getMessage( /*i18n-content*/'TOOLTIP_CONNECT', this.host.hostName); } else { - this.tableRow.removeEventListener('click', this.onConnectReference_, false); + if (this.onConnectReference_) { + this.tableRow.removeEventListener('click', this.onConnectReference_, + false); + this.onConnectReference_ = null; + } this.tableRow.classList.remove('clickable'); this.tableRow.title = ''; } |