Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(193)

Side by Side Diff: chrome/browser/extensions/api/input_ime/input_ime_api.h

Issue 433163005: Refactoring for InputMethodEngine and InputMethodEventRouter. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed browser_tests: ExtensionApiTest.InputImeApiBasic Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 // The engine map from extension_id to an engine.
67 // { Profile : { extension_id : { engine_id : Engine } } }. 68 std::map<std::string, chromeos::InputMethodEngineInterface*> engine_map_;
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 69
76 unsigned int next_request_id_; 70 unsigned int next_request_id_;
77 RequestMap request_map_; 71 RequestMap request_map_;
78 72
79 DISALLOW_COPY_AND_ASSIGN(InputImeEventRouter); 73 DISALLOW_COPY_AND_ASSIGN(InputImeEventRouter);
80 }; 74 };
81 75
82 class InputImeSetCompositionFunction : public SyncExtensionFunction { 76 class InputImeSetCompositionFunction : public SyncExtensionFunction {
83 public: 77 public:
84 DECLARE_EXTENSION_FUNCTION("input.ime.setComposition", 78 DECLARE_EXTENSION_FUNCTION("input.ime.setComposition",
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 content::BrowserContext* const browser_context_; 248 content::BrowserContext* const browser_context_;
255 249
256 // Listen to extension load, unloaded notifications. 250 // Listen to extension load, unloaded notifications.
257 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> 251 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
258 extension_registry_observer_; 252 extension_registry_observer_;
259 }; 253 };
260 254
261 } // namespace extensions 255 } // namespace extensions
262 256
263 #endif // CHROME_BROWSER_EXTENSIONS_API_INPUT_IME_INPUT_IME_API_H_ 257 #endif // CHROME_BROWSER_EXTENSIONS_API_INPUT_IME_INPUT_IME_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698