Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: chrome/browser/chromeos/input_method/input_method_engine.h

Issue 433163005: Refactoring for InputMethodEngine and InputMethodEventRouter. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed a bug. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 21 matching lines...) Expand all
32 struct KeyEventHandle; 32 struct KeyEventHandle;
33 } // namespace input_method 33 } // namespace input_method
34 34
35 class InputMethodEngine : public InputMethodEngineInterface { 35 class InputMethodEngine : public InputMethodEngineInterface {
36 public: 36 public:
37 InputMethodEngine(); 37 InputMethodEngine();
38 38
39 virtual ~InputMethodEngine(); 39 virtual ~InputMethodEngine();
40 40
41 void Initialize(scoped_ptr<InputMethodEngineInterface::Observer> observer, 41 void Initialize(scoped_ptr<InputMethodEngineInterface::Observer> observer,
42 const char* engine_name, 42 const char* extension_id);
43 const char* extension_id,
44 const char* engine_id,
45 const std::vector<std::string>& languages,
46 const std::vector<std::string>& layouts,
47 const GURL& options_page,
48 const GURL& input_view);
49 43
50 // InputMethodEngineInterface overrides. 44 // InputMethodEngineInterface overrides.
51 virtual const input_method::InputMethodDescriptor& GetDescriptor() 45 virtual const std::string& GetActiveEngineId() const OVERRIDE;
52 const OVERRIDE;
53 virtual void NotifyImeReady() OVERRIDE;
54 virtual bool SetComposition(int context_id, 46 virtual bool SetComposition(int context_id,
55 const char* text, 47 const char* text,
56 int selection_start, 48 int selection_start,
57 int selection_end, 49 int selection_end,
58 int cursor, 50 int cursor,
59 const std::vector<SegmentInfo>& segments, 51 const std::vector<SegmentInfo>& segments,
60 std::string* error) OVERRIDE; 52 std::string* error) OVERRIDE;
61 virtual bool ClearComposition(int context_id, std::string* error) OVERRIDE; 53 virtual bool ClearComposition(int context_id, std::string* error) OVERRIDE;
62 virtual bool CommitText(int context_id, const char* text, 54 virtual bool CommitText(int context_id, const char* text,
63 std::string* error) OVERRIDE; 55 std::string* error) OVERRIDE;
(...skipping 15 matching lines...) Expand all
79 virtual bool IsActive() const OVERRIDE; 71 virtual bool IsActive() const OVERRIDE;
80 virtual bool DeleteSurroundingText(int context_id, 72 virtual bool DeleteSurroundingText(int context_id,
81 int offset, 73 int offset,
82 size_t number_of_chars, 74 size_t number_of_chars,
83 std::string* error) OVERRIDE; 75 std::string* error) OVERRIDE;
84 76
85 // IMEEngineHandlerInterface overrides. 77 // IMEEngineHandlerInterface overrides.
86 virtual void FocusIn( 78 virtual void FocusIn(
87 const IMEEngineHandlerInterface::InputContext& input_context) OVERRIDE; 79 const IMEEngineHandlerInterface::InputContext& input_context) OVERRIDE;
88 virtual void FocusOut() OVERRIDE; 80 virtual void FocusOut() OVERRIDE;
89 virtual void Enable() OVERRIDE; 81 virtual void Enable(const std::string& engine_id) OVERRIDE;
90 virtual void Disable() OVERRIDE; 82 virtual void Disable() OVERRIDE;
91 virtual void PropertyActivate(const std::string& property_name) OVERRIDE; 83 virtual void PropertyActivate(const std::string& property_name) OVERRIDE;
92 virtual void Reset() OVERRIDE; 84 virtual void Reset() OVERRIDE;
93 virtual void ProcessKeyEvent(const ui::KeyEvent& key_event, 85 virtual void ProcessKeyEvent(const ui::KeyEvent& key_event,
94 const KeyEventDoneCallback& callback) OVERRIDE; 86 const KeyEventDoneCallback& callback) OVERRIDE;
95 virtual void CandidateClicked(uint32 index) OVERRIDE; 87 virtual void CandidateClicked(uint32 index) OVERRIDE;
96 virtual void SetSurroundingText(const std::string& text, uint32 cursor_pos, 88 virtual void SetSurroundingText(const std::string& text, uint32 cursor_pos,
97 uint32 anchor_pos) OVERRIDE; 89 uint32 anchor_pos) OVERRIDE;
98 virtual void HideInputView() OVERRIDE; 90 virtual void HideInputView() OVERRIDE;
99 91
100 private: 92 private:
101 void RecordHistogram(const char* name, int count); 93 void RecordHistogram(const char* name, int count);
102 94
103 // Converts MenuItem to InputMethodMenuItem. 95 // Converts MenuItem to InputMethodMenuItem.
104 void MenuItemToProperty(const MenuItem& item, 96 void MenuItemToProperty(const MenuItem& item,
105 ash::ime::InputMethodMenuItem* property); 97 ash::ime::InputMethodMenuItem* property);
106 98
107 // Enables or disables overriding input view page to Virtual Keyboard window. 99 // Enables overriding input view page to Virtual Keyboard window.
108 void EnableInputView(bool enabled); 100 void EnableInputView();
109
110 // Descriptor of this input method.
111 input_method::InputMethodDescriptor descriptor_;
112 101
113 ui::TextInputType current_input_type_; 102 ui::TextInputType current_input_type_;
114 103
115 // True if this engine is active.
116 bool active_;
117
118 // ID that is used for the current input context. False if there is no focus. 104 // ID that is used for the current input context. False if there is no focus.
119 int context_id_; 105 int context_id_;
120 106
121 // Next id that will be assigned to a context. 107 // Next id that will be assigned to a context.
122 int next_context_id_; 108 int next_context_id_;
123 109
124 // This IME ID in Chrome Extension. 110 // This IME ID in Chrome Extension.
Yuki 2014/08/05 07:57:18 Could you brush up this comment? This is unclear.
Shu Chen 2014/08/05 14:04:31 Done. Yes, it is input_component ID in IME extensi
125 std::string engine_id_; 111 std::string active_engine_id_;
126 112
127 // This IME's Chrome Extension ID. 113 // This IME's Chrome Extension ID.
128 std::string extension_id_; 114 std::string extension_id_;
129 115
130 // This IME ID in InputMethodManager.
131 std::string imm_id_;
132
133 // The observer object recieving events for this IME. 116 // The observer object recieving events for this IME.
134 scoped_ptr<InputMethodEngineInterface::Observer> observer_; 117 scoped_ptr<InputMethodEngineInterface::Observer> observer_;
135 118
136 // The current preedit text, and it's cursor position. 119 // The current preedit text, and it's cursor position.
137 scoped_ptr<CompositionText> composition_text_; 120 scoped_ptr<CompositionText> composition_text_;
138 int composition_cursor_; 121 int composition_cursor_;
139 122
140 // The current candidate window. 123 // The current candidate window.
141 scoped_ptr<ui::CandidateWindow> candidate_window_; 124 scoped_ptr<ui::CandidateWindow> candidate_window_;
142 125
143 // The current candidate window property. 126 // The current candidate window property.
144 CandidateWindowProperty candidate_window_property_; 127 CandidateWindowProperty candidate_window_property_;
145 128
146 // Indicates whether the candidate window is visible. 129 // Indicates whether the candidate window is visible.
147 bool window_visible_; 130 bool window_visible_;
148 131
149 // Mapping of candidate index to candidate id. 132 // Mapping of candidate index to candidate id.
150 std::vector<int> candidate_ids_; 133 std::vector<int> candidate_ids_;
151 134
152 // Mapping of candidate id to index. 135 // Mapping of candidate id to index.
153 std::map<int, int> candidate_indexes_; 136 std::map<int, int> candidate_indexes_;
154 137
155 // Used for input view window.
156 GURL input_view_url_;
157
158 // Used with SendKeyEvents and ProcessKeyEvent to check if the key event 138 // Used with SendKeyEvents and ProcessKeyEvent to check if the key event
159 // sent to ProcessKeyEvent is sent by SendKeyEvents. 139 // sent to ProcessKeyEvent is sent by SendKeyEvents.
160 const ui::KeyEvent* sent_key_event_; 140 const ui::KeyEvent* sent_key_event_;
161 141
162 // The start & end time of using this input method. This is for UMA. 142 // The start & end time of using this input method. This is for UMA.
163 base::Time start_time_; 143 base::Time start_time_;
164 base::Time end_time_; 144 base::Time end_time_;
165 }; 145 };
166 146
167 } // namespace chromeos 147 } // namespace chromeos
168 148
169 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_ENGINE_H_ 149 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_ENGINE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698