| 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_EXTENSION_INPUT_IME_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_INPUT_IME_INPUT_IME_API_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_INPUT_IME_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_INPUT_IME_INPUT_IME_API_H_ |
| 7 | 7 |
| 8 #include "chrome/browser/extensions/extension_function.h" | 8 #include "chrome/browser/extensions/extension_function.h" |
| 9 | 9 |
| 10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "chrome/browser/chromeos/input_method/input_method_engine.h" | 12 #include "chrome/browser/chromeos/input_method/input_method_engine.h" |
| 13 #include "chrome/common/extensions/extension.h" | 13 #include "chrome/common/extensions/extension.h" |
| 14 | 14 |
| 15 #include <map> | 15 #include <map> |
| 16 #include <string> | 16 #include <string> |
| 17 #include <vector> | 17 #include <vector> |
| 18 | 18 |
| 19 class Profile; | 19 class Profile; |
| 20 | 20 |
| 21 namespace chromeos { | 21 namespace chromeos { |
| 22 class InputMethodEngine; | 22 class InputMethodEngine; |
| 23 class ImeObserver; | 23 class ImeObserver; |
| 24 } | 24 } |
| 25 | 25 |
| 26 class ExtensionInputImeEventRouter { | 26 namespace extensions { |
| 27 |
| 28 class InputImeEventRouter { |
| 27 public: | 29 public: |
| 28 static ExtensionInputImeEventRouter* GetInstance(); | 30 static InputImeEventRouter* GetInstance(); |
| 29 void Init(); | 31 void Init(); |
| 30 | 32 |
| 31 bool RegisterIme(Profile* profile, | 33 bool RegisterIme(Profile* profile, |
| 32 const std::string& extension_id, | 34 const std::string& extension_id, |
| 33 const extensions::Extension::InputComponentInfo& component); | 35 const extensions::Extension::InputComponentInfo& component); |
| 34 void UnregisterAllImes(Profile* profile, const std::string& extension_id); | 36 void UnregisterAllImes(Profile* profile, const std::string& extension_id); |
| 35 chromeos::InputMethodEngine* GetEngine(const std::string& extension_id, | 37 chromeos::InputMethodEngine* GetEngine(const std::string& extension_id, |
| 36 const std::string& engine_id); | 38 const std::string& engine_id); |
| 37 chromeos::InputMethodEngine* GetActiveEngine(const std::string& extension_id); | 39 chromeos::InputMethodEngine* GetActiveEngine(const std::string& extension_id); |
| 38 | 40 |
| 39 | 41 |
| 40 // Called when a key event was handled. | 42 // Called when a key event was handled. |
| 41 void OnEventHandled(const std::string& extension_id, | 43 void OnEventHandled(const std::string& extension_id, |
| 42 const std::string& request_id, | 44 const std::string& request_id, |
| 43 bool handled); | 45 bool handled); |
| 44 | 46 |
| 45 std::string AddRequest(const std::string& engine_id, | 47 std::string AddRequest(const std::string& engine_id, |
| 46 chromeos::input_method::KeyEventHandle* key_data); | 48 chromeos::input_method::KeyEventHandle* key_data); |
| 47 | 49 |
| 48 private: | 50 private: |
| 49 friend struct DefaultSingletonTraits<ExtensionInputImeEventRouter>; | 51 friend struct DefaultSingletonTraits<InputImeEventRouter>; |
| 50 typedef std::map<std::string, std::pair<std::string, | 52 typedef std::map<std::string, std::pair<std::string, |
| 51 chromeos::input_method::KeyEventHandle*> > RequestMap; | 53 chromeos::input_method::KeyEventHandle*> > RequestMap; |
| 52 | 54 |
| 53 ExtensionInputImeEventRouter(); | 55 InputImeEventRouter(); |
| 54 ~ExtensionInputImeEventRouter(); | 56 ~InputImeEventRouter(); |
| 55 | 57 |
| 56 std::map<std::string, std::map<std::string, chromeos::InputMethodEngine*> > | 58 std::map<std::string, std::map<std::string, chromeos::InputMethodEngine*> > |
| 57 engines_; | 59 engines_; |
| 58 std::map<std::string, std::map<std::string, chromeos::ImeObserver*> > | 60 std::map<std::string, std::map<std::string, chromeos::ImeObserver*> > |
| 59 observers_; | 61 observers_; |
| 60 | 62 |
| 61 unsigned int next_request_id_; | 63 unsigned int next_request_id_; |
| 62 RequestMap request_map_; | 64 RequestMap request_map_; |
| 63 | 65 |
| 64 DISALLOW_COPY_AND_ASSIGN(ExtensionInputImeEventRouter); | 66 DISALLOW_COPY_AND_ASSIGN(InputImeEventRouter); |
| 65 }; | 67 }; |
| 66 | 68 |
| 67 class SetCompositionFunction : public SyncExtensionFunction { | 69 class SetCompositionFunction : public SyncExtensionFunction { |
| 68 public: | 70 public: |
| 69 DECLARE_EXTENSION_FUNCTION_NAME("input.ime.setComposition"); | 71 DECLARE_EXTENSION_FUNCTION_NAME("input.ime.setComposition"); |
| 70 | 72 |
| 71 protected: | 73 protected: |
| 72 virtual ~SetCompositionFunction() {} | 74 virtual ~SetCompositionFunction() {} |
| 73 | 75 |
| 74 // ExtensionFunction: | 76 // ExtensionFunction: |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 public: | 163 public: |
| 162 DECLARE_EXTENSION_FUNCTION_NAME("input.ime.eventHandled"); | 164 DECLARE_EXTENSION_FUNCTION_NAME("input.ime.eventHandled"); |
| 163 | 165 |
| 164 protected: | 166 protected: |
| 165 virtual ~InputEventHandled() {} | 167 virtual ~InputEventHandled() {} |
| 166 | 168 |
| 167 // ExtensionFunction: | 169 // ExtensionFunction: |
| 168 virtual bool RunImpl() OVERRIDE; | 170 virtual bool RunImpl() OVERRIDE; |
| 169 }; | 171 }; |
| 170 | 172 |
| 171 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INPUT_IME_API_H_ | 173 } // namespace extensions |
| 174 |
| 175 #endif // CHROME_BROWSER_EXTENSIONS_API_INPUT_IME_INPUT_IME_API_H_ |
| OLD | NEW |