Chromium Code Reviews| 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> |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 } // namespace chromeos | 29 } // namespace chromeos |
| 30 | 30 |
| 31 namespace extensions { | 31 namespace extensions { |
| 32 class ExtensionRegistry; | 32 class ExtensionRegistry; |
| 33 struct InputComponentInfo; | 33 struct InputComponentInfo; |
| 34 | 34 |
| 35 class InputImeEventRouter { | 35 class InputImeEventRouter { |
| 36 public: | 36 public: |
| 37 static InputImeEventRouter* GetInstance(); | 37 static InputImeEventRouter* GetInstance(); |
| 38 | 38 |
| 39 bool RegisterIme(Profile*, | 39 bool RegisterImeExtension( |
| 40 const std::string& extension_id, | 40 const std::string& extension_id, |
| 41 const extensions::InputComponentInfo& component); | 41 const std::vector<extensions::InputComponentInfo>& input_components); |
| 42 void UnregisterAllImes(const std::string& extension_id); | 42 void UnregisterAllImes(const std::string& extension_id); |
| 43 | |
| 43 chromeos::InputMethodEngineInterface* GetEngine( | 44 chromeos::InputMethodEngineInterface* GetEngine( |
| 44 const std::string& extension_id, | 45 const std::string& extension_id, |
| 45 const std::string& engine_id); | 46 const std::string& component_id); |
| 46 chromeos::InputMethodEngineInterface* GetActiveEngine( | 47 chromeos::InputMethodEngineInterface* GetActiveEngine( |
| 47 const std::string& extension_id); | 48 const std::string& extension_id); |
| 48 | 49 |
| 49 | 50 |
| 50 // Called when a key event was handled. | 51 // Called when a key event was handled. |
| 51 void OnKeyEventHandled(const std::string& extension_id, | 52 void OnKeyEventHandled(const std::string& extension_id, |
| 52 const std::string& request_id, | 53 const std::string& request_id, |
| 53 bool handled); | 54 bool handled); |
| 54 | 55 |
| 55 std::string AddRequest(const std::string& engine_id, | 56 std::string AddRequest(const std::string& component_id, |
| 56 chromeos::input_method::KeyEventHandle* key_data); | 57 chromeos::input_method::KeyEventHandle* key_data); |
| 57 | 58 |
| 58 private: | 59 private: |
| 59 friend struct DefaultSingletonTraits<InputImeEventRouter>; | 60 friend struct DefaultSingletonTraits<InputImeEventRouter>; |
| 60 typedef std::map<std::string, std::pair<std::string, | 61 typedef std::map<std::string, std::pair<std::string, |
| 61 chromeos::input_method::KeyEventHandle*> > RequestMap; | 62 chromeos::input_method::KeyEventHandle*> > RequestMap; |
| 62 | 63 |
| 63 InputImeEventRouter(); | 64 InputImeEventRouter(); |
| 64 ~InputImeEventRouter(); | 65 ~InputImeEventRouter(); |
| 65 | 66 |
| 66 // The engine map for event routing. | 67 std::map<std::string, chromeos::InputMethodEngineInterface*> engine_map_; |
|
Yuki
2014/08/06 04:42:24
Better to have a comment here, too.
Say that the k
Shu Chen
2014/08/06 05:45:03
Done.
| |
| 67 // { Profile : { extension_id : { engine_id : Engine } } }. | |
| 68 // TODO(shuchen): reuse the engine map in InputMethodManagerImpl. | |
| 69 typedef std::map<std::string, chromeos::InputMethodEngineInterface*> | |
| 70 EngineMap; | |
| 71 typedef std::map<std::string, EngineMap> ExtensionMap; | |
| 72 typedef std::map<Profile*, ExtensionMap, ProfileCompare> | |
| 73 ProfileEngineMap; | |
| 74 ProfileEngineMap profile_engine_map_; | |
| 75 | 68 |
| 76 unsigned int next_request_id_; | 69 unsigned int next_request_id_; |
| 77 RequestMap request_map_; | 70 RequestMap request_map_; |
| 78 | 71 |
| 79 DISALLOW_COPY_AND_ASSIGN(InputImeEventRouter); | 72 DISALLOW_COPY_AND_ASSIGN(InputImeEventRouter); |
| 80 }; | 73 }; |
| 81 | 74 |
| 82 class InputImeSetCompositionFunction : public SyncExtensionFunction { | 75 class InputImeSetCompositionFunction : public SyncExtensionFunction { |
| 83 public: | 76 public: |
| 84 DECLARE_EXTENSION_FUNCTION("input.ime.setComposition", | 77 DECLARE_EXTENSION_FUNCTION("input.ime.setComposition", |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 254 content::BrowserContext* const browser_context_; | 247 content::BrowserContext* const browser_context_; |
| 255 | 248 |
| 256 // Listen to extension load, unloaded notifications. | 249 // Listen to extension load, unloaded notifications. |
| 257 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> | 250 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> |
| 258 extension_registry_observer_; | 251 extension_registry_observer_; |
| 259 }; | 252 }; |
| 260 | 253 |
| 261 } // namespace extensions | 254 } // namespace extensions |
| 262 | 255 |
| 263 #endif // CHROME_BROWSER_EXTENSIONS_API_INPUT_IME_INPUT_IME_API_H_ | 256 #endif // CHROME_BROWSER_EXTENSIONS_API_INPUT_IME_INPUT_IME_API_H_ |
| OLD | NEW |