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

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: nits. 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 or disables overriding input view page to Virtual Keyboard window.
108 void EnableInputView(bool enabled); 100 void EnableInputView(bool enabled);
109 101
110 // Descriptor of this input method. 102 // Gets the active input method descriptior from InputMethodManager.
111 input_method::InputMethodDescriptor descriptor_; 103 const input_method::InputMethodDescriptor* GetCurrentInputMethod();
112 104
113 ui::TextInputType current_input_type_; 105 ui::TextInputType current_input_type_;
114 106
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. 107 // ID that is used for the current input context. False if there is no focus.
119 int context_id_; 108 int context_id_;
120 109
121 // Next id that will be assigned to a context. 110 // Next id that will be assigned to a context.
122 int next_context_id_; 111 int next_context_id_;
123 112
124 // This IME ID in Chrome Extension. 113 // This IME ID in Chrome Extension.
125 std::string engine_id_; 114 std::string active_engine_id_;
126 115
127 // This IME's Chrome Extension ID. 116 // This IME's Chrome Extension ID.
128 std::string extension_id_; 117 std::string extension_id_;
129 118
130 // This IME ID in InputMethodManager.
131 std::string imm_id_;
132
133 // The observer object recieving events for this IME. 119 // The observer object recieving events for this IME.
134 scoped_ptr<InputMethodEngineInterface::Observer> observer_; 120 scoped_ptr<InputMethodEngineInterface::Observer> observer_;
135 121
136 // The current preedit text, and it's cursor position. 122 // The current preedit text, and it's cursor position.
137 scoped_ptr<CompositionText> composition_text_; 123 scoped_ptr<CompositionText> composition_text_;
138 int composition_cursor_; 124 int composition_cursor_;
139 125
140 // The current candidate window. 126 // The current candidate window.
141 scoped_ptr<ui::CandidateWindow> candidate_window_; 127 scoped_ptr<ui::CandidateWindow> candidate_window_;
142 128
143 // The current candidate window property. 129 // The current candidate window property.
144 CandidateWindowProperty candidate_window_property_; 130 CandidateWindowProperty candidate_window_property_;
145 131
146 // Indicates whether the candidate window is visible. 132 // Indicates whether the candidate window is visible.
147 bool window_visible_; 133 bool window_visible_;
148 134
149 // Mapping of candidate index to candidate id. 135 // Mapping of candidate index to candidate id.
150 std::vector<int> candidate_ids_; 136 std::vector<int> candidate_ids_;
151 137
152 // Mapping of candidate id to index. 138 // Mapping of candidate id to index.
153 std::map<int, int> candidate_indexes_; 139 std::map<int, int> candidate_indexes_;
154 140
155 // Used for input view window.
156 GURL input_view_url_;
157
158 // Used with SendKeyEvents and ProcessKeyEvent to check if the key event 141 // Used with SendKeyEvents and ProcessKeyEvent to check if the key event
159 // sent to ProcessKeyEvent is sent by SendKeyEvents. 142 // sent to ProcessKeyEvent is sent by SendKeyEvents.
160 const ui::KeyEvent* sent_key_event_; 143 const ui::KeyEvent* sent_key_event_;
161 144
162 // The start & end time of using this input method. This is for UMA. 145 // The start & end time of using this input method. This is for UMA.
163 base::Time start_time_; 146 base::Time start_time_;
164 base::Time end_time_; 147 base::Time end_time_;
165 }; 148 };
166 149
167 } // namespace chromeos 150 } // namespace chromeos
168 151
169 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_ENGINE_H_ 152 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_ENGINE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698