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

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

Issue 1136463005: Supports multiple profile in Chrome OS IMF. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased. Created 5 years, 7 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 16 matching lines...) Expand all
27 class InputMethodEngineInterface; 27 class InputMethodEngineInterface;
28 class ImeObserver; 28 class ImeObserver;
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 explicit InputImeEventRouter(Profile* profile);
38 ~InputImeEventRouter();
38 39
39 bool RegisterImeExtension( 40 bool RegisterImeExtension(
40 Profile* profile,
41 const std::string& extension_id, 41 const std::string& extension_id,
42 const std::vector<extensions::InputComponentInfo>& input_components); 42 const std::vector<extensions::InputComponentInfo>& input_components);
43 void UnregisterAllImes(const std::string& extension_id); 43 void UnregisterAllImes(const std::string& extension_id);
44 44
45 chromeos::InputMethodEngineInterface* GetEngine( 45 chromeos::InputMethodEngineInterface* GetEngine(
46 const std::string& extension_id, 46 const std::string& extension_id,
47 const std::string& component_id); 47 const std::string& component_id);
48 chromeos::InputMethodEngineInterface* GetActiveEngine( 48 chromeos::InputMethodEngineInterface* GetActiveEngine(
49 const std::string& extension_id); 49 const std::string& extension_id);
50 50
51 51
52 // Called when a key event was handled. 52 // Called when a key event was handled.
53 void OnKeyEventHandled(const std::string& extension_id, 53 void OnKeyEventHandled(const std::string& extension_id,
54 const std::string& request_id, 54 const std::string& request_id,
55 bool handled); 55 bool handled);
56 56
57 std::string AddRequest(const std::string& component_id, 57 std::string AddRequest(const std::string& component_id,
58 chromeos::input_method::KeyEventHandle* key_data); 58 chromeos::input_method::KeyEventHandle* key_data);
59 59
60 private: 60 private:
61 friend struct DefaultSingletonTraits<InputImeEventRouter>;
62 typedef std::map<std::string, std::pair<std::string, 61 typedef std::map<std::string, std::pair<std::string,
63 chromeos::input_method::KeyEventHandle*> > RequestMap; 62 chromeos::input_method::KeyEventHandle*> > RequestMap;
64 63
65 InputImeEventRouter();
66 ~InputImeEventRouter();
67
68 // The engine map from extension_id to an engine. 64 // The engine map from extension_id to an engine.
69 std::map<std::string, chromeos::InputMethodEngineInterface*> engine_map_; 65 std::map<std::string, chromeos::InputMethodEngineInterface*> engine_map_;
70 66
71 unsigned int next_request_id_; 67 unsigned int next_request_id_;
72 RequestMap request_map_; 68 RequestMap request_map_;
69 Profile* profile_;
73 70
74 DISALLOW_COPY_AND_ASSIGN(InputImeEventRouter); 71 DISALLOW_COPY_AND_ASSIGN(InputImeEventRouter);
75 }; 72 };
76 73
74 class InputImeEventRouterFactory {
75 public:
76 static InputImeEventRouterFactory* GetInstance();
77 InputImeEventRouter* GetRouter(Profile* profile);
78
79 private:
80 friend struct DefaultSingletonTraits<InputImeEventRouterFactory>;
81 InputImeEventRouterFactory();
82 ~InputImeEventRouterFactory();
83
84 std::map<Profile*, InputImeEventRouter*, ProfileCompare> router_map_;
85
86 DISALLOW_COPY_AND_ASSIGN(InputImeEventRouterFactory);
87 };
88
77 class InputImeSetCompositionFunction : public SyncExtensionFunction { 89 class InputImeSetCompositionFunction : public SyncExtensionFunction {
78 public: 90 public:
79 DECLARE_EXTENSION_FUNCTION("input.ime.setComposition", 91 DECLARE_EXTENSION_FUNCTION("input.ime.setComposition",
80 INPUT_IME_SETCOMPOSITION) 92 INPUT_IME_SETCOMPOSITION)
81 93
82 protected: 94 protected:
83 ~InputImeSetCompositionFunction() override {} 95 ~InputImeSetCompositionFunction() override {}
84 96
85 // ExtensionFunction: 97 // ExtensionFunction:
86 bool RunSync() override; 98 bool RunSync() override;
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 content::BrowserContext* const browser_context_; 260 content::BrowserContext* const browser_context_;
249 261
250 // Listen to extension load, unloaded notifications. 262 // Listen to extension load, unloaded notifications.
251 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> 263 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
252 extension_registry_observer_; 264 extension_registry_observer_;
253 }; 265 };
254 266
255 } // namespace extensions 267 } // namespace extensions
256 268
257 #endif // CHROME_BROWSER_EXTENSIONS_API_INPUT_IME_INPUT_IME_API_H_ 269 #endif // CHROME_BROWSER_EXTENSIONS_API_INPUT_IME_INPUT_IME_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698