| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_CHROMEOS_INPUT_METHOD_INPUT_METHOD_ENGINE_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_ENGINE_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_ENGINE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_ENGINE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <map> | 11 #include <map> |
| 12 #include <string> | 12 #include <string> |
| 13 #include <vector> | 13 #include <vector> |
| 14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 15 #include "chrome/browser/input_method/input_method_engine_base.h" |
| 15 #include "ui/base/ime/chromeos/input_method_descriptor.h" | 16 #include "ui/base/ime/chromeos/input_method_descriptor.h" |
| 16 #include "ui/base/ime/ime_engine_handler_interface.h" | 17 #include "ui/base/ime/ime_engine_handler_interface.h" |
| 17 #include "ui/base/ime/ime_engine_observer.h" | 18 #include "ui/base/ime/ime_engine_observer.h" |
| 18 #include "url/gurl.h" | 19 #include "url/gurl.h" |
| 19 | 20 |
| 20 class Profile; | 21 class Profile; |
| 21 | 22 |
| 22 namespace ui { | 23 namespace ui { |
| 23 class CandidateWindow; | 24 class CandidateWindow; |
| 24 struct CompositionText; | 25 struct CompositionText; |
| 25 class IMEEngineHandlerInterface; | 26 class IMEEngineHandlerInterface; |
| 26 class IMEEngineObserver; | 27 class IMEEngineObserver; |
| 27 class KeyEvent; | 28 class KeyEvent; |
| 28 | 29 |
| 29 namespace ime { | 30 namespace ime { |
| 30 struct InputMethodMenuItem; | 31 struct InputMethodMenuItem; |
| 31 } // namespace ime | 32 } // namespace ime |
| 32 } // namespace ui | 33 } // namespace ui |
| 33 | 34 |
| 35 namespace input_method { |
| 36 class InputMethodEngineBase; |
| 37 } |
| 38 |
| 34 namespace chromeos { | 39 namespace chromeos { |
| 35 | 40 |
| 36 class InputMethodEngine : public ui::IMEEngineHandlerInterface { | 41 class InputMethodEngine : public ::input_method::InputMethodEngineBase { |
| 37 public: | 42 public: |
| 38 InputMethodEngine(); | 43 InputMethodEngine(); |
| 39 | 44 |
| 40 ~InputMethodEngine() override; | 45 ~InputMethodEngine() override; |
| 41 | 46 |
| 42 void Initialize(scoped_ptr<ui::IMEEngineObserver> observer, | |
| 43 const char* extension_id, | |
| 44 Profile* profile); | |
| 45 | |
| 46 // IMEEngineHandlerInterface overrides. | 47 // IMEEngineHandlerInterface overrides. |
| 47 const std::string& GetActiveComponentId() const override; | |
| 48 bool SetComposition(int context_id, | |
| 49 const char* text, | |
| 50 int selection_start, | |
| 51 int selection_end, | |
| 52 int cursor, | |
| 53 const std::vector<SegmentInfo>& segments, | |
| 54 std::string* error) override; | |
| 55 bool ClearComposition(int context_id, std::string* error) override; | |
| 56 bool CommitText(int context_id, | |
| 57 const char* text, | |
| 58 std::string* error) override; | |
| 59 bool SendKeyEvents(int context_id, | 48 bool SendKeyEvents(int context_id, |
| 60 const std::vector<KeyboardEvent>& events) override; | 49 const std::vector<KeyboardEvent>& events) override; |
| 61 const CandidateWindowProperty& GetCandidateWindowProperty() const override; | 50 const CandidateWindowProperty& GetCandidateWindowProperty() const override; |
| 62 void SetCandidateWindowProperty( | 51 void SetCandidateWindowProperty( |
| 63 const CandidateWindowProperty& property) override; | 52 const CandidateWindowProperty& property) override; |
| 64 bool SetCandidateWindowVisible(bool visible, std::string* error) override; | 53 bool SetCandidateWindowVisible(bool visible, std::string* error) override; |
| 65 bool SetCandidates(int context_id, | 54 bool SetCandidates(int context_id, |
| 66 const std::vector<Candidate>& candidates, | 55 const std::vector<Candidate>& candidates, |
| 67 std::string* error) override; | 56 std::string* error) override; |
| 68 bool SetCursorPosition(int context_id, | 57 bool SetCursorPosition(int context_id, |
| 69 int candidate_id, | 58 int candidate_id, |
| 70 std::string* error) override; | 59 std::string* error) override; |
| 71 bool SetMenuItems(const std::vector<MenuItem>& items) override; | 60 bool SetMenuItems(const std::vector<MenuItem>& items) override; |
| 72 bool UpdateMenuItems(const std::vector<MenuItem>& items) override; | 61 bool UpdateMenuItems(const std::vector<MenuItem>& items) override; |
| 73 bool IsActive() const override; | 62 bool IsActive() const override; |
| 74 bool DeleteSurroundingText(int context_id, | |
| 75 int offset, | |
| 76 size_t number_of_chars, | |
| 77 std::string* error) override; | |
| 78 | |
| 79 // IMEEngineHandlerInterface overrides. | |
| 80 void FocusIn(const ui::IMEEngineHandlerInterface::InputContext& input_context) | |
| 81 override; | |
| 82 void FocusOut() override; | |
| 83 void Enable(const std::string& component_id) override; | 63 void Enable(const std::string& component_id) override; |
| 84 void Disable() override; | |
| 85 void PropertyActivate(const std::string& property_name) override; | 64 void PropertyActivate(const std::string& property_name) override; |
| 86 void Reset() override; | |
| 87 void ProcessKeyEvent(const ui::KeyEvent& key_event, | |
| 88 KeyEventDoneCallback& callback) override; | |
| 89 void CandidateClicked(uint32_t index) override; | 65 void CandidateClicked(uint32_t index) override; |
| 90 void SetSurroundingText(const std::string& text, | |
| 91 uint32_t cursor_pos, | |
| 92 uint32_t anchor_pos, | |
| 93 uint32_t offset_pos) override; | |
| 94 void HideInputView() override; | 66 void HideInputView() override; |
| 95 void SetCompositionBounds(const std::vector<gfx::Rect>& bounds) override; | |
| 96 | |
| 97 int GetCotextIdForTesting() { return context_id_; } | |
| 98 | |
| 99 bool IsInterestedInKeyEvent() const override; | |
| 100 | 67 |
| 101 private: | 68 private: |
| 102 bool CheckProfile() const; | |
| 103 // Converts MenuItem to InputMethodMenuItem. | 69 // Converts MenuItem to InputMethodMenuItem. |
| 104 void MenuItemToProperty(const MenuItem& item, | 70 void MenuItemToProperty(const MenuItem& item, |
| 105 ui::ime::InputMethodMenuItem* property); | 71 ui::ime::InputMethodMenuItem* property); |
| 106 | 72 |
| 107 // Enables overriding input view page to Virtual Keyboard window. | 73 // Enables overriding input view page to Virtual Keyboard window. |
| 108 void EnableInputView(); | 74 void EnableInputView(); |
| 109 | 75 |
| 110 ui::TextInputType current_input_type_; | |
| 111 | |
| 112 // ID that is used for the current input context. False if there is no focus. | |
| 113 int context_id_; | |
| 114 | |
| 115 // Next id that will be assigned to a context. | |
| 116 int next_context_id_; | |
| 117 | |
| 118 // The input_component ID in IME extension's manifest. | |
| 119 std::string active_component_id_; | |
| 120 | |
| 121 // The IME extension ID. | |
| 122 std::string extension_id_; | |
| 123 | |
| 124 // The observer object recieving events for this IME. | |
| 125 scoped_ptr<ui::IMEEngineObserver> observer_; | |
| 126 | |
| 127 // The current preedit text, and it's cursor position. | |
| 128 scoped_ptr<ui::CompositionText> composition_text_; | |
| 129 int composition_cursor_; | |
| 130 | |
| 131 // The current candidate window. | 76 // The current candidate window. |
| 132 scoped_ptr<ui::CandidateWindow> candidate_window_; | 77 scoped_ptr<ui::CandidateWindow> candidate_window_; |
| 133 | 78 |
| 134 // The current candidate window property. | 79 // The current candidate window property. |
| 135 CandidateWindowProperty candidate_window_property_; | 80 CandidateWindowProperty candidate_window_property_; |
| 136 | 81 |
| 137 // Indicates whether the candidate window is visible. | 82 // Indicates whether the candidate window is visible. |
| 138 bool window_visible_; | 83 bool window_visible_; |
| 139 | 84 |
| 140 // Mapping of candidate index to candidate id. | 85 // Mapping of candidate index to candidate id. |
| 141 std::vector<int> candidate_ids_; | 86 std::vector<int> candidate_ids_; |
| 142 | 87 |
| 143 // Mapping of candidate id to index. | 88 // Mapping of candidate id to index. |
| 144 std::map<int, int> candidate_indexes_; | 89 std::map<int, int> candidate_indexes_; |
| 145 | |
| 146 // Used with SendKeyEvents and ProcessKeyEvent to check if the key event | |
| 147 // sent to ProcessKeyEvent is sent by SendKeyEvents. | |
| 148 const ui::KeyEvent* sent_key_event_; | |
| 149 | |
| 150 Profile* profile_; | |
| 151 }; | 90 }; |
| 152 | 91 |
| 153 } // namespace chromeos | 92 } // namespace chromeos |
| 154 | 93 |
| 155 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_ENGINE_H_ | 94 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_ENGINE_H_ |
| OLD | NEW |