Add ENABLE_MEDIA_ROUTER define to builds other than Android and iOS.
[chromium-blink-merge.git] / chrome / browser / chromeos / extensions / input_method_api.h
blob509c1150e0a089dde5c99ff5fc663e8e75a4c72f
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 class InputMethodAPI : public BrowserContextKeyedAPI,
118 public extensions::EventRouter::Observer {
119 public:
120 static const char kOnDictionaryChanged[];
121 static const char kOnDictionaryLoaded[];
122 static const char kOnInputMethodChanged[];
124 explicit InputMethodAPI(content::BrowserContext* context);
125 ~InputMethodAPI() override;
127 // Returns input method name for the given XKB (X keyboard extensions in X
128 // Window System) id.
129 static std::string GetInputMethodForXkb(const std::string& xkb_id);
131 // BrowserContextKeyedAPI implementation.
132 static BrowserContextKeyedAPIFactory<InputMethodAPI>* GetFactoryInstance();
134 // BrowserContextKeyedAPI implementation.
135 void Shutdown() override;
137 // EventRouter::Observer implementation.
138 void OnListenerAdded(const extensions::EventListenerInfo& details) override;
140 private:
141 friend class BrowserContextKeyedAPIFactory<InputMethodAPI>;
143 // BrowserContextKeyedAPI implementation.
144 static const char* service_name() {
145 return "InputMethodAPI";
147 static const bool kServiceIsNULLWhileTesting = true;
149 content::BrowserContext* const context_;
151 // Created lazily upon OnListenerAdded.
152 scoped_ptr<chromeos::ExtensionInputMethodEventRouter>
153 input_method_event_router_;
154 scoped_ptr<chromeos::ExtensionDictionaryEventRouter>
155 dictionary_event_router_;
157 DISALLOW_COPY_AND_ASSIGN(InputMethodAPI);
160 } // namespace extensions
162 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_INPUT_METHOD_API_H_