Commit 08265d3f authored by jamiewalch@google.com's avatar jamiewalch@google.com

Don't register more than one 'connect' event handler per HostTableEntry. Don't...

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
parent 77721116
......@@ -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;
}
......
......@@ -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 = '';
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment