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

Side by Side Diff: chrome/browser/chromeos/input_method/mock_input_method_manager.cc

Issue 419293002: IME refactoring: ChromeOS introduce input methods State. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup. 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "chrome/browser/chromeos/input_method/mock_input_method_manager.h" 5 #include "chrome/browser/chromeos/input_method/mock_input_method_manager.h"
6 6
7 namespace chromeos { 7 namespace chromeos {
8 namespace input_method { 8 namespace input_method {
9 9
10 MockInputMethodManager::State::State() {
11 active_input_method_ids.push_back("xkb:us::eng");
12 }
13
14 MockInputMethodManager::State::~State() {
15 }
16
10 MockInputMethodManager::MockInputMethodManager() 17 MockInputMethodManager::MockInputMethodManager()
11 : add_observer_count_(0), 18 : add_observer_count_(0),
12 remove_observer_count_(0), 19 remove_observer_count_(0),
20 state_(new State()),
13 util_(&delegate_), 21 util_(&delegate_),
14 mod3_used_(false) { 22 mod3_used_(false) {
15 active_input_method_ids_.push_back("xkb:us::eng");
16 } 23 }
17 24
18 MockInputMethodManager::~MockInputMethodManager() { 25 MockInputMethodManager::~MockInputMethodManager() {
19 } 26 }
20 27
21 void MockInputMethodManager::InitializeComponentExtension() { 28 void MockInputMethodManager::InitializeComponentExtension(Profile* profile) {
22 } 29 }
23 30
24 void MockInputMethodManager::AddObserver( 31 void MockInputMethodManager::AddObserver(
25 InputMethodManager::Observer* observer) { 32 InputMethodManager::Observer* observer) {
26 ++add_observer_count_; 33 ++add_observer_count_;
27 } 34 }
28 35
29 void MockInputMethodManager::AddCandidateWindowObserver( 36 void MockInputMethodManager::AddCandidateWindowObserver(
30 InputMethodManager::CandidateWindowObserver* observer) { 37 InputMethodManager::CandidateWindowObserver* observer) {
31 } 38 }
32 39
33 void MockInputMethodManager::RemoveObserver( 40 void MockInputMethodManager::RemoveObserver(
34 InputMethodManager::Observer* observer) { 41 InputMethodManager::Observer* observer) {
35 ++remove_observer_count_; 42 ++remove_observer_count_;
36 } 43 }
37 44
38 void MockInputMethodManager::RemoveCandidateWindowObserver( 45 void MockInputMethodManager::RemoveCandidateWindowObserver(
39 InputMethodManager::CandidateWindowObserver* observer) { 46 InputMethodManager::CandidateWindowObserver* observer) {
40 } 47 }
41 48
42 scoped_ptr<InputMethodDescriptors> 49 scoped_ptr<InputMethodDescriptors>
43 MockInputMethodManager::GetSupportedInputMethods() const { 50 MockInputMethodManager::GetSupportedInputMethods() const {
44 scoped_ptr<InputMethodDescriptors> result(new InputMethodDescriptors); 51 scoped_ptr<InputMethodDescriptors> result(new InputMethodDescriptors);
45 result->push_back( 52 result->push_back(
46 InputMethodUtil::GetFallbackInputMethodDescriptor()); 53 InputMethodUtil::GetFallbackInputMethodDescriptor());
47 return result.Pass(); 54 return result.Pass();
48 } 55 }
49 56
50 scoped_ptr<InputMethodDescriptors> 57 scoped_ptr<InputMethodDescriptors>
51 MockInputMethodManager::GetActiveInputMethods() const { 58 MockInputMethodManager::State::GetActiveInputMethods() const {
52 scoped_ptr<InputMethodDescriptors> result(new InputMethodDescriptors); 59 scoped_ptr<InputMethodDescriptors> result(new InputMethodDescriptors);
53 result->push_back( 60 result->push_back(
54 InputMethodUtil::GetFallbackInputMethodDescriptor()); 61 InputMethodUtil::GetFallbackInputMethodDescriptor());
55 return result.Pass(); 62 return result.Pass();
56 } 63 }
57 64
58 const std::vector<std::string>& 65 const std::vector<std::string>&
59 MockInputMethodManager::GetActiveInputMethodIds() const { 66 MockInputMethodManager::State::GetActiveInputMethodIds() const {
60 return active_input_method_ids_; 67 return active_input_method_ids;
61 } 68 }
62 69
63 size_t MockInputMethodManager::GetNumActiveInputMethods() const { 70 size_t MockInputMethodManager::State::GetNumActiveInputMethods() const {
64 return 1; 71 return 1;
65 } 72 }
66 73
67 const InputMethodDescriptor* MockInputMethodManager::GetInputMethodFromId( 74 const InputMethodDescriptor*
75 MockInputMethodManager::State::GetInputMethodFromId(
68 const std::string& input_method_id) const { 76 const std::string& input_method_id) const {
69 static const InputMethodDescriptor defaultInputMethod = 77 static const InputMethodDescriptor defaultInputMethod =
70 InputMethodUtil::GetFallbackInputMethodDescriptor(); 78 InputMethodUtil::GetFallbackInputMethodDescriptor();
71 for (size_t i = 0; i < active_input_method_ids_.size(); i++) { 79 for (size_t i = 0; i < active_input_method_ids.size(); i++) {
72 if (input_method_id == active_input_method_ids_[i]) { 80 if (input_method_id == active_input_method_ids[i]) {
73 return &defaultInputMethod; 81 return &defaultInputMethod;
74 } 82 }
75 } 83 }
76 return NULL; 84 return NULL;
77 } 85 }
78 86
79 void MockInputMethodManager::EnableLoginLayouts( 87 void MockInputMethodManager::State::EnableLoginLayouts(
80 const std::string& language_code, 88 const std::string& language_code,
81 const std::vector<std::string>& initial_layout) { 89 const std::vector<std::string>& initial_layout) {
82 } 90 }
83 91
84 bool MockInputMethodManager::ReplaceEnabledInputMethods( 92 void MockInputMethodManager::State::EnableLockScreenLayouts() {
93 }
94
95 bool MockInputMethodManager::State::ReplaceEnabledInputMethods(
85 const std::vector<std::string>& new_active_input_method_ids) { 96 const std::vector<std::string>& new_active_input_method_ids) {
86 return true; 97 return true;
87 } 98 }
88 99
89 bool MockInputMethodManager::EnableInputMethod( 100 bool MockInputMethodManager::State::EnableInputMethod(
90 const std::string& new_active_input_method_id) { 101 const std::string& new_active_input_method_id) {
91 return true; 102 return true;
92 } 103 }
93 104
94 void MockInputMethodManager::ChangeInputMethod( 105 void MockInputMethodManager::State::ChangeInputMethod(
95 const std::string& input_method_id) { 106 const std::string& input_method_id,
107 bool show_message) {
96 } 108 }
97 109
98 void MockInputMethodManager::ActivateInputMethodMenuItem( 110 void MockInputMethodManager::ActivateInputMethodMenuItem(
99 const std::string& key) { 111 const std::string& key) {
100 } 112 }
101 113
102 void MockInputMethodManager::AddInputMethodExtension( 114 void MockInputMethodManager::State::AddInputMethodExtension(
103 const std::string& extension_id, 115 const std::string& extension_id,
104 const InputMethodDescriptors& descriptors, 116 const InputMethodDescriptors& descriptors,
105 InputMethodEngineInterface* instance) { 117 InputMethodEngineInterface* instance) {
106 } 118 }
107 119
108 void MockInputMethodManager::RemoveInputMethodExtension( 120 void MockInputMethodManager::State::RemoveInputMethodExtension(
109 const std::string& extension_id) { 121 const std::string& extension_id) {
110 } 122 }
111 123
112 void MockInputMethodManager::GetInputMethodExtensions( 124 void MockInputMethodManager::State::GetInputMethodExtensions(
113 InputMethodDescriptors* result) { 125 InputMethodDescriptors* result) {
114 } 126 }
115 127
116 void MockInputMethodManager::SetEnabledExtensionImes( 128 void MockInputMethodManager::State::SetEnabledExtensionImes(
117 std::vector<std::string>* ids) { 129 std::vector<std::string>* ids) {
118 } 130 }
119 131
120 void MockInputMethodManager::SetInputMethodLoginDefault() { 132 void MockInputMethodManager::State::SetInputMethodLoginDefault() {
121 } 133 }
122 134
123 void MockInputMethodManager::SetInputMethodLoginDefaultFromVPD( 135 void MockInputMethodManager::State::SetInputMethodLoginDefaultFromVPD(
124 const std::string& locale, const std::string& layout) { 136 const std::string& locale,
137 const std::string& layout) {
125 } 138 }
126 139
127 bool MockInputMethodManager::SwitchToNextInputMethod() { 140 bool MockInputMethodManager::State::SwitchToNextInputMethod() {
128 return true; 141 return true;
129 } 142 }
130 143
131 bool MockInputMethodManager::SwitchToPreviousInputMethod( 144 bool MockInputMethodManager::State::SwitchToPreviousInputMethod(
132 const ui::Accelerator& accelerator) { 145 const ui::Accelerator& accelerator) {
133 return true; 146 return true;
134 } 147 }
135 148
136 bool MockInputMethodManager::SwitchInputMethod( 149 bool MockInputMethodManager::State::SwitchInputMethod(
137 const ui::Accelerator& accelerator) { 150 const ui::Accelerator& accelerator) {
138 return true; 151 return true;
139 } 152 }
140 153
141 InputMethodDescriptor MockInputMethodManager::GetCurrentInputMethod() const { 154 InputMethodDescriptor MockInputMethodManager::State::GetCurrentInputMethod()
155 const {
142 InputMethodDescriptor descriptor = 156 InputMethodDescriptor descriptor =
143 InputMethodUtil::GetFallbackInputMethodDescriptor(); 157 InputMethodUtil::GetFallbackInputMethodDescriptor();
144 if (!current_input_method_id_.empty()) { 158 if (!current_input_method_id.empty()) {
145 return InputMethodDescriptor(current_input_method_id_, 159 return InputMethodDescriptor(current_input_method_id,
146 descriptor.name(), 160 descriptor.name(),
147 descriptor.indicator(), 161 descriptor.indicator(),
148 descriptor.keyboard_layouts(), 162 descriptor.keyboard_layouts(),
149 descriptor.language_codes(), 163 descriptor.language_codes(),
150 true, 164 true,
151 GURL(), // options page url. 165 GURL(), // options page url.
152 GURL()); // input view page url. 166 GURL()); // input view page url.
153 } 167 }
154 return descriptor; 168 return descriptor;
155 } 169 }
156 170
157 bool MockInputMethodManager::IsISOLevel5ShiftUsedByCurrentInputMethod() const { 171 bool MockInputMethodManager::IsISOLevel5ShiftUsedByCurrentInputMethod() const {
158 return mod3_used_; 172 return mod3_used_;
159 } 173 }
160 174
161 bool MockInputMethodManager::IsAltGrUsedByCurrentInputMethod() const { 175 bool MockInputMethodManager::IsAltGrUsedByCurrentInputMethod() const {
(...skipping 23 matching lines...) Expand all
185 bool MockInputMethodManager::IsLoginKeyboard( 199 bool MockInputMethodManager::IsLoginKeyboard(
186 const std::string& layout) const { 200 const std::string& layout) const {
187 return true; 201 return true;
188 } 202 }
189 203
190 bool MockInputMethodManager::MigrateInputMethods( 204 bool MockInputMethodManager::MigrateInputMethods(
191 std::vector<std::string>* input_method_ids) { 205 std::vector<std::string>* input_method_ids) {
192 return false; 206 return false;
193 } 207 }
194 208
209 scoped_refptr<InputMethodManager::State>
210 MockInputMethodManager::GetDefaultState(Profile* profile) {
211 return state_;
212 }
213
214 scoped_refptr<InputMethodManager::State>
215 MockInputMethodManager::GetActiveIMEState() {
216 return scoped_refptr<InputMethodManager::State>(state_.get());
217 }
218
219 scoped_refptr<InputMethodManager::State> MockInputMethodManager::CloneState(
220 const InputMethodManager::State* state) {
221 NOTIMPLEMENTED();
222 return GetActiveIMEState();
223 }
224
225 void MockInputMethodManager::SetState(
226 scoped_refptr<InputMethodManager::State> state) {
227 state_ = scoped_refptr<MockInputMethodManager::State>(
228 static_cast<MockInputMethodManager::State*>(state.get()));
229 }
230
231 void MockInputMethodManager::SetCurrentInputMethodId(
232 const std::string& input_method_id) {
233 state_->current_input_method_id = input_method_id;
234 }
235
195 } // namespace input_method 236 } // namespace input_method
196 } // namespace chromeos 237 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698