| 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 "chrome/browser/input_method/input_method_engine_base.h" |
| 16 #include "ui/base/ime/chromeos/input_method_descriptor.h" | 16 #include "ui/base/ime/chromeos/input_method_descriptor.h" |
| 17 #include "ui/base/ime/ime_engine_handler_interface.h" | 17 #include "ui/base/ime/ime_engine_handler_interface.h" |
| 18 #include "ui/base/ime/ime_engine_observer.h" | |
| 19 #include "url/gurl.h" | 18 #include "url/gurl.h" |
| 20 | 19 |
| 21 class Profile; | 20 class Profile; |
| 22 | 21 |
| 23 namespace ui { | 22 namespace ui { |
| 24 class CandidateWindow; | 23 class CandidateWindow; |
| 25 struct CompositionText; | 24 struct CompositionText; |
| 26 class IMEEngineHandlerInterface; | 25 class IMEEngineHandlerInterface; |
| 27 class IMEEngineObserver; | |
| 28 class KeyEvent; | 26 class KeyEvent; |
| 29 | 27 |
| 30 namespace ime { | 28 namespace ime { |
| 31 struct InputMethodMenuItem; | 29 struct InputMethodMenuItem; |
| 32 } // namespace ime | 30 } // namespace ime |
| 33 } // namespace ui | 31 } // namespace ui |
| 34 | 32 |
| 35 namespace input_method { | 33 namespace input_method { |
| 36 class InputMethodEngineBase; | 34 class InputMethodEngineBase; |
| 37 } | 35 } |
| 38 | 36 |
| 39 namespace chromeos { | 37 namespace chromeos { |
| 40 | 38 |
| 41 class InputMethodEngine : public ::input_method::InputMethodEngineBase { | 39 class InputMethodEngine : public ::input_method::InputMethodEngineBase { |
| 42 public: | 40 public: |
| 41 enum { |
| 42 MENU_ITEM_MODIFIED_LABEL = 0x0001, |
| 43 MENU_ITEM_MODIFIED_STYLE = 0x0002, |
| 44 MENU_ITEM_MODIFIED_VISIBLE = 0x0004, |
| 45 MENU_ITEM_MODIFIED_ENABLED = 0x0008, |
| 46 MENU_ITEM_MODIFIED_CHECKED = 0x0010, |
| 47 MENU_ITEM_MODIFIED_ICON = 0x0020, |
| 48 }; |
| 49 |
| 50 enum MenuItemStyle { |
| 51 MENU_ITEM_STYLE_NONE, |
| 52 MENU_ITEM_STYLE_CHECK, |
| 53 MENU_ITEM_STYLE_RADIO, |
| 54 MENU_ITEM_STYLE_SEPARATOR, |
| 55 }; |
| 56 |
| 57 enum CandidateWindowPosition { |
| 58 WINDOW_POS_CURSOR, |
| 59 WINDOW_POS_COMPOSITTION, |
| 60 }; |
| 61 |
| 62 struct MenuItem { |
| 63 MenuItem(); |
| 64 virtual ~MenuItem(); |
| 65 |
| 66 std::string id; |
| 67 std::string label; |
| 68 MenuItemStyle style; |
| 69 bool visible; |
| 70 bool enabled; |
| 71 bool checked; |
| 72 |
| 73 unsigned int modified; |
| 74 std::vector<MenuItem> children; |
| 75 }; |
| 76 |
| 77 struct UsageEntry { |
| 78 std::string title; |
| 79 std::string body; |
| 80 }; |
| 81 |
| 82 struct Candidate { |
| 83 Candidate(); |
| 84 virtual ~Candidate(); |
| 85 |
| 86 std::string value; |
| 87 int id; |
| 88 std::string label; |
| 89 std::string annotation; |
| 90 UsageEntry usage; |
| 91 std::vector<Candidate> candidates; |
| 92 }; |
| 93 |
| 94 struct CandidateWindowProperty { |
| 95 CandidateWindowProperty(); |
| 96 virtual ~CandidateWindowProperty(); |
| 97 int page_size; |
| 98 bool is_cursor_visible; |
| 99 bool is_vertical; |
| 100 bool show_window_at_composition; |
| 101 |
| 102 // Auxiliary text is typically displayed in the footer of the candidate |
| 103 // window. |
| 104 std::string auxiliary_text; |
| 105 bool is_auxiliary_text_visible; |
| 106 }; |
| 107 |
| 43 InputMethodEngine(); | 108 InputMethodEngine(); |
| 44 | 109 |
| 45 ~InputMethodEngine() override; | 110 ~InputMethodEngine() override; |
| 46 | 111 |
| 47 // IMEEngineHandlerInterface overrides. | 112 // IMEEngineHandlerInterface overrides. |
| 48 bool SendKeyEvents(int context_id, | 113 bool SendKeyEvents(int context_id, |
| 49 const std::vector<KeyboardEvent>& events) override; | 114 const std::vector<KeyboardEvent>& events) override; |
| 50 const CandidateWindowProperty& GetCandidateWindowProperty() const override; | |
| 51 void SetCandidateWindowProperty( | |
| 52 const CandidateWindowProperty& property) override; | |
| 53 bool SetCandidateWindowVisible(bool visible, std::string* error) override; | 115 bool SetCandidateWindowVisible(bool visible, std::string* error) override; |
| 54 bool SetCandidates(int context_id, | |
| 55 const std::vector<Candidate>& candidates, | |
| 56 std::string* error) override; | |
| 57 bool SetCursorPosition(int context_id, | 116 bool SetCursorPosition(int context_id, |
| 58 int candidate_id, | 117 int candidate_id, |
| 59 std::string* error) override; | 118 std::string* error) override; |
| 60 bool SetMenuItems(const std::vector<MenuItem>& items) override; | |
| 61 bool UpdateMenuItems(const std::vector<MenuItem>& items) override; | |
| 62 bool IsActive() const override; | 119 bool IsActive() const override; |
| 63 void Enable(const std::string& component_id) override; | 120 void Enable(const std::string& component_id) override; |
| 64 void PropertyActivate(const std::string& property_name) override; | 121 void PropertyActivate(const std::string& property_name) override; |
| 65 void CandidateClicked(uint32_t index) override; | 122 void CandidateClicked(uint32_t index) override; |
| 66 void HideInputView() override; | 123 void HideInputView() override; |
| 67 | 124 |
| 125 // This function returns the current property of the candidate window. |
| 126 // The caller can use the returned value as the default property and |
| 127 // modify some of specified items. |
| 128 const CandidateWindowProperty& GetCandidateWindowProperty() const; |
| 129 |
| 130 // Change the property of the candidate window and repaint the candidate |
| 131 // window widget. |
| 132 void SetCandidateWindowProperty(const CandidateWindowProperty& property); |
| 133 |
| 134 // Set the list of entries displayed in the candidate window. |
| 135 bool SetCandidates(int context_id, |
| 136 const std::vector<Candidate>& candidates, |
| 137 std::string* error); |
| 138 |
| 139 // Set the list of items that appears in the language menu when this IME is |
| 140 // active. |
| 141 bool SetMenuItems(const std::vector<MenuItem>& items); |
| 142 |
| 143 // Update the state of the menu items. |
| 144 bool UpdateMenuItems(const std::vector<MenuItem>& items); |
| 145 |
| 68 private: | 146 private: |
| 69 // Converts MenuItem to InputMethodMenuItem. | 147 // Converts MenuItem to InputMethodMenuItem. |
| 70 void MenuItemToProperty(const MenuItem& item, | 148 void MenuItemToProperty(const MenuItem& item, |
| 71 ui::ime::InputMethodMenuItem* property); | 149 ui::ime::InputMethodMenuItem* property); |
| 72 | 150 |
| 73 // Enables overriding input view page to Virtual Keyboard window. | 151 // Enables overriding input view page to Virtual Keyboard window. |
| 74 void EnableInputView(); | 152 void EnableInputView(); |
| 75 | 153 |
| 76 // The current candidate window. | 154 // The current candidate window. |
| 77 scoped_ptr<ui::CandidateWindow> candidate_window_; | 155 scoped_ptr<ui::CandidateWindow> candidate_window_; |
| 78 | 156 |
| 79 // The current candidate window property. | 157 // The current candidate window property. |
| 80 CandidateWindowProperty candidate_window_property_; | 158 CandidateWindowProperty candidate_window_property_; |
| 81 | 159 |
| 82 // Indicates whether the candidate window is visible. | 160 // Indicates whether the candidate window is visible. |
| 83 bool window_visible_; | 161 bool window_visible_; |
| 84 | 162 |
| 85 // Mapping of candidate index to candidate id. | 163 // Mapping of candidate index to candidate id. |
| 86 std::vector<int> candidate_ids_; | 164 std::vector<int> candidate_ids_; |
| 87 | 165 |
| 88 // Mapping of candidate id to index. | 166 // Mapping of candidate id to index. |
| 89 std::map<int, int> candidate_indexes_; | 167 std::map<int, int> candidate_indexes_; |
| 90 }; | 168 }; |
| 91 | 169 |
| 92 } // namespace chromeos | 170 } // namespace chromeos |
| 93 | 171 |
| 94 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_ENGINE_H_ | 172 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_ENGINE_H_ |
| OLD | NEW |