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