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

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 browser_tests: ExtensionApiTest.InputImeApiBasic 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 22 matching lines...) Expand all
33 namespace input_method { 33 namespace input_method {
34 struct KeyEventHandle; 34 struct KeyEventHandle;
35 } // namespace input_method 35 } // namespace input_method
36 36
37 class InputMethodEngine : public InputMethodEngineInterface { 37 class InputMethodEngine : public InputMethodEngineInterface {
38 public: 38 public:
39 InputMethodEngine(); 39 InputMethodEngine();
40 40
41 virtual ~InputMethodEngine(); 41 virtual ~InputMethodEngine();
42 42
43 void Initialize(Profile* profile, 43 void Initialize(scoped_ptr<InputMethodEngineInterface::Observer> observer,
44 scoped_ptr<InputMethodEngineInterface::Observer> observer, 44 const char* extension_id);
45 const char* engine_name,
46 const char* extension_id,
47 const char* engine_id,
48 const std::vector<std::string>& languages,
49 const std::vector<std::string>& layouts,
50 const GURL& options_page,
51 const GURL& input_view);
52 45
53 // InputMethodEngineInterface overrides. 46 // InputMethodEngineInterface overrides.
54 virtual const input_method::InputMethodDescriptor& GetDescriptor() 47 virtual const std::string& GetActiveComponentId() const OVERRIDE;
55 const OVERRIDE;
56 virtual void NotifyImeReady() OVERRIDE;
57 virtual bool SetComposition(int context_id, 48 virtual bool SetComposition(int context_id,
58 const char* text, 49 const char* text,
59 int selection_start, 50 int selection_start,
60 int selection_end, 51 int selection_end,
61 int cursor, 52 int cursor,
62 const std::vector<SegmentInfo>& segments, 53 const std::vector<SegmentInfo>& segments,
63 std::string* error) OVERRIDE; 54 std::string* error) OVERRIDE;
64 virtual bool ClearComposition(int context_id, std::string* error) OVERRIDE; 55 virtual bool ClearComposition(int context_id, std::string* error) OVERRIDE;
65 virtual bool CommitText(int context_id, const char* text, 56 virtual bool CommitText(int context_id, const char* text,
66 std::string* error) OVERRIDE; 57 std::string* error) OVERRIDE;
(...skipping 15 matching lines...) Expand all
82 virtual bool IsActive() const OVERRIDE; 73 virtual bool IsActive() const OVERRIDE;
83 virtual bool DeleteSurroundingText(int context_id, 74 virtual bool DeleteSurroundingText(int context_id,
84 int offset, 75 int offset,
85 size_t number_of_chars, 76 size_t number_of_chars,
86 std::string* error) OVERRIDE; 77 std::string* error) OVERRIDE;
87 78
88 // IMEEngineHandlerInterface overrides. 79 // IMEEngineHandlerInterface overrides.
89 virtual void FocusIn( 80 virtual void FocusIn(
90 const IMEEngineHandlerInterface::InputContext& input_context) OVERRIDE; 81 const IMEEngineHandlerInterface::InputContext& input_context) OVERRIDE;
91 virtual void FocusOut() OVERRIDE; 82 virtual void FocusOut() OVERRIDE;
92 virtual void Enable() OVERRIDE; 83 virtual void Enable(const std::string& component_id) OVERRIDE;
93 virtual void Disable() OVERRIDE; 84 virtual void Disable() OVERRIDE;
94 virtual void PropertyActivate(const std::string& property_name) OVERRIDE; 85 virtual void PropertyActivate(const std::string& property_name) OVERRIDE;
95 virtual void Reset() OVERRIDE; 86 virtual void Reset() OVERRIDE;
96 virtual void ProcessKeyEvent(const ui::KeyEvent& key_event, 87 virtual void ProcessKeyEvent(const ui::KeyEvent& key_event,
97 const KeyEventDoneCallback& callback) OVERRIDE; 88 const KeyEventDoneCallback& callback) OVERRIDE;
98 virtual void CandidateClicked(uint32 index) OVERRIDE; 89 virtual void CandidateClicked(uint32 index) OVERRIDE;
99 virtual void SetSurroundingText(const std::string& text, uint32 cursor_pos, 90 virtual void SetSurroundingText(const std::string& text, uint32 cursor_pos,
100 uint32 anchor_pos) OVERRIDE; 91 uint32 anchor_pos) OVERRIDE;
101 virtual void HideInputView() OVERRIDE; 92 virtual void HideInputView() OVERRIDE;
102 93
103 private: 94 private:
104 void RecordHistogram(const char* name, int count); 95 void RecordHistogram(const char* name, int count);
105 96
106 // Converts MenuItem to InputMethodMenuItem. 97 // Converts MenuItem to InputMethodMenuItem.
107 void MenuItemToProperty(const MenuItem& item, 98 void MenuItemToProperty(const MenuItem& item,
108 ash::ime::InputMethodMenuItem* property); 99 ash::ime::InputMethodMenuItem* property);
109 100
110 // Enables or disables overriding input view page to Virtual Keyboard window. 101 // Enables overriding input view page to Virtual Keyboard window.
111 void EnableInputView(bool enabled); 102 void EnableInputView();
112
113 // Descriptor of this input method.
114 input_method::InputMethodDescriptor descriptor_;
115 103
116 ui::TextInputType current_input_type_; 104 ui::TextInputType current_input_type_;
117 105
118 // True if this engine is active.
119 bool active_;
120
121 // ID that is used for the current input context. False if there is no focus. 106 // ID that is used for the current input context. False if there is no focus.
122 int context_id_; 107 int context_id_;
123 108
124 // Next id that will be assigned to a context. 109 // Next id that will be assigned to a context.
125 int next_context_id_; 110 int next_context_id_;
126 111
127 // This IME ID in Chrome Extension. 112 // The input_component ID in IME extension's manifest.
128 std::string engine_id_; 113 std::string active_component_id_;
129 114
130 // This IME's Chrome Extension ID. 115 // The IME extension ID.
131 std::string extension_id_; 116 std::string extension_id_;
132 117
133 // This IME ID in InputMethodManager.
134 std::string imm_id_;
135
136 // The observer object recieving events for this IME. 118 // The observer object recieving events for this IME.
137 scoped_ptr<InputMethodEngineInterface::Observer> observer_; 119 scoped_ptr<InputMethodEngineInterface::Observer> observer_;
138 120
139 // The current preedit text, and it's cursor position. 121 // The current preedit text, and it's cursor position.
140 scoped_ptr<CompositionText> composition_text_; 122 scoped_ptr<CompositionText> composition_text_;
141 int composition_cursor_; 123 int composition_cursor_;
142 124
143 // The current candidate window. 125 // The current candidate window.
144 scoped_ptr<ui::CandidateWindow> candidate_window_; 126 scoped_ptr<ui::CandidateWindow> candidate_window_;
145 127
146 // The current candidate window property. 128 // The current candidate window property.
147 CandidateWindowProperty candidate_window_property_; 129 CandidateWindowProperty candidate_window_property_;
148 130
149 // Indicates whether the candidate window is visible. 131 // Indicates whether the candidate window is visible.
150 bool window_visible_; 132 bool window_visible_;
151 133
152 // Mapping of candidate index to candidate id. 134 // Mapping of candidate index to candidate id.
153 std::vector<int> candidate_ids_; 135 std::vector<int> candidate_ids_;
154 136
155 // Mapping of candidate id to index. 137 // Mapping of candidate id to index.
156 std::map<int, int> candidate_indexes_; 138 std::map<int, int> candidate_indexes_;
157 139
158 // Used for input view window.
159 GURL input_view_url_;
160
161 // Used with SendKeyEvents and ProcessKeyEvent to check if the key event 140 // Used with SendKeyEvents and ProcessKeyEvent to check if the key event
162 // sent to ProcessKeyEvent is sent by SendKeyEvents. 141 // sent to ProcessKeyEvent is sent by SendKeyEvents.
163 const ui::KeyEvent* sent_key_event_; 142 const ui::KeyEvent* sent_key_event_;
164 143
165 // The start & end time of using this input method. This is for UMA. 144 // The start & end time of using this input method. This is for UMA.
166 base::Time start_time_; 145 base::Time start_time_;
167 base::Time end_time_; 146 base::Time end_time_;
168
169 // User profile that owns this method.
170 Profile* profile_;
171 }; 147 };
172 148
173 } // namespace chromeos 149 } // namespace chromeos
174 150
175 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_ENGINE_H_ 151 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_ENGINE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698