Upstream version 9.37.195.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / chromeos / input_method / mock_input_method_manager.cc
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.
4
5 #include "chrome/browser/chromeos/input_method/mock_input_method_manager.h"
6
7 namespace chromeos {
8 namespace input_method {
9
10 MockInputMethodManager::MockInputMethodManager()
11     : add_observer_count_(0),
12       remove_observer_count_(0),
13       util_(&delegate_, whitelist_.GetSupportedInputMethods()),
14       mod3_used_(false) {
15   active_input_method_ids_.push_back("xkb:us::eng");
16 }
17
18 MockInputMethodManager::~MockInputMethodManager() {
19 }
20
21 void MockInputMethodManager::AddObserver(
22     InputMethodManager::Observer* observer) {
23   ++add_observer_count_;
24 }
25
26 void MockInputMethodManager::AddCandidateWindowObserver(
27     InputMethodManager::CandidateWindowObserver* observer) {
28 }
29
30 void MockInputMethodManager::RemoveObserver(
31     InputMethodManager::Observer* observer) {
32   ++remove_observer_count_;
33 }
34
35 void MockInputMethodManager::RemoveCandidateWindowObserver(
36     InputMethodManager::CandidateWindowObserver* observer) {
37 }
38
39 scoped_ptr<InputMethodDescriptors>
40 MockInputMethodManager::GetSupportedInputMethods() const {
41   scoped_ptr<InputMethodDescriptors> result(new InputMethodDescriptors);
42   result->push_back(
43       InputMethodUtil::GetFallbackInputMethodDescriptor());
44   return result.Pass();
45 }
46
47 scoped_ptr<InputMethodDescriptors>
48 MockInputMethodManager::GetActiveInputMethods() const {
49   scoped_ptr<InputMethodDescriptors> result(new InputMethodDescriptors);
50   result->push_back(
51       InputMethodUtil::GetFallbackInputMethodDescriptor());
52   return result.Pass();
53 }
54
55 const std::vector<std::string>&
56 MockInputMethodManager::GetActiveInputMethodIds() const {
57   return active_input_method_ids_;
58 }
59
60 size_t MockInputMethodManager::GetNumActiveInputMethods() const {
61   return 1;
62 }
63
64 const InputMethodDescriptor* MockInputMethodManager::GetInputMethodFromId(
65     const std::string& input_method_id) const {
66   static const InputMethodDescriptor defaultInputMethod =
67       InputMethodUtil::GetFallbackInputMethodDescriptor();
68   for (size_t i = 0; i < active_input_method_ids_.size(); i++) {
69     if (input_method_id == active_input_method_ids_[i]) {
70       return &defaultInputMethod;
71     }
72   }
73   return NULL;
74 }
75
76 void MockInputMethodManager::EnableLoginLayouts(
77     const std::string& language_code,
78     const std::vector<std::string>& initial_layout) {
79 }
80
81 bool MockInputMethodManager::ReplaceEnabledInputMethods(
82     const std::vector<std::string>& new_active_input_method_ids) {
83   return true;
84 }
85
86 bool MockInputMethodManager::EnableInputMethod(
87     const std::string& new_active_input_method_id) {
88   return true;
89 }
90
91 void MockInputMethodManager::ChangeInputMethod(
92     const std::string& input_method_id) {
93 }
94
95 void MockInputMethodManager::ActivateInputMethodMenuItem(
96     const std::string& key) {
97 }
98
99 void MockInputMethodManager::AddInputMethodExtension(
100     Profile* profile,
101     const std::string& id,
102     InputMethodEngineInterface* instance) {
103 }
104
105 void MockInputMethodManager::RemoveInputMethodExtension(Profile* profile,
106                                                         const std::string& id) {
107 }
108
109 void MockInputMethodManager::GetInputMethodExtensions(
110     InputMethodDescriptors* result) {
111 }
112
113 void MockInputMethodManager::SetEnabledExtensionImes(
114     std::vector<std::string>* ids) {
115 }
116
117 void MockInputMethodManager::SetInputMethodLoginDefault() {
118 }
119
120 void MockInputMethodManager::SetInputMethodLoginDefaultFromVPD(
121     const std::string& locale, const std::string& layout) {
122 }
123
124 bool MockInputMethodManager::SwitchToNextInputMethod() {
125   return true;
126 }
127
128 bool MockInputMethodManager::SwitchToPreviousInputMethod(
129     const ui::Accelerator& accelerator) {
130   return true;
131 }
132
133 bool MockInputMethodManager::SwitchInputMethod(
134     const ui::Accelerator& accelerator) {
135   return true;
136 }
137
138 InputMethodDescriptor MockInputMethodManager::GetCurrentInputMethod() const {
139   InputMethodDescriptor descriptor =
140       InputMethodUtil::GetFallbackInputMethodDescriptor();
141   if (!current_input_method_id_.empty()) {
142     return InputMethodDescriptor(current_input_method_id_,
143                                  descriptor.name(),
144                                  descriptor.indicator(),
145                                  descriptor.keyboard_layouts(),
146                                  descriptor.language_codes(),
147                                  true,
148                                  GURL(),  // options page url.
149                                  GURL());  // input view page url.
150   }
151   return descriptor;
152 }
153
154 bool MockInputMethodManager::IsISOLevel5ShiftUsedByCurrentInputMethod() const {
155   return mod3_used_;
156 }
157
158 bool MockInputMethodManager::IsAltGrUsedByCurrentInputMethod() const {
159   return false;
160 }
161
162 ImeKeyboard* MockInputMethodManager::GetImeKeyboard() { return &keyboard_; }
163
164 InputMethodUtil* MockInputMethodManager::GetInputMethodUtil() {
165   return &util_;
166 }
167
168 ComponentExtensionIMEManager*
169     MockInputMethodManager::GetComponentExtensionIMEManager() {
170   return comp_ime_manager_.get();
171 }
172
173 void MockInputMethodManager::SetComponentExtensionIMEManager(
174     scoped_ptr<ComponentExtensionIMEManager> comp_ime_manager) {
175   comp_ime_manager_ = comp_ime_manager.Pass();
176 }
177
178 void MockInputMethodManager::set_application_locale(const std::string& value) {
179   delegate_.set_active_locale(value);
180 }
181
182 bool MockInputMethodManager::IsLoginKeyboard(
183     const std::string& layout) const {
184   return true;
185 }
186
187 bool MockInputMethodManager::MigrateInputMethods(
188     std::vector<std::string>* input_method_ids) {
189   return false;
190 }
191
192 }  // namespace input_method
193 }  // namespace chromeos