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

Unified Diff: remoting/webapp/host_table_entry.js

Issue 10081027: Don't register more than one 'connect' event handler per HostTableEntry. Don't create more than one… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed JSCompile error. Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/webapp/host_controller.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/webapp/host_table_entry.js
diff --git a/remoting/webapp/host_table_entry.js b/remoting/webapp/host_table_entry.js
index 789db2cd6a46f19c27e93e7949e8baf669e6ad2a..9ea7fb3096647f2518ab384335353bc2463ea1a8 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 = '';
}
« no previous file with comments | « remoting/webapp/host_controller.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698