| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_INPUT_IME_INPUT_IME_API_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_INPUT_IME_INPUT_IME_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_INPUT_IME_INPUT_IME_API_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/singleton.h" | 13 #include "base/memory/singleton.h" |
| 14 #include "base/scoped_observer.h" | 14 #include "base/scoped_observer.h" |
| 15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "build/build_config.h" | 16 #include "build/build_config.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 18 #include "components/keyed_service/core/keyed_service.h" | 18 #include "components/keyed_service/core/keyed_service.h" |
| 19 #include "extensions/browser/browser_context_keyed_api_factory.h" | 19 #include "extensions/browser/browser_context_keyed_api_factory.h" |
| 20 #include "extensions/browser/event_router.h" | 20 #include "extensions/browser/event_router.h" |
| 21 #include "extensions/browser/extension_function.h" | 21 #include "extensions/browser/extension_function.h" |
| 22 #include "extensions/browser/extension_registry_observer.h" | 22 #include "extensions/browser/extension_registry_observer.h" |
| 23 #include "extensions/common/extension.h" | 23 #include "extensions/common/extension.h" |
| 24 #include "ui/base/ime/ime_engine_handler_interface.h" | 24 #include "ui/base/ime/ime_engine_handler_interface.h" |
| 25 #include "ui/base/ime/ime_engine_observer.h" | 25 #include "ui/base/ime/ime_engine_observer.h" |
| 26 #include "ui/base/ime/text_input_flags.h" | 26 #include "ui/base/ime/text_input_flags.h" |
| 27 | 27 |
| 28 #if defined(OS_CHROMEOS) | 28 #if defined(OS_CHROMEOS) |
| 29 #include "chrome/browser/extensions/api/input_ime/input_ime_api_chromeos.h" | 29 #include "chrome/browser/extensions/api/input_ime/input_ime_api_chromeos.h" |
| 30 #elif defined(OS_LINUX) || defined(OS_WIN) |
| 31 #include "chrome/browser/extensions/api/input_ime/input_ime_api_nonchromeos.h" |
| 30 #endif // defined(OS_CHROMEOS) | 32 #endif // defined(OS_CHROMEOS) |
| 31 | 33 |
| 32 class Profile; | 34 class Profile; |
| 33 | 35 |
| 34 namespace ui { | 36 namespace ui { |
| 35 class IMEEngineHandlerInterface; | 37 class IMEEngineHandlerInterface; |
| 36 class IMEEngineObserver; | 38 class IMEEngineObserver; |
| 37 | 39 |
| 38 class ImeObserver : public IMEEngineObserver { | 40 class ImeObserver : public IMEEngineObserver { |
| 39 public: | 41 public: |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 | 82 |
| 81 std::string extension_id_; | 83 std::string extension_id_; |
| 82 Profile* profile_; | 84 Profile* profile_; |
| 83 | 85 |
| 84 DISALLOW_COPY_AND_ASSIGN(ImeObserver); | 86 DISALLOW_COPY_AND_ASSIGN(ImeObserver); |
| 85 }; | 87 }; |
| 86 | 88 |
| 87 } // namespace ui | 89 } // namespace ui |
| 88 | 90 |
| 89 namespace extensions { | 91 namespace extensions { |
| 92 class InputImeEventRouter; |
| 90 class ExtensionRegistry; | 93 class ExtensionRegistry; |
| 91 struct InputComponentInfo; | |
| 92 | |
| 93 class InputImeEventRouter { | |
| 94 public: | |
| 95 explicit InputImeEventRouter(Profile* profile); | |
| 96 ~InputImeEventRouter(); | |
| 97 | |
| 98 bool RegisterImeExtension( | |
| 99 const std::string& extension_id, | |
| 100 const std::vector<extensions::InputComponentInfo>& input_components); | |
| 101 void UnregisterAllImes(const std::string& extension_id); | |
| 102 | |
| 103 ui::IMEEngineHandlerInterface* GetEngine(const std::string& extension_id, | |
| 104 const std::string& component_id); | |
| 105 ui::IMEEngineHandlerInterface* GetActiveEngine( | |
| 106 const std::string& extension_id); | |
| 107 | |
| 108 // Called when a key event was handled. | |
| 109 void OnKeyEventHandled(const std::string& extension_id, | |
| 110 const std::string& request_id, | |
| 111 bool handled); | |
| 112 | |
| 113 std::string AddRequest( | |
| 114 const std::string& component_id, | |
| 115 ui::IMEEngineHandlerInterface::KeyEventDoneCallback& key_data); | |
| 116 | |
| 117 private: | |
| 118 typedef std::map< | |
| 119 std::string, | |
| 120 std::pair<std::string, | |
| 121 ui::IMEEngineHandlerInterface::KeyEventDoneCallback>> | |
| 122 RequestMap; | |
| 123 | |
| 124 // The engine map from extension_id to an engine. | |
| 125 std::map<std::string, ui::IMEEngineHandlerInterface*> engine_map_; | |
| 126 | |
| 127 unsigned int next_request_id_; | |
| 128 RequestMap request_map_; | |
| 129 Profile* profile_; | |
| 130 | |
| 131 DISALLOW_COPY_AND_ASSIGN(InputImeEventRouter); | |
| 132 }; | |
| 133 | 94 |
| 134 class InputImeEventRouterFactory { | 95 class InputImeEventRouterFactory { |
| 135 public: | 96 public: |
| 136 static InputImeEventRouterFactory* GetInstance(); | 97 static InputImeEventRouterFactory* GetInstance(); |
| 137 InputImeEventRouter* GetRouter(Profile* profile); | 98 InputImeEventRouter* GetRouter(Profile* profile); |
| 138 | 99 |
| 139 private: | 100 private: |
| 140 friend struct base::DefaultSingletonTraits<InputImeEventRouterFactory>; | 101 friend struct base::DefaultSingletonTraits<InputImeEventRouterFactory>; |
| 141 InputImeEventRouterFactory(); | 102 InputImeEventRouterFactory(); |
| 142 ~InputImeEventRouterFactory(); | 103 ~InputImeEventRouterFactory(); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 // Listen to extension load, unloaded notifications. | 154 // Listen to extension load, unloaded notifications. |
| 194 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> | 155 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> |
| 195 extension_registry_observer_; | 156 extension_registry_observer_; |
| 196 }; | 157 }; |
| 197 | 158 |
| 198 InputImeEventRouter* GetInputImeEventRouter(Profile* profile); | 159 InputImeEventRouter* GetInputImeEventRouter(Profile* profile); |
| 199 | 160 |
| 200 } // namespace extensions | 161 } // namespace extensions |
| 201 | 162 |
| 202 #endif // CHROME_BROWSER_EXTENSIONS_API_INPUT_IME_INPUT_IME_API_H_ | 163 #endif // CHROME_BROWSER_EXTENSIONS_API_INPUT_IME_INPUT_IME_API_H_ |
| OLD | NEW |