ozone: evdev: Sync caps lock LED state to evdev
[chromium-blink-merge.git] / chrome / browser / chromeos / extensions / input_method_api.h
blobaed0217dcd6ad451368a450e8630779e68ecb410
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 ExtensionInputMethodEventRouter;
18 namespace extensions {
20 // Implements the inputMethodPrivate.getInputMethodConfig method.
21 class GetInputMethodConfigFunction : public UIThreadExtensionFunction {
22 public:
23 GetInputMethodConfigFunction() {}
25 protected:
26 ~GetInputMethodConfigFunction() override {}
28 ResponseAction Run() override;
30 private:
31 DECLARE_EXTENSION_FUNCTION("inputMethodPrivate.getInputMethodConfig",
32 INPUTMETHODPRIVATE_GETINPUTMETHODCONFIG)
33 DISALLOW_COPY_AND_ASSIGN(GetInputMethodConfigFunction);
36 // Implements the inputMethodPrivate.getCurrentInputMethod method.
37 class GetCurrentInputMethodFunction : public UIThreadExtensionFunction {
38 public:
39 GetCurrentInputMethodFunction() {}
41 protected:
42 ~GetCurrentInputMethodFunction() override {}
44 ResponseAction Run() override;
46 private:
47 DECLARE_EXTENSION_FUNCTION("inputMethodPrivate.getCurrentInputMethod",
48 INPUTMETHODPRIVATE_GETCURRENTINPUTMETHOD)
49 DISALLOW_COPY_AND_ASSIGN(GetCurrentInputMethodFunction);
52 // Implements the inputMethodPrivate.setCurrentInputMethod method.
53 class SetCurrentInputMethodFunction : public UIThreadExtensionFunction {
54 public:
55 SetCurrentInputMethodFunction() {}
57 protected:
58 ~SetCurrentInputMethodFunction() override {}
60 ResponseAction Run() override;
62 private:
63 DECLARE_EXTENSION_FUNCTION("inputMethodPrivate.setCurrentInputMethod",
64 INPUTMETHODPRIVATE_SETCURRENTINPUTMETHOD)
65 DISALLOW_COPY_AND_ASSIGN(SetCurrentInputMethodFunction);
68 // Implements the inputMethodPrivate.getInputMethods method.
69 class GetInputMethodsFunction : public UIThreadExtensionFunction {
70 public:
71 GetInputMethodsFunction() {}
73 protected:
74 ~GetInputMethodsFunction() override {}
76 ResponseAction Run() override;
78 private:
79 DECLARE_EXTENSION_FUNCTION("inputMethodPrivate.getInputMethods",
80 INPUTMETHODPRIVATE_GETINPUTMETHODS)
81 DISALLOW_COPY_AND_ASSIGN(GetInputMethodsFunction);
84 // Implements the inputMethodPrivate.fetchAllDictionaryWords method.
85 class FetchAllDictionaryWordsFunction : public UIThreadExtensionFunction {
86 public:
87 FetchAllDictionaryWordsFunction() {}
89 protected:
90 ~FetchAllDictionaryWordsFunction() override {}
92 ResponseAction Run() override;
94 private:
95 DECLARE_EXTENSION_FUNCTION("inputMethodPrivate.fetchAllDictionaryWords",
96 INPUTMETHODPRIVATE_FETCHALLDICTIONARYWORDS)
97 DISALLOW_COPY_AND_ASSIGN(FetchAllDictionaryWordsFunction);
100 // Implements the inputMethodPrivate.addWordToDictionary method.
101 class AddWordToDictionaryFunction : public UIThreadExtensionFunction {
102 public:
103 AddWordToDictionaryFunction() {}
105 protected:
106 ~AddWordToDictionaryFunction() override {}
108 ResponseAction Run() override;
110 private:
111 DECLARE_EXTENSION_FUNCTION("inputMethodPrivate.addWordToDictionary",
112 INPUTMETHODPRIVATE_ADDWORDTODICTIONARY)
113 DISALLOW_COPY_AND_ASSIGN(AddWordToDictionaryFunction);
116 class InputMethodAPI : public BrowserContextKeyedAPI,
117 public extensions::EventRouter::Observer {
118 public:
119 static const char kOnInputMethodChanged[];
121 explicit InputMethodAPI(content::BrowserContext* context);
122 ~InputMethodAPI() override;
124 // Returns input method name for the given XKB (X keyboard extensions in X
125 // Window System) id.
126 static std::string GetInputMethodForXkb(const std::string& xkb_id);
128 // BrowserContextKeyedAPI implementation.
129 static BrowserContextKeyedAPIFactory<InputMethodAPI>* GetFactoryInstance();
131 // BrowserContextKeyedAPI implementation.
132 void Shutdown() override;
134 // EventRouter::Observer implementation.
135 void OnListenerAdded(const extensions::EventListenerInfo& details) override;
137 private:
138 friend class BrowserContextKeyedAPIFactory<InputMethodAPI>;
140 // BrowserContextKeyedAPI implementation.
141 static const char* service_name() {
142 return "InputMethodAPI";
144 static const bool kServiceIsNULLWhileTesting = true;
146 content::BrowserContext* const context_;
148 // Created lazily upon OnListenerAdded.
149 scoped_ptr<chromeos::ExtensionInputMethodEventRouter>
150 input_method_event_router_;
152 DISALLOW_COPY_AND_ASSIGN(InputMethodAPI);
155 } // namespace extensions
157 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_INPUT_METHOD_API_H_