OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_INPUT_METHOD_API_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_INPUT_METHOD_API_H_ |
6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_INPUT_METHOD_API_H_ | 6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_INPUT_METHOD_API_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "chrome/common/extensions/api/input_method_private.h" |
11 #include "extensions/browser/browser_context_keyed_api_factory.h" | 12 #include "extensions/browser/browser_context_keyed_api_factory.h" |
12 #include "extensions/browser/event_router.h" | 13 #include "extensions/browser/event_router.h" |
13 #include "extensions/browser/extension_function.h" | 14 #include "extensions/browser/extension_function.h" |
14 | 15 |
15 namespace chromeos { | 16 namespace chromeos { |
16 class ExtensionDictionaryEventRouter; | 17 class ExtensionDictionaryEventRouter; |
17 class ExtensionInputMethodEventRouter; | 18 class ExtensionInputMethodEventRouter; |
18 } | 19 } |
19 | 20 |
20 namespace extensions { | 21 namespace extensions { |
21 | 22 |
22 // Implements the inputMethodPrivate.getInputMethodConfig method. | 23 // Implements the inputMethodPrivate.getInputMethodConfig method. |
23 class GetInputMethodConfigFunction : public UIThreadExtensionFunction { | 24 class InputMethodPrivateGetInputMethodConfigFunction |
| 25 : public UIThreadExtensionFunction { |
24 public: | 26 public: |
25 GetInputMethodConfigFunction() {} | 27 InputMethodPrivateGetInputMethodConfigFunction() {} |
26 | 28 |
27 protected: | 29 protected: |
28 ~GetInputMethodConfigFunction() override {} | 30 ~InputMethodPrivateGetInputMethodConfigFunction() override {} |
29 | 31 |
30 ResponseAction Run() override; | 32 ResponseAction Run() override; |
31 | 33 |
32 private: | 34 private: |
33 DECLARE_EXTENSION_FUNCTION("inputMethodPrivate.getInputMethodConfig", | 35 DECLARE_EXTENSION_FUNCTION("inputMethodPrivate.getInputMethodConfig", |
34 INPUTMETHODPRIVATE_GETINPUTMETHODCONFIG) | 36 INPUTMETHODPRIVATE_GETINPUTMETHODCONFIG) |
35 DISALLOW_COPY_AND_ASSIGN(GetInputMethodConfigFunction); | 37 DISALLOW_COPY_AND_ASSIGN(InputMethodPrivateGetInputMethodConfigFunction); |
36 }; | 38 }; |
37 | 39 |
38 // Implements the inputMethodPrivate.getCurrentInputMethod method. | 40 // Implements the inputMethodPrivate.getCurrentInputMethod method. |
39 class GetCurrentInputMethodFunction : public UIThreadExtensionFunction { | 41 class InputMethodPrivateGetCurrentInputMethodFunction |
| 42 : public UIThreadExtensionFunction { |
40 public: | 43 public: |
41 GetCurrentInputMethodFunction() {} | 44 InputMethodPrivateGetCurrentInputMethodFunction() {} |
42 | 45 |
43 protected: | 46 protected: |
44 ~GetCurrentInputMethodFunction() override {} | 47 ~InputMethodPrivateGetCurrentInputMethodFunction() override {} |
45 | 48 |
46 ResponseAction Run() override; | 49 ResponseAction Run() override; |
47 | 50 |
48 private: | 51 private: |
49 DECLARE_EXTENSION_FUNCTION("inputMethodPrivate.getCurrentInputMethod", | 52 DECLARE_EXTENSION_FUNCTION("inputMethodPrivate.getCurrentInputMethod", |
50 INPUTMETHODPRIVATE_GETCURRENTINPUTMETHOD) | 53 INPUTMETHODPRIVATE_GETCURRENTINPUTMETHOD) |
51 DISALLOW_COPY_AND_ASSIGN(GetCurrentInputMethodFunction); | 54 DISALLOW_COPY_AND_ASSIGN(InputMethodPrivateGetCurrentInputMethodFunction); |
52 }; | 55 }; |
53 | 56 |
54 // Implements the inputMethodPrivate.setCurrentInputMethod method. | 57 // Implements the inputMethodPrivate.setCurrentInputMethod method. |
55 class SetCurrentInputMethodFunction : public UIThreadExtensionFunction { | 58 class InputMethodPrivateSetCurrentInputMethodFunction |
| 59 : public UIThreadExtensionFunction { |
56 public: | 60 public: |
57 SetCurrentInputMethodFunction() {} | 61 InputMethodPrivateSetCurrentInputMethodFunction() {} |
58 | 62 |
59 protected: | 63 protected: |
60 ~SetCurrentInputMethodFunction() override {} | 64 ~InputMethodPrivateSetCurrentInputMethodFunction() override {} |
61 | 65 |
62 ResponseAction Run() override; | 66 ResponseAction Run() override; |
63 | 67 |
64 private: | 68 private: |
65 DECLARE_EXTENSION_FUNCTION("inputMethodPrivate.setCurrentInputMethod", | 69 DECLARE_EXTENSION_FUNCTION("inputMethodPrivate.setCurrentInputMethod", |
66 INPUTMETHODPRIVATE_SETCURRENTINPUTMETHOD) | 70 INPUTMETHODPRIVATE_SETCURRENTINPUTMETHOD) |
67 DISALLOW_COPY_AND_ASSIGN(SetCurrentInputMethodFunction); | 71 DISALLOW_COPY_AND_ASSIGN(InputMethodPrivateSetCurrentInputMethodFunction); |
68 }; | 72 }; |
69 | 73 |
70 // Implements the inputMethodPrivate.getInputMethods method. | 74 // Implements the inputMethodPrivate.getInputMethods method. |
71 class GetInputMethodsFunction : public UIThreadExtensionFunction { | 75 class InputMethodPrivateGetInputMethodsFunction |
| 76 : public UIThreadExtensionFunction { |
72 public: | 77 public: |
73 GetInputMethodsFunction() {} | 78 InputMethodPrivateGetInputMethodsFunction() {} |
74 | 79 |
75 protected: | 80 protected: |
76 ~GetInputMethodsFunction() override {} | 81 ~InputMethodPrivateGetInputMethodsFunction() override {} |
77 | 82 |
78 ResponseAction Run() override; | 83 ResponseAction Run() override; |
79 | 84 |
80 private: | 85 private: |
81 DECLARE_EXTENSION_FUNCTION("inputMethodPrivate.getInputMethods", | 86 DECLARE_EXTENSION_FUNCTION("inputMethodPrivate.getInputMethods", |
82 INPUTMETHODPRIVATE_GETINPUTMETHODS) | 87 INPUTMETHODPRIVATE_GETINPUTMETHODS) |
83 DISALLOW_COPY_AND_ASSIGN(GetInputMethodsFunction); | 88 DISALLOW_COPY_AND_ASSIGN(InputMethodPrivateGetInputMethodsFunction); |
84 }; | 89 }; |
85 | 90 |
86 // Implements the inputMethodPrivate.fetchAllDictionaryWords method. | 91 // Implements the inputMethodPrivate.fetchAllDictionaryWords method. |
87 class FetchAllDictionaryWordsFunction : public UIThreadExtensionFunction { | 92 class InputMethodPrivateFetchAllDictionaryWordsFunction |
| 93 : public UIThreadExtensionFunction { |
88 public: | 94 public: |
89 FetchAllDictionaryWordsFunction() {} | 95 InputMethodPrivateFetchAllDictionaryWordsFunction() {} |
90 | 96 |
91 protected: | 97 protected: |
92 ~FetchAllDictionaryWordsFunction() override {} | 98 ~InputMethodPrivateFetchAllDictionaryWordsFunction() override {} |
93 | 99 |
94 ResponseAction Run() override; | 100 ResponseAction Run() override; |
95 | 101 |
96 private: | 102 private: |
97 DECLARE_EXTENSION_FUNCTION("inputMethodPrivate.fetchAllDictionaryWords", | 103 DECLARE_EXTENSION_FUNCTION("inputMethodPrivate.fetchAllDictionaryWords", |
98 INPUTMETHODPRIVATE_FETCHALLDICTIONARYWORDS) | 104 INPUTMETHODPRIVATE_FETCHALLDICTIONARYWORDS) |
99 DISALLOW_COPY_AND_ASSIGN(FetchAllDictionaryWordsFunction); | 105 DISALLOW_COPY_AND_ASSIGN(InputMethodPrivateFetchAllDictionaryWordsFunction); |
100 }; | 106 }; |
101 | 107 |
102 // Implements the inputMethodPrivate.addWordToDictionary method. | 108 // Implements the inputMethodPrivate.addWordToDictionary method. |
103 class AddWordToDictionaryFunction : public UIThreadExtensionFunction { | 109 class InputMethodPrivateAddWordToDictionaryFunction |
| 110 : public UIThreadExtensionFunction { |
104 public: | 111 public: |
105 AddWordToDictionaryFunction() {} | 112 InputMethodPrivateAddWordToDictionaryFunction() {} |
106 | 113 |
107 protected: | 114 protected: |
108 ~AddWordToDictionaryFunction() override {} | 115 ~InputMethodPrivateAddWordToDictionaryFunction() override {} |
109 | 116 |
110 ResponseAction Run() override; | 117 ResponseAction Run() override; |
111 | 118 |
112 private: | 119 private: |
113 DECLARE_EXTENSION_FUNCTION("inputMethodPrivate.addWordToDictionary", | 120 DECLARE_EXTENSION_FUNCTION("inputMethodPrivate.addWordToDictionary", |
114 INPUTMETHODPRIVATE_ADDWORDTODICTIONARY) | 121 INPUTMETHODPRIVATE_ADDWORDTODICTIONARY) |
115 DISALLOW_COPY_AND_ASSIGN(AddWordToDictionaryFunction); | 122 DISALLOW_COPY_AND_ASSIGN(InputMethodPrivateAddWordToDictionaryFunction); |
116 }; | 123 }; |
117 | 124 |
118 // Implements the inputMethodPrivate.getEncryptSyncEnabled method. | 125 // Implements the inputMethodPrivate.getEncryptSyncEnabled method. |
119 class GetEncryptSyncEnabledFunction : public UIThreadExtensionFunction { | 126 class InputMethodPrivateGetEncryptSyncEnabledFunction |
| 127 : public UIThreadExtensionFunction { |
120 public: | 128 public: |
121 GetEncryptSyncEnabledFunction() {} | 129 InputMethodPrivateGetEncryptSyncEnabledFunction() {} |
122 | 130 |
123 protected: | 131 protected: |
124 ~GetEncryptSyncEnabledFunction() override {} | 132 ~InputMethodPrivateGetEncryptSyncEnabledFunction() override {} |
125 | 133 |
126 ResponseAction Run() override; | 134 ResponseAction Run() override; |
127 | 135 |
128 private: | 136 private: |
129 DECLARE_EXTENSION_FUNCTION("inputMethodPrivate.getEncryptSyncEnabled", | 137 DECLARE_EXTENSION_FUNCTION("inputMethodPrivate.getEncryptSyncEnabled", |
130 INPUTMETHODPRIVATE_GETENCRYPTSYNCENABLED) | 138 INPUTMETHODPRIVATE_GETENCRYPTSYNCENABLED) |
131 DISALLOW_COPY_AND_ASSIGN(GetEncryptSyncEnabledFunction); | 139 DISALLOW_COPY_AND_ASSIGN(InputMethodPrivateGetEncryptSyncEnabledFunction); |
132 }; | 140 }; |
133 | 141 |
134 class InputMethodAPI : public BrowserContextKeyedAPI, | 142 class InputMethodAPI : public BrowserContextKeyedAPI, |
135 public extensions::EventRouter::Observer { | 143 public extensions::EventRouter::Observer { |
136 public: | 144 public: |
137 static const char kOnDictionaryChanged[]; | |
138 static const char kOnDictionaryLoaded[]; | |
139 static const char kOnInputMethodChanged[]; | |
140 | |
141 explicit InputMethodAPI(content::BrowserContext* context); | 145 explicit InputMethodAPI(content::BrowserContext* context); |
142 ~InputMethodAPI() override; | 146 ~InputMethodAPI() override; |
143 | 147 |
144 // Returns input method name for the given XKB (X keyboard extensions in X | 148 // Returns input method name for the given XKB (X keyboard extensions in X |
145 // Window System) id. | 149 // Window System) id. |
146 static std::string GetInputMethodForXkb(const std::string& xkb_id); | 150 static std::string GetInputMethodForXkb(const std::string& xkb_id); |
147 | 151 |
148 // BrowserContextKeyedAPI implementation. | 152 // BrowserContextKeyedAPI implementation. |
149 static BrowserContextKeyedAPIFactory<InputMethodAPI>* GetFactoryInstance(); | 153 static BrowserContextKeyedAPIFactory<InputMethodAPI>* GetFactoryInstance(); |
150 | 154 |
(...skipping 19 matching lines...) Expand all Loading... |
170 input_method_event_router_; | 174 input_method_event_router_; |
171 scoped_ptr<chromeos::ExtensionDictionaryEventRouter> | 175 scoped_ptr<chromeos::ExtensionDictionaryEventRouter> |
172 dictionary_event_router_; | 176 dictionary_event_router_; |
173 | 177 |
174 DISALLOW_COPY_AND_ASSIGN(InputMethodAPI); | 178 DISALLOW_COPY_AND_ASSIGN(InputMethodAPI); |
175 }; | 179 }; |
176 | 180 |
177 } // namespace extensions | 181 } // namespace extensions |
178 | 182 |
179 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_INPUT_METHOD_API_H_ | 183 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_INPUT_METHOD_API_H_ |
OLD | NEW |