input_method_private.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. // Copyright 2022 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.
  4. // This file was generated by:
  5. // tools/json_schema_compiler/compiler.py.
  6. // NOTE: The format of types has changed. 'FooType' is now
  7. // 'chrome.inputMethodPrivate.FooType'.
  8. // Please run the closure compiler before committing changes.
  9. // See https://chromium.googlesource.com/chromium/src/+/main/docs/closure_compilation.md
  10. /** @fileoverview Externs generated from namespace: inputMethodPrivate */
  11. /** @const */
  12. chrome.inputMethodPrivate = {};
  13. /**
  14. * @enum {string}
  15. */
  16. chrome.inputMethodPrivate.MenuItemStyle = {
  17. CHECK: 'check',
  18. RADIO: 'radio',
  19. SEPARATOR: 'separator',
  20. };
  21. /**
  22. * A menu item used by an input method to interact with the user from the language menu.
  23. * @typedef {{
  24. * id: string,
  25. * label: (string|undefined),
  26. * style: (!chrome.inputMethodPrivate.MenuItemStyle|undefined),
  27. * visible: (boolean|undefined),
  28. * checked: (boolean|undefined),
  29. * enabled: (boolean|undefined)
  30. * }}
  31. */
  32. chrome.inputMethodPrivate.MenuItem;
  33. /**
  34. * @enum {string}
  35. */
  36. chrome.inputMethodPrivate.UnderlineStyle = {
  37. UNDERLINE: 'underline',
  38. DOUBLE_UNDERLINE: 'doubleUnderline',
  39. NO_UNDERLINE: 'noUnderline',
  40. };
  41. /**
  42. * @enum {string}
  43. */
  44. chrome.inputMethodPrivate.FocusReason = {
  45. MOUSE: 'mouse',
  46. TOUCH: 'touch',
  47. PEN: 'pen',
  48. OTHER: 'other',
  49. };
  50. /**
  51. * @enum {string}
  52. */
  53. chrome.inputMethodPrivate.InputModeType = {
  54. NO_KEYBOARD: 'noKeyboard',
  55. TEXT: 'text',
  56. TEL: 'tel',
  57. URL: 'url',
  58. EMAIL: 'email',
  59. NUMERIC: 'numeric',
  60. DECIMAL: 'decimal',
  61. SEARCH: 'search',
  62. };
  63. /**
  64. * @enum {string}
  65. */
  66. chrome.inputMethodPrivate.InputContextType = {
  67. TEXT: 'text',
  68. SEARCH: 'search',
  69. TEL: 'tel',
  70. URL: 'url',
  71. EMAIL: 'email',
  72. NUMBER: 'number',
  73. PASSWORD: 'password',
  74. NULL: 'null',
  75. };
  76. /**
  77. * @enum {string}
  78. */
  79. chrome.inputMethodPrivate.AutoCapitalizeType = {
  80. OFF: 'off',
  81. CHARACTERS: 'characters',
  82. WORDS: 'words',
  83. SENTENCES: 'sentences',
  84. };
  85. /**
  86. * Describes an input Context
  87. * @typedef {{
  88. * contextID: number,
  89. * type: !chrome.inputMethodPrivate.InputContextType,
  90. * mode: !chrome.inputMethodPrivate.InputModeType,
  91. * autoCorrect: boolean,
  92. * autoComplete: boolean,
  93. * autoCapitalize: !chrome.inputMethodPrivate.AutoCapitalizeType,
  94. * spellCheck: boolean,
  95. * shouldDoLearning: boolean,
  96. * focusReason: !chrome.inputMethodPrivate.FocusReason,
  97. * hasBeenPassword: boolean,
  98. * appKey: (string|undefined)
  99. * }}
  100. */
  101. chrome.inputMethodPrivate.InputContext;
  102. /**
  103. * User preference settings for a specific input method. Japanese input methods are not included because they are managed separately by Mozc module.
  104. * @typedef {{
  105. * enableCompletion: (boolean|undefined),
  106. * enableDoubleSpacePeriod: (boolean|undefined),
  107. * enableGestureTyping: (boolean|undefined),
  108. * enablePrediction: (boolean|undefined),
  109. * enableSoundOnKeypress: (boolean|undefined),
  110. * physicalKeyboardAutoCorrectionLevel: (number|undefined),
  111. * physicalKeyboardEnableCapitalization: (boolean|undefined),
  112. * virtualKeyboardAutoCorrectionLevel: (number|undefined),
  113. * virtualKeyboardEnableCapitalization: (boolean|undefined),
  114. * xkbLayout: (string|undefined),
  115. * koreanEnableSyllableInput: (boolean|undefined),
  116. * koreanKeyboardLayout: (string|undefined),
  117. * koreanShowHangulCandidate: (boolean|undefined),
  118. * pinyinChinesePunctuation: (boolean|undefined),
  119. * pinyinDefaultChinese: (boolean|undefined),
  120. * pinyinEnableFuzzy: (boolean|undefined),
  121. * pinyinEnableLowerPaging: (boolean|undefined),
  122. * pinyinEnableUpperPaging: (boolean|undefined),
  123. * pinyinFullWidthCharacter: (boolean|undefined),
  124. * pinyinFuzzyConfig: ({
  125. * an_ang: (boolean|undefined),
  126. * c_ch: (boolean|undefined),
  127. * en_eng: (boolean|undefined),
  128. * f_h: (boolean|undefined),
  129. * ian_iang: (boolean|undefined),
  130. * in_ing: (boolean|undefined),
  131. * k_g: (boolean|undefined),
  132. * l_n: (boolean|undefined),
  133. * r_l: (boolean|undefined),
  134. * s_sh: (boolean|undefined),
  135. * uan_uang: (boolean|undefined),
  136. * z_zh: (boolean|undefined)
  137. * }|undefined),
  138. * zhuyinKeyboardLayout: (string|undefined),
  139. * zhuyinPageSize: (number|undefined),
  140. * zhuyinSelectKeys: (string|undefined)
  141. * }}
  142. */
  143. chrome.inputMethodPrivate.InputMethodSettings;
  144. /**
  145. * Gets configurations for input methods.
  146. * @param {function({
  147. * isPhysicalKeyboardAutocorrectEnabled: boolean,
  148. * isImeMenuActivated: boolean
  149. * }): void} callback Callback which is called with the config object.
  150. */
  151. chrome.inputMethodPrivate.getInputMethodConfig = function(callback) {};
  152. /**
  153. * Gets all enabled input methods, sorted in ascending order of their localized
  154. * full display names, according to the lexicographical order defined by the
  155. * current system locale aka. display language.
  156. * @param {function(!Array<{
  157. * id: string,
  158. * name: string,
  159. * indicator: string
  160. * }>): void} callback Callback which is called with the input method objects.
  161. */
  162. chrome.inputMethodPrivate.getInputMethods = function(callback) {};
  163. /**
  164. * Gets the current input method.
  165. * @param {function(string): void} callback Callback which is called with the
  166. * current input method.
  167. */
  168. chrome.inputMethodPrivate.getCurrentInputMethod = function(callback) {};
  169. /**
  170. * Sets the current input method.
  171. * @param {string} inputMethodId The input method ID to be set as current input
  172. * method.
  173. * @param {function(): void=} callback Callback which is called once the current
  174. * input method is set. If unsuccessful $(ref:runtime.lastError) is set.
  175. */
  176. chrome.inputMethodPrivate.setCurrentInputMethod = function(inputMethodId, callback) {};
  177. /**
  178. * Switches to the last used input method. If no last used input method, this is
  179. * a no-op.
  180. * @param {function(): void=} callback Callback which is called once the input
  181. * method is swapped (if applicable). If unsuccessful
  182. * $(ref:runtime.lastError) is set.
  183. */
  184. chrome.inputMethodPrivate.switchToLastUsedInputMethod = function(callback) {};
  185. /**
  186. * Fetches a list of all the words currently in the dictionary.
  187. * @param {function(!Array<string>): void} callback Callback which is called
  188. * once the list of dictionary words are ready.
  189. */
  190. chrome.inputMethodPrivate.fetchAllDictionaryWords = function(callback) {};
  191. /**
  192. * Adds a single word to be stored in the dictionary.
  193. * @param {string} word A new word to add to the dictionary.
  194. * @param {function(): void=} callback Callback which is called once the word is
  195. * added. If unsuccessful $(ref:runtime.lastError) is set.
  196. */
  197. chrome.inputMethodPrivate.addWordToDictionary = function(word, callback) {};
  198. /**
  199. * Gets whether the encrypt sync is enabled.
  200. * @param {function(boolean): void=} callback Callback which is called to
  201. * provide the result.
  202. */
  203. chrome.inputMethodPrivate.getEncryptSyncEnabled = function(callback) {};
  204. /**
  205. * Sets the XKB layout for the given input method.
  206. * @param {string} xkb_name The XKB layout name.
  207. * @param {function(): void=} callback Callback which is called when the layout
  208. * is set.
  209. */
  210. chrome.inputMethodPrivate.setXkbLayout = function(xkb_name, callback) {};
  211. /**
  212. * Commits the text currently being composed without moving the selected text
  213. * range. This is a no-op if the context is incorrect.
  214. * @param {{
  215. * contextID: number
  216. * }} parameters
  217. * @param {function(): void=} callback Called when the operation completes.
  218. */
  219. chrome.inputMethodPrivate.finishComposingText = function(parameters, callback) {};
  220. /**
  221. * Sets the selection range
  222. * @param {{
  223. * contextID: number,
  224. * selectionStart: (number|undefined),
  225. * selectionEnd: (number|undefined)
  226. * }} parameters
  227. * @param {function(boolean): void=} callback Called when the operation
  228. * completes with a boolean indicating if the text was accepted or not.
  229. */
  230. chrome.inputMethodPrivate.setSelectionRange = function(parameters, callback) {};
  231. /**
  232. * Fires the input.ime.onMenuItemActivated event.
  233. * @param {string} engineID ID of the engine to use.
  234. * @param {string} name Name of the MenuItem which was activated
  235. */
  236. chrome.inputMethodPrivate.notifyImeMenuItemActivated = function(engineID, name) {};
  237. /**
  238. * Shows the input view window. If the input view window is already shown, this
  239. * function will do nothing.
  240. * @param {function(): void=} callback Called when the operation completes.
  241. */
  242. chrome.inputMethodPrivate.showInputView = function(callback) {};
  243. /**
  244. * Hides the input view window. If the input view window is already hidden, this
  245. * function will do nothing.
  246. * @param {function(): void=} callback Called when the operation completes.
  247. */
  248. chrome.inputMethodPrivate.hideInputView = function(callback) {};
  249. /**
  250. * Opens the options page for the input method extension. If the input method
  251. * does not have options, this function will do nothing.
  252. * @param {string} inputMethodId ID of the input method to open options for.
  253. */
  254. chrome.inputMethodPrivate.openOptionsPage = function(inputMethodId) {};
  255. /**
  256. * Gets the composition bounds
  257. * @param {function(!Array<{
  258. * x: number,
  259. * y: number,
  260. * w: number,
  261. * h: number
  262. * }>): void} callback Callback which is called to provide the result
  263. */
  264. chrome.inputMethodPrivate.getCompositionBounds = function(callback) {};
  265. /**
  266. * Gets the surrounding text of the current selection. WARNING: This could
  267. * return a stale cache that doesn't reflect reality, due to async between IMF
  268. * and TextInputClient.
  269. * @param {number} beforeLength The number of characters before the current
  270. * selection.
  271. * @param {number} afterLength The number of characters after the current
  272. * selection.
  273. * @param {function({
  274. * before: string,
  275. * selected: string,
  276. * after: string
  277. * }): void} callback Callback which is called to provide the result
  278. */
  279. chrome.inputMethodPrivate.getSurroundingText = function(beforeLength, afterLength, callback) {};
  280. /**
  281. * Gets the current values of all settings for a particular input method
  282. * @param {string} engineID The ID of the engine (e.g. 'zh-t-i0-pinyin',
  283. * 'xkb:us::eng')
  284. * @param {function((!chrome.inputMethodPrivate.InputMethodSettings|undefined)): void}
  285. * callback Callback to receive the settings
  286. */
  287. chrome.inputMethodPrivate.getSettings = function(engineID, callback) {};
  288. /**
  289. * Sets the value of all settings for a particular input method
  290. * @param {string} engineID The ID of the engine (e.g. 'zh-t-i0-pinyin',
  291. * 'xkb:us::eng')
  292. * @param {!chrome.inputMethodPrivate.InputMethodSettings} settings The settings
  293. * to set
  294. * @param {function(): void=} callback Callback to notify that the new value has
  295. * been set
  296. */
  297. chrome.inputMethodPrivate.setSettings = function(engineID, settings, callback) {};
  298. /**
  299. * (Deprecated) Set the composition range. If this extension does not own the
  300. * active IME, this fails. Use setComposingRange instead.
  301. * @param {{
  302. * contextID: number,
  303. * selectionBefore: number,
  304. * selectionAfter: number,
  305. * segments: (!Array<{
  306. * start: number,
  307. * end: number,
  308. * style: !chrome.inputMethodPrivate.UnderlineStyle
  309. * }>|undefined)
  310. * }} parameters
  311. * @param {function(boolean): void=} callback Called when the operation
  312. * completes with a boolean indicating if the text was accepted or not. On
  313. * failure, $(ref:runtime.lastError) is set.
  314. */
  315. chrome.inputMethodPrivate.setCompositionRange = function(parameters, callback) {};
  316. /**
  317. * Sets the composing range. If this extension does not own the active IME, this
  318. * fails.
  319. * @param {{
  320. * contextID: number,
  321. * start: number,
  322. * end: number,
  323. * segments: (!Array<{
  324. * start: number,
  325. * end: number,
  326. * style: !chrome.inputMethodPrivate.UnderlineStyle
  327. * }>|undefined)
  328. * }} parameters
  329. * @param {function(): void=} callback Called when the operation is complete. On
  330. * failure, $(ref:runtime.lastError) is set.
  331. */
  332. chrome.inputMethodPrivate.setComposingRange = function(parameters, callback) {};
  333. /**
  334. * Get the autocorrected word's bounds. Returns an empty range if there is no
  335. * autocorrected word.
  336. * @param {{
  337. * contextID: number
  338. * }} parameters
  339. * @param {function({
  340. * start: number,
  341. * end: number
  342. * }): void} callback Called with the bounds of the autocorrect word when the
  343. * operation completes. On failure, $(ref:runtime.lastError) is set.
  344. */
  345. chrome.inputMethodPrivate.getAutocorrectRange = function(parameters, callback) {};
  346. /**
  347. * Get the screen coordinates of the autocorrected word's bounds.
  348. * @param {{
  349. * contextID: number
  350. * }} parameters
  351. * @param {function({
  352. * x: number,
  353. * y: number,
  354. * width: number,
  355. * height: number
  356. * }): void} callback Called with screen coordinates of the autocorrect word
  357. * when the operation completes. On failure, $(ref:runtime.lastError) is
  358. * set.
  359. */
  360. chrome.inputMethodPrivate.getAutocorrectCharacterBounds = function(parameters, callback) {};
  361. /**
  362. * Set the autocorrect range and autocorrect word. If this extension does not
  363. * own the active IME, this fails.
  364. * @param {{
  365. * contextID: number,
  366. * autocorrectString: string,
  367. * selectionStart: number,
  368. * selectionEnd: number
  369. * }} parameters
  370. * @param {function(): void=} callback Called when the operation completes. On
  371. * failure, chrome.runtime.lastError is set.
  372. */
  373. chrome.inputMethodPrivate.setAutocorrectRange = function(parameters, callback) {};
  374. /**
  375. * Resets the current engine to its initial state. Fires an OnReset event.
  376. */
  377. chrome.inputMethodPrivate.reset = function() {};
  378. /**
  379. * Called after a word has been autocorrected to show some UI for autocorrect.
  380. * @param {{
  381. * contextID: number,
  382. * typedWord: string,
  383. * correctedWord: string,
  384. * startIndex: number
  385. * }} parameters
  386. */
  387. chrome.inputMethodPrivate.onAutocorrect = function(parameters) {};
  388. /**
  389. * Get the bounds of the current text field
  390. * @param {{
  391. * contextID: number
  392. * }} parameters
  393. * @param {function({
  394. * x: number,
  395. * y: number,
  396. * width: number,
  397. * height: number
  398. * }): void} callback Called with screen coordinates of the text field when the
  399. * operation completes. On failure, $(ref:runtime.lastError) is set.
  400. */
  401. chrome.inputMethodPrivate.getTextFieldBounds = function(parameters, callback) {};
  402. /**
  403. * Fired when the caret bounds change.
  404. * @type {!ChromeEvent}
  405. */
  406. chrome.inputMethodPrivate.onCaretBoundsChanged;
  407. /**
  408. * Fired when the input method is changed.
  409. * @type {!ChromeEvent}
  410. */
  411. chrome.inputMethodPrivate.onChanged;
  412. /**
  413. * Fired when the composition bounds or cursor bounds are changed.
  414. * @type {!ChromeEvent}
  415. */
  416. chrome.inputMethodPrivate.onCompositionBoundsChanged;
  417. /**
  418. * Fired when the custom spelling dictionary is loaded.
  419. * @type {!ChromeEvent}
  420. */
  421. chrome.inputMethodPrivate.onDictionaryLoaded;
  422. /**
  423. * Fired when words are added or removed from the custom spelling dictionary.
  424. * @type {!ChromeEvent}
  425. */
  426. chrome.inputMethodPrivate.onDictionaryChanged;
  427. /**
  428. * Fired when the IME menu is activated or deactivated.
  429. * @type {!ChromeEvent}
  430. */
  431. chrome.inputMethodPrivate.onImeMenuActivationChanged;
  432. /**
  433. * Fired when the input method or the list of active input method IDs is
  434. * changed.
  435. * @type {!ChromeEvent}
  436. */
  437. chrome.inputMethodPrivate.onImeMenuListChanged;
  438. /**
  439. * Fired when the input.ime.setMenuItems or input.ime.updateMenuItems API is
  440. * called.
  441. * @type {!ChromeEvent}
  442. */
  443. chrome.inputMethodPrivate.onImeMenuItemsChanged;
  444. /**
  445. * This event is sent when focus enters a text box. It is sent to all extensions
  446. * that are listening to this event, and enabled by the user.
  447. * @type {!ChromeEvent}
  448. */
  449. chrome.inputMethodPrivate.onFocus;
  450. /**
  451. * This event is sent when a touch occurs in a text field. Should only happen
  452. * after onFocus()
  453. * @type {!ChromeEvent}
  454. */
  455. chrome.inputMethodPrivate.onTouch;
  456. /**
  457. * This event is sent when the settings for any input method changed. It is sent
  458. * to all extensions that are listening to this event, and enabled by the user.
  459. * @type {!ChromeEvent}
  460. */
  461. chrome.inputMethodPrivate.onSettingsChanged;
  462. /**
  463. * This event is sent when the screen is being mirrored or the desktop is being
  464. * cast.
  465. * @type {!ChromeEvent}
  466. */
  467. chrome.inputMethodPrivate.onScreenProjectionChanged;
  468. /**
  469. * This event is sent when a new set of suggestions has been generated
  470. * @type {!ChromeEvent}
  471. */
  472. chrome.inputMethodPrivate.onSuggestionsChanged;
  473. /**
  474. * This event is sent when input method options are changed.
  475. * @type {!ChromeEvent}
  476. */
  477. chrome.inputMethodPrivate.onInputMethodOptionsChanged;