Commit 16accd4c authored by jamiewalch's avatar jamiewalch Committed by Commit bot

Reinstated onBlur handler and added images for CWS.

The onBlur handler was accidentally removed by my recent refactoring.
The images are required for submissions to CWS; only the icon needs to
included in the crx, however.

Review URL: https://codereview.chromium.org/868663007

Cr-Commit-Position: refs/heads/master@{#314961}
parent 33e0ed25
......@@ -35,6 +35,7 @@
'tools/javascript_key_tester/main.css',
'tools/javascript_key_tester/main.html',
'tools/javascript_key_tester/manifest.json',
'tools/javascript_key_tester/icon_128.png',
'tools/javascript_key_tester/pnacl/remoting_key_tester.nmf',
'<(PRODUCT_DIR)/remoting_key_tester_newlib.pexe',
],
......
......@@ -36,7 +36,8 @@ var EventListeners = function(jsLog, pnaclLog, textLog,
this.onKeyUpHandler_ = this.onKeyUp_.bind(this);
this.onKeyPressHandler_ = this.onKeyPress_.bind(this);
this.onMessageHandler_ = this.onMessage_.bind(this);
this.onBlurHandler_ = this.onBlur_.bind(this);
this.onPluginBlurHandler_ = this.onPluginBlur_.bind(this);
this.onWindowBlurHandler_ = this.onWindowBlur_.bind(this);
this.jsChordTracker_ = new ChordTracker(jsLog);
this.pnaclChordTracker_ = new ChordTracker(pnaclLog);
......@@ -48,24 +49,27 @@ var EventListeners = function(jsLog, pnaclLog, textLog,
* Start listening for keyboard events.
*/
EventListeners.prototype.activate = function() {
window.addEventListener('blur', this.onWindowBlurHandler_, false);
document.body.addEventListener('keydown', this.onKeyDownHandler_, false);
document.body.addEventListener('keyup', this.onKeyUpHandler_, false);
document.body.addEventListener('keypress', this.onKeyPressHandler_, false);
this.pnaclListener_.addEventListener('message', this.onMessageHandler_, true);
this.pnaclPlugin_.addEventListener('blur', this.onBlurHandler_, false);
this.onBlur_();
this.pnaclPlugin_.addEventListener('blur', this.onPluginBlurHandler_, false);
this.onPluginBlur_();
};
/**
* Stop listening for keyboard events.
*/
EventListeners.prototype.deactivate = function() {
window.removeEventListener('blur', this.onWindowBlurHandler_, false);
document.body.removeEventListener('keydown', this.onKeyDownHandler_, false);
document.body.removeEventListener('keyup', this.onKeyUpHandler_, false);
document.body.removeEventListener('keypress', this.onKeyPressHandler_, false);
this.pnaclListener_.removeEventListener(
'message', this.onMessageHandler_, true);
this.pnaclPlugin_.removeEventListener('blur', this.onBlurHandler_, false);
this.pnaclPlugin_.removeEventListener(
'blur', this.onPluginBlurHandler_, false);
};
/**
......@@ -122,10 +126,18 @@ EventListeners.prototype.onMessage_ = function (event) {
/**
* @return {void}
*/
EventListeners.prototype.onBlur_ = function() {
EventListeners.prototype.onPluginBlur_ = function() {
this.pnaclPlugin_.focus();
};
/**
* @return {void}
*/
EventListeners.prototype.onWindowBlur_ = function() {
this.jsChordTracker_.releaseAllKeys();
this.pnaclChordTracker_.releaseAllKeys();
};
/**
* @param {string} str
* @private
......
......@@ -2,6 +2,9 @@
"name": "Javascript key event tester",
"version": "1.1",
"manifest_version": 2,
"icons": {
"128": "icon_128.png"
},
"app": {
"background": {
"scripts": ["background.js"]
......
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