| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_INPUT_IME_EXTENSION_API_H_ | |
| 6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_INPUT_IME_EXTENSION_API_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include "chrome/browser/extensions/extension_function.h" | |
| 10 | |
| 11 #include "base/memory/singleton.h" | |
| 12 #include "base/values.h" | |
| 13 #include "chrome/browser/chromeos/input_method/input_method_engine.h" | |
| 14 #include "chrome/common/extensions/extension.h" | |
| 15 | |
| 16 #include <map> | |
| 17 #include <string> | |
| 18 #include <vector> | |
| 19 | |
| 20 class Profile; | |
| 21 | |
| 22 namespace chromeos { | |
| 23 class InputMethodEngine; | |
| 24 class ImeObserver; | |
| 25 } | |
| 26 | |
| 27 class InputImeExtensionEventRouter { | |
| 28 public: | |
| 29 static InputImeExtensionEventRouter* GetInstance(); | |
| 30 void Init(); | |
| 31 | |
| 32 bool RegisterIme(Profile* profile, | |
| 33 const std::string& extension_id, | |
| 34 const Extension::InputComponentInfo& component); | |
| 35 chromeos::InputMethodEngine* GetEngine(const std::string& extension_id, | |
| 36 const std::string& engine_id); | |
| 37 chromeos::InputMethodEngine* GetActiveEngine(const std::string& extension_id); | |
| 38 | |
| 39 | |
| 40 // Called when a key event was handled. | |
| 41 void OnEventHandled(const std::string& extension_id, | |
| 42 const std::string& request_id, | |
| 43 bool handled); | |
| 44 | |
| 45 std::string AddRequest(const std::string& engine_id, | |
| 46 chromeos::input_method::KeyEventHandle* key_data); | |
| 47 | |
| 48 private: | |
| 49 friend struct DefaultSingletonTraits<InputImeExtensionEventRouter>; | |
| 50 typedef std::map<std::string, std::pair<std::string, | |
| 51 chromeos::input_method::KeyEventHandle*> > RequestMap; | |
| 52 | |
| 53 InputImeExtensionEventRouter(); | |
| 54 ~InputImeExtensionEventRouter(); | |
| 55 | |
| 56 std::map<std::string, std::map<std::string, chromeos::InputMethodEngine*> > | |
| 57 engines_; | |
| 58 std::map<std::string, std::map<std::string, chromeos::ImeObserver*> > | |
| 59 observers_; | |
| 60 | |
| 61 unsigned int next_request_id_; | |
| 62 RequestMap request_map_; | |
| 63 | |
| 64 DISALLOW_COPY_AND_ASSIGN(InputImeExtensionEventRouter); | |
| 65 }; | |
| 66 | |
| 67 class SetCompositionFunction : public SyncExtensionFunction { | |
| 68 public: | |
| 69 virtual bool RunImpl() OVERRIDE; | |
| 70 DECLARE_EXTENSION_FUNCTION_NAME( | |
| 71 "experimental.input.ime.setComposition"); | |
| 72 }; | |
| 73 | |
| 74 class ClearCompositionFunction : public SyncExtensionFunction { | |
| 75 public: | |
| 76 virtual bool RunImpl() OVERRIDE; | |
| 77 DECLARE_EXTENSION_FUNCTION_NAME( | |
| 78 "experimental.input.ime.clearComposition"); | |
| 79 }; | |
| 80 | |
| 81 class CommitTextFunction : public SyncExtensionFunction { | |
| 82 public: | |
| 83 virtual bool RunImpl() OVERRIDE; | |
| 84 DECLARE_EXTENSION_FUNCTION_NAME( | |
| 85 "experimental.input.ime.commitText"); | |
| 86 }; | |
| 87 | |
| 88 class SetCandidateWindowPropertiesFunction : public SyncExtensionFunction { | |
| 89 public: | |
| 90 virtual bool RunImpl() OVERRIDE; | |
| 91 DECLARE_EXTENSION_FUNCTION_NAME( | |
| 92 "experimental.input.ime.setCandidateWindowProperties"); | |
| 93 }; | |
| 94 | |
| 95 class SetCandidatesFunction : public SyncExtensionFunction { | |
| 96 public: | |
| 97 virtual bool RunImpl() OVERRIDE; | |
| 98 DECLARE_EXTENSION_FUNCTION_NAME( | |
| 99 "experimental.input.ime.setCandidates"); | |
| 100 private: | |
| 101 bool ReadCandidates( | |
| 102 ListValue* candidates, | |
| 103 std::vector<chromeos::InputMethodEngine::Candidate>* output); | |
| 104 }; | |
| 105 | |
| 106 class SetCursorPositionFunction : public SyncExtensionFunction { | |
| 107 public: | |
| 108 virtual bool RunImpl() OVERRIDE; | |
| 109 DECLARE_EXTENSION_FUNCTION_NAME( | |
| 110 "experimental.input.ime.setCursorPosition"); | |
| 111 }; | |
| 112 | |
| 113 class SetMenuItemsFunction : public SyncExtensionFunction { | |
| 114 public: | |
| 115 virtual bool RunImpl() OVERRIDE; | |
| 116 DECLARE_EXTENSION_FUNCTION_NAME( | |
| 117 "experimental.input.ime.setMenuItems"); | |
| 118 }; | |
| 119 | |
| 120 class UpdateMenuItemsFunction : public SyncExtensionFunction { | |
| 121 public: | |
| 122 virtual bool RunImpl() OVERRIDE; | |
| 123 DECLARE_EXTENSION_FUNCTION_NAME( | |
| 124 "experimental.input.ime.updateMenuItems"); | |
| 125 }; | |
| 126 | |
| 127 class InputEventHandled : public AsyncExtensionFunction { | |
| 128 public: | |
| 129 virtual bool RunImpl() OVERRIDE; | |
| 130 DECLARE_EXTENSION_FUNCTION_NAME("experimental.input.ime.eventHandled"); | |
| 131 }; | |
| 132 | |
| 133 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_INPUT_IME_EXTENSION_API_H_ | |
| OLD | NEW |