| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_EXTENSIONS_API_INPUT_IME_INPUT_IME_API_NONCHROMEOS_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_INPUT_IME_INPUT_IME_API_NONCHROMEOS_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_INPUT_IME_INPUT_IME_API_NONCHROMEOS_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_INPUT_IME_INPUT_IME_API_NONCHROMEOS_H_ |
| 7 | 7 |
| 8 #include "chrome/browser/extensions/api/input_ime/input_ime_event_router_base.h" | 8 #include "chrome/browser/extensions/api/input_ime/input_ime_event_router_base.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "extensions/browser/extension_function.h" | 10 #include "extensions/browser/extension_function.h" |
| 11 | 11 |
| 12 class Profile; | 12 class Profile; |
| 13 | 13 |
| 14 namespace input_method { |
| 15 class InputMethodEngine; |
| 16 } // namespace input_method |
| 17 |
| 14 namespace extensions { | 18 namespace extensions { |
| 15 | 19 |
| 16 class InputImeEventRouterBase; | 20 class InputImeEventRouterBase; |
| 17 | 21 |
| 18 class InputImeEventRouter : public InputImeEventRouterBase { | 22 class InputImeEventRouter : public InputImeEventRouterBase { |
| 19 public: | 23 public: |
| 20 explicit InputImeEventRouter(Profile* profile); | 24 explicit InputImeEventRouter(Profile* profile); |
| 21 ~InputImeEventRouter() override; | 25 ~InputImeEventRouter() override; |
| 22 | 26 |
| 27 // Registers the extension as an IME extension, allowing it to be the active |
| 28 // engine. |
| 29 bool RegisterImeExtension(const std::string& extension_id); |
| 30 |
| 31 // Unregisters the extension as an IME extension and deactivates the IME |
| 32 // engine for it, if it was active. |
| 33 void UnregisterImeExtension(const std::string& extension_id); |
| 34 |
| 35 // Gets the input method engine if the extension is active. |
| 36 input_method::InputMethodEngine* GetActiveEngine( |
| 37 const std::string& extension_id); |
| 38 |
| 39 // Actives the extension with new input method engine, and deletes the |
| 40 // previous engine if another extension was active. |
| 41 void SetActiveEngine(const std::string& extension_id); |
| 42 |
| 43 private: |
| 44 // Deletes the current input method engine. |
| 45 void DeleteInputMethodEngine(); |
| 46 |
| 47 // The active input method engine. |
| 48 input_method::InputMethodEngine* active_engine_; |
| 49 |
| 50 // The id of the all registered extensions. |
| 51 std::vector<std::string> extension_ids_; |
| 52 |
| 23 DISALLOW_COPY_AND_ASSIGN(InputImeEventRouter); | 53 DISALLOW_COPY_AND_ASSIGN(InputImeEventRouter); |
| 24 }; | 54 }; |
| 25 | 55 |
| 26 class InputImeCreateWindowFunction : public UIThreadExtensionFunction { | 56 class InputImeCreateWindowFunction : public UIThreadExtensionFunction { |
| 27 public: | 57 public: |
| 28 DECLARE_EXTENSION_FUNCTION("input.ime.createWindow", INPUT_IME_CREATEWINDOW) | 58 DECLARE_EXTENSION_FUNCTION("input.ime.createWindow", INPUT_IME_CREATEWINDOW) |
| 29 | 59 |
| 30 protected: | 60 protected: |
| 31 ~InputImeCreateWindowFunction() override {} | 61 ~InputImeCreateWindowFunction() override {} |
| 32 | 62 |
| 33 // ExtensionFunction: | 63 // ExtensionFunction: |
| 34 ExtensionFunction::ResponseAction Run() override; | 64 ExtensionFunction::ResponseAction Run() override; |
| 35 }; | 65 }; |
| 36 | 66 |
| 67 class InputImeActivateFunction : public UIThreadExtensionFunction { |
| 68 public: |
| 69 DECLARE_EXTENSION_FUNCTION("input.ime.activate", INPUT_IME_ACTIVATE) |
| 70 |
| 71 protected: |
| 72 ~InputImeActivateFunction() override {} |
| 73 |
| 74 // UIThreadExtensionFunction: |
| 75 ResponseAction Run() override; |
| 76 }; |
| 77 |
| 78 class InputImeDeactivateFunction : public UIThreadExtensionFunction { |
| 79 public: |
| 80 DECLARE_EXTENSION_FUNCTION("input.ime.deactivate", INPUT_IME_DEACTIVATE) |
| 81 |
| 82 protected: |
| 83 ~InputImeDeactivateFunction() override {} |
| 84 |
| 85 // UIThreadExtensionFunction: |
| 86 ResponseAction Run() override; |
| 87 }; |
| 88 |
| 37 } // namespace extensions | 89 } // namespace extensions |
| 38 | 90 |
| 39 #endif // CHROME_BROWSER_EXTENSIONS_API_INPUT_IME_INPUT_IME_API_NONCHROMEOS_H_ | 91 #endif // CHROME_BROWSER_EXTENSIONS_API_INPUT_IME_INPUT_IME_API_NONCHROMEOS_H_ |
| OLD | NEW |