BookmarkManager: Fix 'new folder text field size changes on clicking it' issue.
[chromium-blink-merge.git] / chrome / browser / chromeos / extensions / input_method_api.h
blobf8cd11905eefcda296082e26bc25c8b775471468
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_INPUT_METHOD_API_H_
6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_INPUT_METHOD_API_H_
8 #include "base/compiler_specific.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "extensions/browser/browser_context_keyed_api_factory.h"
11 #include "extensions/browser/event_router.h"
12 #include "extensions/browser/extension_function.h"
14 namespace chromeos {
15 class ExtensionDictionaryEventRouter;
16 class ExtensionInputMethodEventRouter;
19 namespace extensions {
21 // Implements the inputMethodPrivate.getInputMethodConfig method.
22 class GetInputMethodConfigFunction : public UIThreadExtensionFunction {
23 public:
24 GetInputMethodConfigFunction() {}
26 protected:
27 ~GetInputMethodConfigFunction() override {}
29 ResponseAction Run() override;
31 private:
32 DECLARE_EXTENSION_FUNCTION("inputMethodPrivate.getInputMethodConfig",
33 INPUTMETHODPRIVATE_GETINPUTMETHODCONFIG)
34 DISALLOW_COPY_AND_ASSIGN(GetInputMethodConfigFunction);
37 // Implements the inputMethodPrivate.getCurrentInputMethod method.
38 class GetCurrentInputMethodFunction : public UIThreadExtensionFunction {
39 public:
40 GetCurrentInputMethodFunction() {}
42 protected:
43 ~GetCurrentInputMethodFunction() override {}
45 ResponseAction Run() override;
47 private:
48 DECLARE_EXTENSION_FUNCTION("inputMethodPrivate.getCurrentInputMethod",
49 INPUTMETHODPRIVATE_GETCURRENTINPUTMETHOD)
50 DISALLOW_COPY_AND_ASSIGN(GetCurrentInputMethodFunction);
53 // Implements the inputMethodPrivate.setCurrentInputMethod method.
54 class SetCurrentInputMethodFunction : public UIThreadExtensionFunction {
55 public:
56 SetCurrentInputMethodFunction() {}
58 protected:
59 ~SetCurrentInputMethodFunction() override {}
61 ResponseAction Run() override;
63 private:
64 DECLARE_EXTENSION_FUNCTION("inputMethodPrivate.setCurrentInputMethod",
65 INPUTMETHODPRIVATE_SETCURRENTINPUTMETHOD)
66 DISALLOW_COPY_AND_ASSIGN(SetCurrentInputMethodFunction);
69 // Implements the inputMethodPrivate.getInputMethods method.
70 class GetInputMethodsFunction : public UIThreadExtensionFunction {
71 public:
72 GetInputMethodsFunction() {}
74 protected:
75 ~GetInputMethodsFunction() override {}
77 ResponseAction Run() override;
79 private:
80 DECLARE_EXTENSION_FUNCTION("inputMethodPrivate.getInputMethods",
81 INPUTMETHODPRIVATE_GETINPUTMETHODS)
82 DISALLOW_COPY_AND_ASSIGN(GetInputMethodsFunction);
85 // Implements the inputMethodPrivate.fetchAllDictionaryWords method.
86 class FetchAllDictionaryWordsFunction : public UIThreadExtensionFunction {
87 public:
88 FetchAllDictionaryWordsFunction() {}
90 protected:
91 ~FetchAllDictionaryWordsFunction() override {}
93 ResponseAction Run() override;
95 private:
96 DECLARE_EXTENSION_FUNCTION("inputMethodPrivate.fetchAllDictionaryWords",
97 INPUTMETHODPRIVATE_FETCHALLDICTIONARYWORDS)
98 DISALLOW_COPY_AND_ASSIGN(FetchAllDictionaryWordsFunction);
101 // Implements the inputMethodPrivate.addWordToDictionary method.
102 class AddWordToDictionaryFunction : public UIThreadExtensionFunction {
103 public:
104 AddWordToDictionaryFunction() {}
106 protected:
107 ~AddWordToDictionaryFunction() override {}
109 ResponseAction Run() override;
111 private:
112 DECLARE_EXTENSION_FUNCTION("inputMethodPrivate.addWordToDictionary",
113 INPUTMETHODPRIVATE_ADDWORDTODICTIONARY)
114 DISALLOW_COPY_AND_ASSIGN(AddWordToDictionaryFunction);
117 // Implements the inputMethodPrivate.getEncryptSyncEnabled method.
118 class GetEncryptSyncEnabledFunction : public UIThreadExtensionFunction {
119 public:
120 GetEncryptSyncEnabledFunction() {}
122 protected:
123 ~GetEncryptSyncEnabledFunction() override {}
125 ResponseAction Run() override;
127 private:
128 DECLARE_EXTENSION_FUNCTION("inputMethodPrivate.getEncryptSyncEnabled",
129 INPUTMETHODPRIVATE_GETENCRYPTSYNCENABLED)
130 DISALLOW_COPY_AND_ASSIGN(GetEncryptSyncEnabledFunction);
133 class InputMethodAPI : public BrowserContextKeyedAPI,
134 public extensions::EventRouter::Observer {
135 public:
136 static const char kOnDictionaryChanged[];
137 static const char kOnDictionaryLoaded[];
138 static const char kOnInputMethodChanged[];
140 explicit InputMethodAPI(content::BrowserContext* context);
141 ~InputMethodAPI() override;
143 // Returns input method name for the given XKB (X keyboard extensions in X
144 // Window System) id.
145 static std::string GetInputMethodForXkb(const std::string& xkb_id);
147 // BrowserContextKeyedAPI implementation.
148 static BrowserContextKeyedAPIFactory<InputMethodAPI>* GetFactoryInstance();
150 // BrowserContextKeyedAPI implementation.
151 void Shutdown() override;
153 // EventRouter::Observer implementation.
154 void OnListenerAdded(const extensions::EventListenerInfo& details) override;
156 private:
157 friend class BrowserContextKeyedAPIFactory<InputMethodAPI>;
159 // BrowserContextKeyedAPI implementation.
160 static const char* service_name() {
161 return "InputMethodAPI";
163 static const bool kServiceIsNULLWhileTesting = true;
165 content::BrowserContext* const context_;
167 // Created lazily upon OnListenerAdded.
168 scoped_ptr<chromeos::ExtensionInputMethodEventRouter>
169 input_method_event_router_;
170 scoped_ptr<chromeos::ExtensionDictionaryEventRouter>
171 dictionary_event_router_;
173 DISALLOW_COPY_AND_ASSIGN(InputMethodAPI);
176 } // namespace extensions
178 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_INPUT_METHOD_API_H_