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