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

Side by Side Diff: chrome/renderer/resources/extensions/input.ime_custom_bindings.js

Issue 10736024: Revert 146038 as it might have broken chromeos browser_tests - Make eventArgumentMassagers asynchro… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Custom bindings for the input ime API. Only injected into the 5 // Custom bindings for the input ime API. Only injected into the
6 // v8 contexts for extensions which have permission for the API. 6 // v8 contexts for extensions which have permission for the API.
7 7
8 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); 8 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden();
9 9
10 chromeHidden.registerCustomHook('input.ime', function() { 10 chromeHidden.registerCustomHook('input.ime', function() {
11 chrome.input.ime.onKeyEvent.dispatchToListener = function(callback, args) { 11 chrome.input.ime.onKeyEvent.dispatch = function(engineID, keyData) {
12 var engineID = args[0]; 12 var args = Array.prototype.slice.call(arguments);
13 var keyData = args[1]; 13 if (this.validate_) {
14 14 var validationErrors = this.validate_(args);
15 var result = false; 15 if (validationErrors) {
16 try { 16 chrome.input.ime.eventHandled(requestId, false);
17 result = chrome.Event.prototype.dispatchToListener(callback, args); 17 return validationErrors;
18 } catch (e) { 18 }
19 console.error('Error in event handler for onKeyEvent: ' + e.stack);
20 } 19 }
21 chrome.input.ime.eventHandled(keyData.requestId, result); 20 if (this.listeners_.length > 1) {
21 console.error('Too many listeners for onKeyEvent: ' + e.stack);
22 chrome.input.ime.eventHandled(requestId, false);
23 return;
24 }
25 for (var i = 0; i < this.listeners_.length; i++) {
26 try {
27 var requestId = keyData.requestId;
28 var result = this.listeners_[i].callback.apply(null, args);
29 chrome.input.ime.eventHandled(requestId, result);
30 } catch (e) {
31 console.error('Error in event handler for onKeyEvent: ' + e.stack);
32 chrome.input.ime.eventHandled(requestId, false);
33 }
34 }
22 }; 35 };
23 }); 36 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698