Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / chromeos / input_method / mock_input_method_manager.cc
blob7254bf91d4ba9dae7309c88739d88291bb2ddd24
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
3 // found in the LICENSE file.
5 #include "chrome/browser/chromeos/input_method/mock_input_method_manager.h"
7 namespace chromeos {
8 namespace input_method {
10 MockInputMethodManager::State::State(MockInputMethodManager* manager)
11 : manager_(manager) {
12 active_input_method_ids.push_back("xkb:us::eng");
15 MockInputMethodManager::State::~State() {
18 MockInputMethodManager::MockInputMethodManager()
19 : add_observer_count_(0),
20 remove_observer_count_(0),
21 state_(new State(this)),
22 util_(&delegate_),
23 mod3_used_(false) {
26 MockInputMethodManager::~MockInputMethodManager() {
29 InputMethodManager::UISessionState MockInputMethodManager::GetUISessionState() {
30 return InputMethodManager::STATE_BROWSER_SCREEN;
33 void MockInputMethodManager::AddObserver(
34 InputMethodManager::Observer* observer) {
35 ++add_observer_count_;
38 void MockInputMethodManager::AddCandidateWindowObserver(
39 InputMethodManager::CandidateWindowObserver* observer) {
42 void MockInputMethodManager::RemoveObserver(
43 InputMethodManager::Observer* observer) {
44 ++remove_observer_count_;
47 void MockInputMethodManager::RemoveCandidateWindowObserver(
48 InputMethodManager::CandidateWindowObserver* observer) {
51 scoped_ptr<InputMethodDescriptors>
52 MockInputMethodManager::GetSupportedInputMethods() const {
53 scoped_ptr<InputMethodDescriptors> result(new InputMethodDescriptors);
54 result->push_back(
55 InputMethodUtil::GetFallbackInputMethodDescriptor());
56 return result.Pass();
59 scoped_ptr<InputMethodDescriptors>
60 MockInputMethodManager::State::GetActiveInputMethods() const {
61 scoped_ptr<InputMethodDescriptors> result(new InputMethodDescriptors);
62 result->push_back(
63 InputMethodUtil::GetFallbackInputMethodDescriptor());
64 return result.Pass();
67 const std::vector<std::string>&
68 MockInputMethodManager::State::GetActiveInputMethodIds() const {
69 return active_input_method_ids;
72 size_t MockInputMethodManager::State::GetNumActiveInputMethods() const {
73 return 1;
76 const InputMethodDescriptor*
77 MockInputMethodManager::State::GetInputMethodFromId(
78 const std::string& input_method_id) const {
79 static const InputMethodDescriptor defaultInputMethod =
80 InputMethodUtil::GetFallbackInputMethodDescriptor();
81 for (size_t i = 0; i < active_input_method_ids.size(); i++) {
82 if (input_method_id == active_input_method_ids[i]) {
83 return &defaultInputMethod;
86 return NULL;
89 void MockInputMethodManager::State::EnableLoginLayouts(
90 const std::string& language_code,
91 const std::vector<std::string>& initial_layout) {
94 void MockInputMethodManager::State::EnableLockScreenLayouts() {
97 bool MockInputMethodManager::State::ReplaceEnabledInputMethods(
98 const std::vector<std::string>& new_active_input_method_ids) {
99 return true;
102 bool MockInputMethodManager::State::EnableInputMethod(
103 const std::string& new_active_input_method_id) {
104 return true;
107 void MockInputMethodManager::State::ChangeInputMethod(
108 const std::string& input_method_id,
109 bool show_message) {
112 void MockInputMethodManager::ActivateInputMethodMenuItem(
113 const std::string& key) {
116 void MockInputMethodManager::State::AddInputMethodExtension(
117 const std::string& extension_id,
118 const InputMethodDescriptors& descriptors,
119 InputMethodEngineInterface* instance) {
122 void MockInputMethodManager::State::RemoveInputMethodExtension(
123 const std::string& extension_id) {
126 void MockInputMethodManager::State::GetInputMethodExtensions(
127 InputMethodDescriptors* result) {
130 void MockInputMethodManager::State::SetEnabledExtensionImes(
131 std::vector<std::string>* ids) {
134 void MockInputMethodManager::State::SetInputMethodLoginDefault() {
137 void MockInputMethodManager::State::SetInputMethodLoginDefaultFromVPD(
138 const std::string& locale,
139 const std::string& layout) {
142 bool MockInputMethodManager::State::CanCycleInputMethod() {
143 return true;
146 void MockInputMethodManager::State::SwitchToNextInputMethod() {
149 void MockInputMethodManager::State::SwitchToPreviousInputMethod() {
152 bool MockInputMethodManager::State::CanSwitchInputMethod(
153 const ui::Accelerator& accelerator) {
154 return true;
157 void MockInputMethodManager::State::SwitchInputMethod(
158 const ui::Accelerator& accelerator) {
161 InputMethodDescriptor MockInputMethodManager::State::GetCurrentInputMethod()
162 const {
163 InputMethodDescriptor descriptor =
164 InputMethodUtil::GetFallbackInputMethodDescriptor();
165 if (!current_input_method_id.empty()) {
166 return InputMethodDescriptor(current_input_method_id,
167 descriptor.name(),
168 descriptor.indicator(),
169 descriptor.keyboard_layouts(),
170 descriptor.language_codes(),
171 true,
172 GURL(), // options page url.
173 GURL()); // input view page url.
175 return descriptor;
178 bool MockInputMethodManager::IsISOLevel5ShiftUsedByCurrentInputMethod() const {
179 return mod3_used_;
182 bool MockInputMethodManager::IsAltGrUsedByCurrentInputMethod() const {
183 return false;
186 ImeKeyboard* MockInputMethodManager::GetImeKeyboard() { return &keyboard_; }
188 InputMethodUtil* MockInputMethodManager::GetInputMethodUtil() {
189 return &util_;
192 ComponentExtensionIMEManager*
193 MockInputMethodManager::GetComponentExtensionIMEManager() {
194 return comp_ime_manager_.get();
197 void MockInputMethodManager::SetComponentExtensionIMEManager(
198 scoped_ptr<ComponentExtensionIMEManager> comp_ime_manager) {
199 comp_ime_manager_ = comp_ime_manager.Pass();
202 void MockInputMethodManager::set_application_locale(const std::string& value) {
203 delegate_.set_active_locale(value);
206 bool MockInputMethodManager::IsLoginKeyboard(
207 const std::string& layout) const {
208 return true;
211 bool MockInputMethodManager::MigrateInputMethods(
212 std::vector<std::string>* input_method_ids) {
213 return false;
215 scoped_refptr<InputMethodManager::State> MockInputMethodManager::CreateNewState(
216 Profile* profile) {
217 NOTIMPLEMENTED();
218 return state_;
221 scoped_refptr<InputMethodManager::State>
222 MockInputMethodManager::GetActiveIMEState() {
223 return scoped_refptr<InputMethodManager::State>(state_.get());
226 scoped_refptr<InputMethodManager::State> MockInputMethodManager::State::Clone()
227 const {
228 NOTIMPLEMENTED();
229 return manager_->GetActiveIMEState();
232 void MockInputMethodManager::SetState(
233 scoped_refptr<InputMethodManager::State> state) {
234 state_ = scoped_refptr<MockInputMethodManager::State>(
235 static_cast<MockInputMethodManager::State*>(state.get()));
238 void MockInputMethodManager::SetCurrentInputMethodId(
239 const std::string& input_method_id) {
240 state_->current_input_method_id = input_method_id;
243 } // namespace input_method
244 } // namespace chromeos