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