Properly attach InfoBarContainer when it is swapped to a new WebContents
[chromium-blink-merge.git] / chrome / common / extensions / api / input_ime.json
blobcb41d2934f73c2121dccb8d7d40d1188836eeb5a
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
3 // found in the LICENSE file.
6   {
7     "namespace": "input.ime",
8     "description": "Use the <code>chrome.input.ime</code> API to implement a custom IME for Chrome OS. This allows your extension to handle keystrokes, set the composition, and manage the candidate window.",
9     "types": [
10       {
11         "id": "KeyboardEventType",
12         "type": "string",
13         "enum": ["keyup", "keydown"]
14       },
15       {
16         "id": "KeyboardEvent",
17         "type": "object",
18         "description": "See http://www.w3.org/TR/DOM-Level-3-Events/#events-KeyboardEvent",
19         "properties": {
20           "type": {"$ref": "KeyboardEventType", "description": "One of keyup or keydown."},
21           "requestId": {"type": "string", "description": "The ID of the request."},
22           "extensionId": {"type": "string", "optional": true, "description": "The extension ID of the sender of this keyevent."},
23           "key": {"type": "string", "description": "Value of the key being pressed"},
24           "code": {"type": "string", "description": "Value of the physical key being pressed. The value is not affected by current keyboard layout or modifier state."},
25           "keyCode": {"type": "integer", "optional": true, "description": "The deprecated HTML keyCode, which is system- and implementation-dependent numerical code signifying the unmodified identifier associated with the key pressed."},
26           "altKey": {"type": "boolean", "optional": true, "description": "Whether or not the ALT key is pressed."},
27           "ctrlKey": {"type": "boolean", "optional": true, "description": "Whether or not the CTRL key is pressed."},
28           "shiftKey": {"type": "boolean", "optional": true, "description": "Whether or not the SHIFT key is pressed."},
29           "capsLock": {"type": "boolean", "optional": true, "description": "Whether or not the CAPS_LOCK is enabled."}
30         }
31       },
32       {
33         "id": "InputContextType",
34         "type": "string",
35         "description": "Type of value this text field edits, (Text, Number, URL, etc)",
36         "enum": ["text", "search", "tel", "url", "email", "number", "password"]
37       },
38       {
39         "id": "InputContext",
40         "type": "object",
41         "description": "Describes an input Context",
42         "properties": {
43           "contextID": {"type": "integer", "description": "This is used to specify targets of text field operations.  This ID becomes invalid as soon as onBlur is called."},
44           "type": {"$ref": "InputContextType", "description": "Type of value this text field edits, (Text, Number, URL, etc)"},
45           "autoCorrect": {"type": "boolean", "description": "Whether the text field wants auto-correct."},
46           "autoComplete": {"type": "boolean", "description": "Whether the text field wants auto-complete."},
47           "spellCheck": {"type": "boolean", "description": "Whether the text field wants spell-check."}
48         }
49       },
50       {
51         "id": "MenuItemStyle",
52         "type": "string",
53         "description": "The type of menu item. Radio buttons between separators are considered grouped.",
54         "enum": ["check", "radio", "separator"]
55       },
56       {
57         "id": "MenuItem",
58         "type": "object",
59         "description": "A menu item used by an input method to interact with the user from the language menu.",
60         "properties": {
61           "id": {"type": "string", "description": "String that will be passed to callbacks referencing this MenuItem."},
62           "label": {"type": "string", "optional": true, "description": "Text displayed in the menu for this item."},
63           "style": {
64             "$ref": "MenuItemStyle",
65             "optional": true,
66             "description": "The type of menu item."
67           },
68           "visible": {"type": "boolean", "optional": true, "description": "Indicates this item is visible."},
69           "checked": {"type": "boolean", "optional": true, "description": "Indicates this item should be drawn with a check."},
70           "enabled": {"type": "boolean", "optional": true, "description": "Indicates this item is enabled."}
71         }
72       },
73       {
74         "id": "UnderlineStyle",
75         "type": "string",
76         "description": "The type of the underline to modify this segment.",
77         "enum": ["underline", "doubleUnderline", "noUnderline"]
78       },
79       {
80         "id": "WindowPosition",
81         "type": "string",
82         "description": "Where to display the candidate window. If set to 'cursor', the window follows the cursor. If set to 'composition', the window is locked to the beginning of the composition.",
83         "enum": ["cursor", "composition"]
84       },
85       {
86         "id": "ScreenType",
87         "type": "string",
88         "enum": ["normal", "login", "lock", "secondary-login"],
89         "description": "The screen type under which the IME is activated."
90       },
91       {
92         "id": "CallbackStyle",
93         "type": "string",
94         "enum": ["async"]
95       },
96       {
97         "id": "MouseButton",
98         "type": "string",
99         "description": "Which mouse buttons was clicked.",
100         "enum": ["left", "middle", "right"]
101       }
102     ],
103     "functions": [
104       {
105         "name": "setComposition",
106         "type": "function",
107         "description": "Set the current composition. If this extension does not own the active IME, this fails.",
108         "parameters": [
109           {
110             "name": "parameters",
111             "type": "object",
112             "properties": {
113               "contextID": {
114                 "description": "ID of the context where the composition text will be set",
115                 "type": "integer"
116               },
117               "text": {
118                 "description": "Text to set",
119                 "type": "string"
120               },
121               "selectionStart": {
122                 "description": "Position in the text that the selection starts at.",
123                 "optional": true,
124                 "type": "integer"
125               },
126               "selectionEnd": {
127                 "description": "Position in the text that the selection ends at.",
128                 "optional": true,
129                 "type": "integer"
130               },
131               "cursor": {
132                 "description": "Position in the text of the cursor.",
133                 "type": "integer"
134               },
135               "segments": {
136                 "description": "List of segments and their associated types.",
137                 "type": "array",
138                 "optional": true,
139                 "items": {
140                   "type": "object",
141                   "properties": {
142                     "start": {
143                       "description": "Index of the character to start this segment at",
144                       "type": "integer"
145                     },
146                     "end": {
147                       "description": "Index of the character to end this segment after.",
148                       "type": "integer"
149                     },
150                     "style": {
151                       "$ref": "UnderlineStyle",
152                       "description": "The type of the underline to modify this segment."
153                     }
154                   }
155                 }
156               }
157             }
158           },
159           {
160             "type": "function",
161             "name": "callback",
162             "optional": true,
163             "description": "Called when the operation completes with a boolean indicating if the text was accepted or not. On failure, chrome.runtime.lastError is set.",
164             "parameters": [
165               {
166                 "name": "success",
167                 "type": "boolean"
168               }
169             ]
170           }
171         ]
172       },
173       {
174         "name": "clearComposition",
175         "type": "function",
176         "description": "Clear the current composition. If this extension does not own the active IME, this fails.",
177         "parameters": [
178           {
179             "name": "parameters",
180             "type": "object",
181             "properties": {
182               "contextID": {
183                 "description": "ID of the context where the composition will be cleared",
184                 "type": "integer"
185               }
186             }
187           },
188           {
189             "type": "function",
190             "name": "callback",
191             "optional": true,
192             "description": "Called when the operation completes with a boolean indicating if the text was accepted or not. On failure, chrome.runtime.lastError is set.",
193             "parameters": [
194               {
195                 "name": "success",
196                 "type": "boolean"
197               }
198             ]
199           }
200         ]
201       },
202       {
203         "name": "commitText",
204         "type": "function",
205         "description": "Commits the provided text to the current input.",
206         "parameters": [
207           {
208             "name": "parameters",
209             "type": "object",
210             "properties": {
211               "contextID": {
212                 "description": "ID of the context where the text will be committed",
213                 "type": "integer"
214               },
215               "text": {
216                 "description": "The text to commit",
217                 "type": "string"
218               }
219             }
220           },
221           {
222             "type": "function",
223             "name": "callback",
224             "optional": true,
225             "description": "Called when the operation completes with a boolean indicating if the text was accepted or not. On failure, chrome.runtime.lastError is set.",
226             "parameters": [
227               {
228                 "name": "success",
229                 "type": "boolean"
230               }
231             ]
232           }
233         ]
234       },
235       {
236         "name": "sendKeyEvents",
237         "type": "function",
238         "description": "Sends the key events.  This function is expected to be used by virtual keyboards.  When key(s) on a virtual keyboard is pressed by a user, this function is used to propagate that event to the system.",
239         "parameters": [
240           {
241             "name": "parameters",
242             "type": "object",
243             "properties": {
244               "contextID": {
245                 "description": "ID of the context where the key events will be sent, or zero to send key events to non-input field.",
246                 "type": "integer"
247               },
248               "keyData": {
249                 "type": "array",
250                 "description": "Data on the key event.",
251                 "items": {
252                   "$ref": "KeyboardEvent"
253                 }
254               }
255             }
256           },
257           {
258             "type": "function",
259             "name": "callback",
260             "optional": true,
261             "description": "Called when the operation completes.",
262             "parameters": []
263           }
264         ]
265       },
266       {
267         "name": "hideInputView",
268         "type": "function",
269         "description": "Hides the input view window, which is popped up automatically by system. If the input view window is already hidden, this function will do nothing.",
270         "parameters": []
271       },
272       {
273         "name": "setCandidateWindowProperties",
274         "type": "function",
275         "description": "Sets the properties of the candidate window. This fails if the extension doesn't own the active IME",
276         "parameters": [
277           {
278             "name": "parameters",
279             "type": "object",
280             "properties": {
281               "engineID": {
282                 "description": "ID of the engine to set properties on.",
283                 "type": "string"
284               },
285               "properties": {
286                 "type": "object",
287                 "properties": {
288                   "visible": {
289                     "type": "boolean",
290                     "optional": true,
291                     "description": "True to show the Candidate window, false to hide it."
292                   },
293                   "cursorVisible": {
294                     "type": "boolean",
295                     "optional": true,
296                     "description": "True to show the cursor, false to hide it."
297                   },
298                   "vertical": {
299                     "type": "boolean",
300                     "optional": true,
301                     "description": "True if the candidate window should be rendered vertical, false to make it horizontal."
302                   },
303                   "pageSize": {
304                     "type": "integer",
305                     "optional": true,
306                     "description": "The number of candidates to display per page."
307                   },
308                   "auxiliaryText": {
309                     "type": "string",
310                     "optional": true,
311                     "description": "Text that is shown at the bottom of the candidate window."
312                   },
313                   "auxiliaryTextVisible": {
314                     "type": "boolean",
315                     "optional": true,
316                     "description": "True to display the auxiliary text, false to hide it."
317                   },
318                   "windowPosition": {
319                     "$ref": "WindowPosition",
320                     "description": "Where to display the candidate window.",
321                     "optional": true
322                   }
323                 }
324               }
325             }
326           },
327           {
328             "type": "function",
329             "name": "callback",
330             "optional": true,
331             "description": "Called when the operation completes.",
332             "parameters": [
333               {
334                 "name": "success",
335                 "type": "boolean"
336               }
337             ]
338           }
339         ]
340       },
341       {
342         "name": "setCandidates",
343         "type": "function",
344         "description": "Sets the current candidate list. This fails if this extension doesn't own the active IME",
345         "parameters": [
346           {
347             "name": "parameters",
348             "type": "object",
349             "properties": {
350               "contextID": {
351                 "description": "ID of the context that owns the candidate window.",
352                 "type": "integer"
353               },
354               "candidates": {
355                 "description": "List of candidates to show in the candidate window",
356                 "type": "array",
357                 "items": {
358                   "type": "object",
359                   "properties": {
360                     "candidate": {"type": "string", "description": "The candidate"},
361                     "id": {"type": "integer", "description": "The candidate's id"},
362                     "parentId": {"type": "integer", "optional": true, "description": "The id to add these candidates under"},
363                     "label": {"type": "string", "optional": true, "description": "Short string displayed to next to the candidate, often the shortcut key or index"},
364                     "annotation": {"type": "string", "optional": true, "description": "Additional text describing the candidate"},
365                     "usage": {
366                       "type": "object",
367                       "optional": true,
368                       "description": "The usage or detail description of word.",
369                       "properties": {
370                         "title": { "type": "string", "description": "The title string of details description."},
371                         "body": { "type": "string", "description": "The body string of detail description."}
372                       }
373                     }
374                   }
375                 }
376               }
377             }
378           },
379           {
380             "type": "function",
381             "name": "callback",
382             "optional": true,
383             "description": "Called when the operation completes.",
384             "parameters": [
385               {
386                 "name": "success",
387                 "type": "boolean"
388               }
389             ]
390           }
391         ]
392       },
393       {
394         "name": "setCursorPosition",
395         "type": "function",
396         "description": "Set the position of the cursor in the candidate window. This is a no-op if this extension does not own the active IME.",
397         "parameters": [
398           {
399             "name": "parameters",
400             "type": "object",
401             "properties": {
402               "contextID": {
403                 "description": "ID of the context that owns the candidate window.",
404                 "type": "integer"
405               },
406               "candidateID": {
407                 "description": "ID of the candidate to select.",
408                 "type": "integer"
409               }
410             }
411           },
412           {
413             "type": "function",
414             "name": "callback",
415             "optional": true,
416             "description": "Called when the operation completes",
417             "parameters": [
418               {
419                 "name": "success",
420                 "type": "boolean"
421               }
422             ]
423           }
424         ]
425       },
426       {
427         "name": "setMenuItems",
428         "type": "function",
429         "description": "Adds the provided menu items to the language menu when this IME is active.",
430         "parameters": [
431           {
432             "name": "parameters",
433             "type": "object",
434             "properties": {
435               "engineID": {
436                 "description": "ID of the engine to use",
437                 "type": "string"
438               },
439               "items": {
440                 "description": "MenuItems to add. They will be added in the order they exist in the array.",
441                 "type": "array",
442                 "items": {
443                   "$ref": "MenuItem"
444                 }
445               }
446             }
447           },
448           {
449             "type": "function",
450             "name": "callback",
451             "optional": true,
452             "description": "",
453             "parameters": []
454           }
455         ]
456       },
457       {
458         "name": "updateMenuItems",
459         "type": "function",
460         "description": "Updates the state of the MenuItems specified",
461         "parameters": [
462           {
463             "name": "parameters",
464             "type": "object",
465             "properties": {
466               "engineID": {
467                 "description": "ID of the engine to use",
468                 "type": "string"
469               },
470               "items": {
471                 "description": "Array of MenuItems to update",
472                 "type": "array",
473                 "items": {
474                   "$ref": "MenuItem"
475                 }
476               }
477             }
478           },
479           {
480             "type": "function",
481             "name": "callback",
482             "optional": true,
483             "description": "Called when the operation completes",
484             "parameters": []
485           }
486         ]
487       },
488       {
489         "name": "deleteSurroundingText",
490         "type": "function",
491         "description": "Deletes the text around the caret.",
492         "parameters": [
493           {
494             "name": "parameters",
495             "type": "object",
496             "properties": {
497               "engineID": {
498                 "type": "string",
499                 "description": "ID of the engine receiving the event."
500               },
501               "contextID": {
502                 "type": "integer",
503                 "description": "ID of the context where the surrounding text will be deleted."
504               },
505               "offset": {
506                 "type": "integer",
507                 "description": "The offset from the caret position where deletion will start. This value can be negative."
508               },
509               "length": {
510                 "type": "integer",
511                 "description": "The number of characters to be deleted",
512                 "minimum": 0
513               }
514             }
515           },
516           {
517             "type": "function",
518             "name": "callback",
519             "optional": true,
520             "description": "Called when the operation completes.",
521             "parameters": []
522           }
523         ]
524       },
525       {
526         "name": "keyEventHandled",
527         "type": "function",
528         "description": "Indicates that the key event received by onKeyEvent is handled.  This should only be called if the onKeyEvent listener is asynchronous.",
529         "parameters": [
530           {"type": "string", "name": "requestId", "description": "Request id of the event that was handled.  This should come from keyEvent.requestId"},
531           {"type": "boolean", "name": "response", "description": "True if the keystroke was handled, false if not"}
532         ]
533       }
534     ],
535     "events": [
536       {
537         "name": "onActivate",
538         "type": "function",
539         "description": "This event is sent when an IME is activated. It signals that the IME will be receiving onKeyPress events.",
540         "parameters": [
541           {
542             "type": "string",
543             "name": "engineID",
544             "description": "ID of the engine receiving the event"
545           },
546           {
547             "name": "screen",
548             "$ref": "ScreenType",
549             "description": "The screen type under which the IME is activated."
550           }
551         ]
552       },
553       {
554         "name": "onDeactivated",
555         "type": "function",
556         "description": "This event is sent when an IME is deactivated. It signals that the IME will no longer be receiving onKeyPress events.",
557         "parameters": [
558           {
559             "type": "string",
560             "name": "engineID",
561             "description": "ID of the engine receiving the event"
562           }
563         ]
564       },
565       {
566         "name": "onFocus",
567         "type": "function",
568         "description": "This event is sent when focus enters a text box. It is sent to all extensions that are listening to this event, and enabled by the user.",
569         "parameters": [
570           {
571             "$ref": "InputContext",
572             "name": "context",
573             "description": "Describes the text field that has acquired focus."
574           }
575         ]
576       },
577       {
578         "name": "onBlur",
579         "type": "function",
580         "description": "This event is sent when focus leaves a text box. It is sent to all extensions that are listening to this event, and enabled by the user.",
581         "parameters": [
582           {
583             "type": "integer",
584             "name": "contextID",
585             "description": "The ID of the text field that has lost focus. The ID is invalid after this call"
586           }
587         ]
588       },
589       {
590         "name": "onInputContextUpdate",
591         "type": "function",
592         "description": "This event is sent when the properties of the current InputContext change, such as the the type. It is sent to all extensions that are listening to this event, and enabled by the user.",
593         "parameters": [
594           {
595             "$ref": "InputContext",
596             "name": "context",
597             "description": "An InputContext object describing the text field that has changed."
598           }
599         ]
600       },
601       {
602         "name": "onKeyEvent",
603         "type": "function",
604         "description": "This event is sent if this extension owns the active IME.",
605         "options": {
606           "supportsFilters": false,
607           "supportsListeners": true,
608           "supportsRules": false,
609           "maxListeners": 1
610         },
611         "parameters": [
612           {
613             "type": "string",
614             "name": "engineID",
615             "description": "ID of the engine receiving the event"
616           },
617           {
618             "$ref": "KeyboardEvent",
619             "name": "keyData",
620             "description": "Data on the key event"
621           }
622         ],
623         "extraParameters": [
624           {
625             "type": "array",
626             "optional": true,
627             "name": "extraInfoSpec",
628             "description": "Array of extra information that specifies how the callback is invoked.",
629             "items": {
630               "$ref": "CallbackStyle"
631             }
632           }
633         ],
634         "returns": {
635           "type": "boolean",
636           "description": "True if the keystroke was handled, false if not.  This function should always return a value if |async| is not specified.",
637           "optional": true
638         }
639       },
640       {
641         "name": "onCandidateClicked",
642         "type": "function",
643         "description": "This event is sent if this extension owns the active IME.",
644         "parameters": [
645           {
646             "type": "string",
647             "name": "engineID",
648             "description": "ID of the engine receiving the event"
649           },
650           {
651             "type": "integer",
652             "name": "candidateID",
653             "description": "ID of the candidate that was clicked."
654           },
655           {
656             "name": "button",
657             "$ref": "MouseButton",
658             "description": "Which mouse buttons was clicked."
659           }
660         ]
661       },
662       {
663         "name": "onMenuItemActivated",
664         "type": "function",
665         "description": "Called when the user selects a menu item",
666         "parameters": [
667           {
668             "type": "string",
669             "name": "engineID",
670             "description": "ID of the engine receiving the event"
671           },
672           {
673             "type": "string",
674             "name": "name",
675             "description": "Name of the MenuItem which was activated"
676           }
677         ]
678       },
679       {
680         "name": "onSurroundingTextChanged",
681         "type": "function",
682         "description": "Called when the editable string around caret is changed or when the caret position is moved. The text length is limited to 100 characters for each back and forth direction.",
683         "parameters": [
684           {
685             "type": "string",
686             "name": "engineID",
687             "description": "ID of the engine receiving the event"
688           },
689           {
690             "type": "object",
691             "name": "surroundingInfo",
692             "description": "The surrounding information.",
693             "properties": {
694               "text": {
695                 "type": "string",
696                 "description": "The text around cursor."
697               },
698               "focus": {
699                 "type": "integer",
700                 "description": "The ending position of the selection. This value indicates caret position if there is no selection."
701               },
702               "anchor": {
703                 "type": "integer",
704                 "description": "The beginning position of the selection. This value indicates caret position if is no selection."
705               }
706             }
707           }
708         ]
709       },
710       {
711         "name": "onReset",
712         "type": "function",
713         "description": "This event is sent when chrome terminates ongoing text input session.",
714         "parameters": [
715           {
716             "type": "string",
717             "name": "engineID",
718             "description": "ID of the engine receiving the event"
719           }
720         ]
721       }
722     ]
723   }