OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 // Use the <code>chrome.languageSettingsPrivate</code> API to get or change | 5 // Use the <code>chrome.languageSettingsPrivate</code> API to get or change |
6 // language and input method settings. | 6 // language and input method settings. |
7 namespace languageSettingsPrivate { | 7 namespace languageSettingsPrivate { |
8 // Status of a spell check dictionary download. | |
9 enum DownloadStatus { DOWNLOADED, DOWNLOADING, FAILURE }; | |
10 | |
11 dictionary Language { | 8 dictionary Language { |
12 // The unique code identifying the language. | 9 // The unique code identifying the language. |
13 DOMString code; | 10 DOMString code; |
14 | 11 |
15 // The name of the language, in the current UI language. | 12 // The name of the language, in the current UI language. |
16 DOMString displayName; | 13 DOMString displayName; |
17 | 14 |
18 // The name of the language as it is in its own language. | 15 // The name of the language as it is in its own language. |
19 DOMString nativeDisplayName; | 16 DOMString nativeDisplayName; |
20 | 17 |
21 // Whether the directionality is RTL. Defaults to false. | 18 // Whether the display name has RTL. Defaults to false. |
22 boolean? rtl; | 19 boolean? displayNameRTL; |
23 | 20 |
24 // Whether the UI can be displayed in this language. Defaults to false. | 21 // Whether the UI can be displayed in this language. Defaults to false. |
25 boolean? supportsUI; | 22 boolean? supportsUI; |
26 | 23 |
27 // Whether this language can be used for spell checking. Defaults to false. | 24 // Whether this language can be used for spell checking. Defaults to false. |
28 boolean? supportsSpellCheck; | 25 boolean? supportsSpellcheck; |
29 | 26 |
30 // Whether this language has translations for the current target language. | 27 // Whether this language has translations for the current target language. |
31 // Defaults to false. | 28 // Defaults to false. |
32 boolean? supportsTranslate; | 29 boolean? supportsTranslate; |
33 }; | 30 }; |
34 | 31 |
35 dictionary SpellCheckDictionaryStatus { | 32 dictionary SpellcheckDictionaryStatus { |
36 // The language code of the dictionary that the status describes. | 33 // The language code of the dictionary that the status describes. |
37 DOMString languageCode; | 34 DOMString languageCode; |
38 | 35 |
39 // The download status of the dictionary. | 36 // Whether the dictionary is ready (has been loaded from disk or |
40 DownloadStatus status; | 37 // successfully downloaded). |
| 38 boolean isReady; |
| 39 |
| 40 // Whether the dictionary is being downloaded. Defaults to false. |
| 41 boolean? isDownloading; |
| 42 |
| 43 // Whether the dictionary download failed. Defaults to false. |
| 44 boolean? downloadFailed; |
41 }; | 45 }; |
42 | 46 |
43 dictionary InputMethod { | 47 dictionary InputMethod { |
44 // The ID of the input method descriptor. | 48 // The ID of the input method descriptor. |
45 DOMString id; | 49 DOMString id; |
46 | 50 |
47 // The human-readable name of the input method. | 51 // The human-readable name of the input method. |
48 DOMString displayName; | 52 DOMString displayName; |
49 | 53 |
50 // The language codes this input method supports. | 54 // The language codes this input method supports. |
51 DOMString[] languageCodes; | 55 DOMString[] languageCodes; |
52 | 56 |
53 // True if the input method is enabled. | 57 // True if the input method is enabled. |
54 boolean enabled; | 58 boolean enabled; |
55 }; | 59 }; |
56 | 60 |
57 dictionary InputMethodLists { | 61 dictionary InputMethodLists { |
58 // The list of built-in input methods. | 62 // The list of built-in input methods. |
59 InputMethod[] inputMethods; | 63 InputMethod[] inputMethods; |
60 | 64 |
61 // The list of component extension input methods. | 65 // The list of component extension input methods. |
62 InputMethod[] componentExtensionIMEs; | 66 InputMethod[] componentExtensionIMEs; |
63 | 67 |
64 // The list of third-party extension input methods. | 68 // The list of third-party extension input methods. |
65 InputMethod[] thirdPartyExtensionIMEs; | 69 InputMethod[] thirdPartyExtensionIMEs; |
66 }; | 70 }; |
67 | 71 |
68 callback GetLanguageListCallback = void (Language[] languages); | 72 callback GetLanguageListCallback = void (Language[] languages); |
69 callback GetInputMethodListsCallback = void (InputMethodLists lists); | 73 callback GetInputMethodListsCallback = void (InputMethodLists lists); |
70 callback GetSpellCheckWordsCallback = void (DOMString[] words); | 74 callback GetSpellcheckWordsCallback = void (DOMString[] words); |
71 callback GetTranslateTargetLanguageCallback = void (DOMString languageCode); | 75 callback GetTranslateTargetLanguageCallback = void (DOMString languageCode); |
72 callback GetSpellCheckDictionaryStatusCallback = | 76 callback GetSpellcheckDictionaryStatusesCallback = |
73 void (SpellCheckDictionaryStatus status); | 77 void (SpellcheckDictionaryStatus[] status); |
74 callback InputMethodAddedRemovedCallback = void (DOMString inputMethodId); | |
75 | 78 |
76 interface Functions { | 79 interface Functions { |
77 // Gets languages available for translate, spell checking, input and locale. | 80 // Gets languages available for translate, spell checking, input and locale. |
78 static void getLanguageList(GetLanguageListCallback callback); | 81 static void getLanguageList(GetLanguageListCallback callback); |
79 | 82 |
80 // Sets the accepted languages, used to decide which languages to translate, | 83 // Sets the accepted languages, used to decide which languages to translate, |
81 // generate the Accept-Language header, etc. | 84 // generate the Accept-Language header, etc. |
82 static void setLanguageList(DOMString[] languageCodes); | 85 static void setLanguageList(DOMString[] languageCodes); |
83 | 86 |
84 // Gets the current status of the spell check dictionary. | 87 // Gets the current status of the chosen spell check dictionaries. |
85 static void getSpellCheckDictionaryStatus( | 88 static void getSpellcheckDictionaryStatuses( |
86 GetSpellCheckDictionaryStatusCallback callback); | 89 GetSpellcheckDictionaryStatusesCallback callback); |
87 | 90 |
88 // Gets the custom spell check words. | 91 // Gets the custom spell check words. |
89 static void getSpellCheckWords(GetSpellCheckWordsCallback callback); | 92 static void getSpellcheckWords(GetSpellcheckWordsCallback callback); |
90 | 93 |
91 // Gets the translate target language (in most cases, the display locale). | 94 // Gets the translate target language (in most cases, the display locale). |
92 static void getTranslateTargetLanguage( | 95 static void getTranslateTargetLanguage( |
93 GetTranslateTargetLanguageCallback callback); | 96 GetTranslateTargetLanguageCallback callback); |
94 | 97 |
95 // Gets all supported input methods, including IMEs. Chrome OS only. | 98 // Gets all supported input methods, including IMEs. Chrome OS only. |
96 static void getInputMethodLists(GetInputMethodListsCallback callback); | 99 static void getInputMethodLists(GetInputMethodListsCallback callback); |
97 | 100 |
98 // Adds the input method to the current user's list of enabled input | 101 // Adds the input method to the current user's list of enabled input |
99 // methods, enabling the input method for the current user. Chrome OS only. | 102 // methods, enabling the input method for the current user. Chrome OS only. |
100 static void addInputMethod(DOMString inputMethodId); | 103 static void addInputMethod(DOMString inputMethodId); |
101 | 104 |
102 // Removes the input method from the current user's list of enabled input | 105 // Removes the input method from the current user's list of enabled input |
103 // methods, disabling the input method for the current user. Chrome OS only. | 106 // methods, disabling the input method for the current user. Chrome OS only. |
104 static void removeInputMethod(DOMString inputMethodId); | 107 static void removeInputMethod(DOMString inputMethodId); |
105 }; | 108 }; |
106 | 109 |
107 interface Events { | 110 interface Events { |
108 // Called when the language used for spell checking changes or the | 111 // Called when the pref for the dictionaries used for spell checking changes |
109 // dictionary download status changes. | 112 // or the status of one of the spell check dictionaries changes. |
110 static void onSpellCheckDictionaryChanged( | 113 static void onSpellcheckDictionariesChanged( |
111 GetSpellCheckDictionaryStatusCallback callback); | 114 SpellcheckDictionaryStatus[] statuses); |
| 115 |
| 116 // Called when words are added to and/or removed from the custom spell check |
| 117 // dictionary. |
| 118 static void onCustomDictionaryChanged( |
| 119 DOMString[] wordsAdded, DOMString[] wordsRemoved); |
112 | 120 |
113 // Called when an input method is added. | 121 // Called when an input method is added. |
114 static void onInputMethodAdded( | 122 static void onInputMethodAdded(DOMString inputMethodId); |
115 InputMethodAddedRemovedCallback callback); | |
116 | 123 |
117 // Called when an input method is removed. | 124 // Called when an input method is removed. |
118 static void onInputMethodRemoved( | 125 static void onInputMethodRemoved(DOMString inputMethodId); |
119 InputMethodAddedRemovedCallback callback); | |
120 }; | 126 }; |
121 }; | 127 }; |
OLD | NEW |