summaryrefslogtreecommitdiffstats
path: root/chrome/renderer
diff options
context:
space:
mode:
authorzork@chromium.org <zork@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-08 05:18:06 +0000
committerzork@chromium.org <zork@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-08 05:18:06 +0000
commitcd0b04c94c9d2dd922bcdd63b9325dfdacef3b85 (patch)
tree86cd0e0bad4e5a3ecbdf44da6cbc2836c154950c /chrome/renderer
parentb103b5975f6ac1b1b491510b8246091f160d9013 (diff)
downloadchromium_src-cd0b04c94c9d2dd922bcdd63b9325dfdacef3b85.zip
chromium_src-cd0b04c94c9d2dd922bcdd63b9325dfdacef3b85.tar.gz
chromium_src-cd0b04c94c9d2dd922bcdd63b9325dfdacef3b85.tar.bz2
Make OnKeyEvent asynchronous to match the design.
BUG=None TEST=None Review URL: http://codereview.chromium.org/7721006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@100107 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r--chrome/renderer/resources/extension_process_bindings.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/chrome/renderer/resources/extension_process_bindings.js b/chrome/renderer/resources/extension_process_bindings.js
index c0c93ee..4dd5461 100644
--- a/chrome/renderer/resources/extension_process_bindings.js
+++ b/chrome/renderer/resources/extension_process_bindings.js
@@ -415,6 +415,35 @@ var chrome = chrome || {};
customBindings['ContentSetting'] = ContentSetting;
}
+ function setupInputEvents() {
+ chrome.experimental.input.onKeyEvent.dispatch =
+ function(engineID, keyData) {
+ var args = Array.prototype.slice.call(arguments);
+ if (this.validate_) {
+ var validationErrors = this.validate_(args);
+ if (validationErrors) {
+ chrome.experimental.input.eventHandled(requestId, false);
+ return validationErrors;
+ }
+ }
+ if (this.listeners_.length > 1) {
+ console.error("Too many listeners for 'onKeyEvent': " + e.stack);
+ chrome.experimental.input.eventHandled(requestId, false);
+ return;
+ }
+ for (var i = 0; i < this.listeners_.length; i++) {
+ try {
+ var requestId = keyData.requestId;
+ var result = this.listeners_[i].apply(null, args);
+ chrome.experimental.input.eventHandled(requestId, result);
+ } catch (e) {
+ console.error("Error in event handler for 'onKeyEvent': " + e.stack);
+ chrome.experimental.input.eventHandled(requestId, false);
+ }
+ }
+ };
+ }
+
// Page action events send (pageActionId, {tabId, tabUrl}).
function setupPageActionEvents(extensionId) {
var pageActions = GetCurrentPageActions(extensionId);
@@ -1021,6 +1050,7 @@ var chrome = chrome || {};
setupPageActionEvents(extensionId);
setupToolstripEvents(GetRenderViewId());
setupHiddenContextMenuEvent(extensionId);
+ setupInputEvents();
setupOmniboxEvents();
setupTtsEvents();
});