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

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

Issue 9423049: Make registering custom hooks with schema_generated_bindings.js safer and (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 10 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 (function() { 8 (function() {
9 9
10 native function GetChromeHidden(); 10 native function GetChromeHidden();
11 11
12 GetChromeHidden().registerCustomHook('input.ime', function() { 12 GetChromeHidden().registerCustomHook('input.ime', function() {
13 chrome.input.ime.onKeyEvent.dispatch = function(engineID, keyData) { 13 chrome.input.ime.onKeyEvent.dispatch = function(engineID, keyData) {
14 var args = Array.prototype.slice.call(arguments); 14 var args = Array.prototype.slice.call(arguments);
15 if (this.validate_) { 15 if (this.validate_) {
16 var validationErrors = this.validate_(args); 16 var validationErrors = this.validate_(args);
17 if (validationErrors) { 17 if (validationErrors) {
18 chrome.input.ime.eventHandled(requestId, false); 18 chrome.input.ime.eventHandled(requestId, false);
19 return validationErrors; 19 return validationErrors;
20 } 20 }
21 } 21 }
22 if (this.listeners_.length > 1) { 22 if (this.listeners_.length > 1) {
23 console.error("Too many listeners for 'onKeyEvent': " + e.stack); 23 console.error('Too many listeners for onKeyEvent: ' + e.stack);
24 chrome.input.ime.eventHandled(requestId, false); 24 chrome.input.ime.eventHandled(requestId, false);
25 return; 25 return;
26 } 26 }
27 for (var i = 0; i < this.listeners_.length; i++) { 27 for (var i = 0; i < this.listeners_.length; i++) {
28 try { 28 try {
29 var requestId = keyData.requestId; 29 var requestId = keyData.requestId;
30 var result = this.listeners_[i].apply(null, args); 30 var result = this.listeners_[i].apply(null, args);
31 chrome.input.ime.eventHandled(requestId, result); 31 chrome.input.ime.eventHandled(requestId, result);
32 } catch (e) { 32 } catch (e) {
33 console.error("Error in event handler for 'onKeyEvent': " + e.stack); 33 console.error('Error in event handler for onKeyEvent: ' + e.stack);
34 chrome.input.ime.eventHandled(requestId, false); 34 chrome.input.ime.eventHandled(requestId, false);
35 } 35 }
36 } 36 }
37 }; 37 };
38 }); 38 });
39 39
40 })(); 40 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698