summaryrefslogtreecommitdiffstats
path: root/remoting
diff options
context:
space:
mode:
authorkelvinp <kelvinp@chromium.org>2016-01-13 18:23:17 -0800
committerCommit bot <commit-bot@chromium.org>2016-01-14 02:24:53 +0000
commit05db7454a08aeb230f34b1c2ed9fd74252e7c71a (patch)
tree4b3444f5b135ed93b300d2076287be2fdfdd3d0b /remoting
parentfb77a3ad74674e58e2886d807335c0669749d869 (diff)
downloadchromium_src-05db7454a08aeb230f34b1c2ed9fd74252e7c71a.zip
chromium_src-05db7454a08aeb230f34b1c2ed9fd74252e7c71a.tar.gz
chromium_src-05db7454a08aeb230f34b1c2ed9fd74252e7c71a.tar.bz2
Fix script error on disconnect.
Cause: We set a timer to handle blur event but we do not destroy the timer on dispose. Fix: Wrapped the callback in a base.OneShotTimer and destroyed the timer on dispose. BUG=522577 Review URL: https://codereview.chromium.org/1584573006 Cr-Commit-Position: refs/heads/master@{#369286}
Diffstat (limited to 'remoting')
-rw-r--r--remoting/webapp/base/js/connected_view.js11
1 files changed, 8 insertions, 3 deletions
diff --git a/remoting/webapp/base/js/connected_view.js b/remoting/webapp/base/js/connected_view.js
index da75a66..b90a112 100644
--- a/remoting/webapp/base/js/connected_view.js
+++ b/remoting/webapp/base/js/connected_view.js
@@ -52,6 +52,9 @@ remoting.ConnectedView = function(plugin, viewportElement, cursorElement) {
new remoting.Clipboard(plugin)
);
+ /** @private {base.OneShotTimer} */
+ this.restoreFocusTimer_ = null;
+
// TODO(wez): Only allow mouse lock if the app has the pointerLock permission.
this.plugin_.allowMouseLock();
@@ -66,6 +69,8 @@ remoting.ConnectedView.prototype.dispose = function() {
this.disposables_ = null;
this.cursorRender_ = null;
this.plugin_ = null;
+ base.dispose(this.restoreFocusTimer_);
+ this.restoreFocusTimer_ = null;
};
/**
@@ -101,7 +106,8 @@ remoting.ConnectedView.prototype.onPluginLostFocus_ = function(event) {
// Due to crbug.com/246335, we can't restore the focus immediately,
// otherwise the plugin gets confused about whether or not it has focus.
var that = this;
- var delayedCallback = function() {
+ base.dispose(this.restoreFocusTimer_);
+ this.restoreFocusTimer_ = new base.OneShotTimer(function() {
// When the 'blur' event handler is called document.activeElement has not
// been set to the correct target. We need to retrieve the target in this
// delayedCallback.
@@ -109,8 +115,7 @@ remoting.ConnectedView.prototype.onPluginLostFocus_ = function(event) {
if (!that.isElementFocusable_(target)) {
that.plugin_.element().focus();
}
- };
- window.setTimeout(delayedCallback, 0);
+ }, 0);
};
/**