| 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/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "extensions/browser/browser_context_keyed_api_factory.h" | 10 #include "extensions/browser/browser_context_keyed_api_factory.h" |
| 11 #include "extensions/browser/event_router.h" | 11 #include "extensions/browser/event_router.h" |
| 12 #include "extensions/browser/extension_function.h" | 12 #include "extensions/browser/extension_function.h" |
| 13 | 13 |
| 14 namespace chromeos { | 14 namespace chromeos { |
| 15 class ExtensionInputMethodEventRouter; | 15 class ExtensionInputMethodEventRouter; |
| 16 } | 16 } |
| 17 | 17 |
| 18 namespace extensions { | 18 namespace extensions { |
| 19 | 19 |
| 20 // Implements the experimental.inputMethod.get method. | 20 // Implements the inputMethodPrivate.getCurrentInputMethod method. |
| 21 class GetInputMethodFunction : public SyncExtensionFunction { | 21 class GetCurrentInputMethodFunction : public UIThreadExtensionFunction { |
| 22 public: | 22 public: |
| 23 GetInputMethodFunction(); | 23 GetCurrentInputMethodFunction() {} |
| 24 | 24 |
| 25 protected: | 25 protected: |
| 26 virtual ~GetInputMethodFunction(); | 26 virtual ~GetCurrentInputMethodFunction() {} |
| 27 | 27 |
| 28 virtual bool RunSync() OVERRIDE; | 28 virtual ResponseAction Run() OVERRIDE; |
| 29 | 29 |
| 30 private: | 30 private: |
| 31 DECLARE_EXTENSION_FUNCTION("inputMethodPrivate.get", INPUTMETHODPRIVATE_GET) | 31 DECLARE_EXTENSION_FUNCTION("inputMethodPrivate.getCurrentInputMethod", |
| 32 INPUTMETHODPRIVATE_GETCURRENTINPUTMETHOD) |
| 33 }; |
| 34 |
| 35 // Implements the inputMethodPrivate.setCurrentInputMethod method. |
| 36 class SetCurrentInputMethodFunction : public UIThreadExtensionFunction { |
| 37 public: |
| 38 SetCurrentInputMethodFunction() {} |
| 39 |
| 40 protected: |
| 41 virtual ~SetCurrentInputMethodFunction() {} |
| 42 |
| 43 virtual ResponseAction Run() OVERRIDE; |
| 44 |
| 45 private: |
| 46 DECLARE_EXTENSION_FUNCTION("inputMethodPrivate.setCurrentInputMethod", |
| 47 INPUTMETHODPRIVATE_SETCURRENTINPUTMETHOD) |
| 48 }; |
| 49 |
| 50 // Implements the inputMethodPrivate.getInputMethods method. |
| 51 class GetInputMethodsFunction : public UIThreadExtensionFunction { |
| 52 public: |
| 53 GetInputMethodsFunction() {} |
| 54 |
| 55 protected: |
| 56 virtual ~GetInputMethodsFunction() {} |
| 57 |
| 58 virtual ResponseAction Run() OVERRIDE; |
| 59 |
| 60 private: |
| 61 DECLARE_EXTENSION_FUNCTION("inputMethodPrivate.getInputMethods", |
| 62 INPUTMETHODPRIVATE_GETINPUTMETHODS) |
| 32 }; | 63 }; |
| 33 | 64 |
| 34 // Notify the initialization is done to input method engine. | 65 // Notify the initialization is done to input method engine. |
| 35 // TODO(nona): remove this function. | 66 // TODO(nona): remove this function. |
| 36 class StartImeFunction : public SyncExtensionFunction { | 67 class StartImeFunction : public UIThreadExtensionFunction { |
| 37 public: | 68 public: |
| 38 StartImeFunction(); | 69 StartImeFunction(); |
| 39 | 70 |
| 40 protected: | 71 protected: |
| 41 virtual ~StartImeFunction(); | 72 virtual ~StartImeFunction(); |
| 42 | 73 |
| 43 virtual bool RunSync() OVERRIDE; | 74 virtual ResponseAction Run() OVERRIDE; |
| 44 | 75 |
| 45 private: | 76 private: |
| 46 DECLARE_EXTENSION_FUNCTION("inputMethodPrivate.startIme", | 77 DECLARE_EXTENSION_FUNCTION("inputMethodPrivate.startIme", |
| 47 INPUTMETHODPRIVATE_STARTIME) | 78 INPUTMETHODPRIVATE_STARTIME) |
| 48 }; | 79 }; |
| 49 | 80 |
| 50 class InputMethodAPI : public BrowserContextKeyedAPI, | 81 class InputMethodAPI : public BrowserContextKeyedAPI, |
| 51 public extensions::EventRouter::Observer { | 82 public extensions::EventRouter::Observer { |
| 52 public: | 83 public: |
| 53 static const char kOnInputMethodChanged[]; | 84 static const char kOnInputMethodChanged[]; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 83 // Created lazily upon OnListenerAdded. | 114 // Created lazily upon OnListenerAdded. |
| 84 scoped_ptr<chromeos::ExtensionInputMethodEventRouter> | 115 scoped_ptr<chromeos::ExtensionInputMethodEventRouter> |
| 85 input_method_event_router_; | 116 input_method_event_router_; |
| 86 | 117 |
| 87 DISALLOW_COPY_AND_ASSIGN(InputMethodAPI); | 118 DISALLOW_COPY_AND_ASSIGN(InputMethodAPI); |
| 88 }; | 119 }; |
| 89 | 120 |
| 90 } // namespace extensions | 121 } // namespace extensions |
| 91 | 122 |
| 92 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_INPUT_METHOD_API_H_ | 123 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_INPUT_METHOD_API_H_ |
| OLD | NEW |