Upstream version 6.35.121.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     const std::string& id,
101     InputMethodEngineInterface* instance) {
102 }
103
104 void MockInputMethodManager::RemoveInputMethodExtension(const std::string& id) {
105 }
106
107 void MockInputMethodManager::GetInputMethodExtensions(
108     InputMethodDescriptors* result) {
109 }
110
111 void MockInputMethodManager::SetEnabledExtensionImes(
112     std::vector<std::string>* ids) {
113 }
114
115 void MockInputMethodManager::SetInputMethodLoginDefault() {
116 }
117
118 bool MockInputMethodManager::SwitchToNextInputMethod() {
119   return true;
120 }
121
122 bool MockInputMethodManager::SwitchToPreviousInputMethod(
123     const ui::Accelerator& accelerator) {
124   return true;
125 }
126
127 bool MockInputMethodManager::SwitchInputMethod(
128     const ui::Accelerator& accelerator) {
129   return true;
130 }
131
132 InputMethodDescriptor MockInputMethodManager::GetCurrentInputMethod() const {
133   InputMethodDescriptor descriptor =
134       InputMethodUtil::GetFallbackInputMethodDescriptor();
135   if (!current_input_method_id_.empty()) {
136     return InputMethodDescriptor(current_input_method_id_,
137                                  descriptor.name(),
138                                  descriptor.indicator(),
139                                  descriptor.keyboard_layouts(),
140                                  descriptor.language_codes(),
141                                  true,
142                                  GURL(),  // options page url.
143                                  GURL());  // input view page url.
144   }
145   return descriptor;
146 }
147
148 bool MockInputMethodManager::IsISOLevel5ShiftUsedByCurrentInputMethod() const {
149   return mod3_used_;
150 }
151
152 bool MockInputMethodManager::IsAltGrUsedByCurrentInputMethod() const {
153   return false;
154 }
155
156 XKeyboard* MockInputMethodManager::GetXKeyboard() {
157   return &xkeyboard_;
158 }
159
160 InputMethodUtil* MockInputMethodManager::GetInputMethodUtil() {
161   return &util_;
162 }
163
164 ComponentExtensionIMEManager*
165     MockInputMethodManager::GetComponentExtensionIMEManager() {
166   return NULL;
167 }
168
169 void MockInputMethodManager::set_application_locale(const std::string& value) {
170   delegate_.set_active_locale(value);
171 }
172
173 bool MockInputMethodManager::IsLoginKeyboard(
174     const std::string& layout) const {
175   return true;
176 }
177
178 bool MockInputMethodManager::MigrateXkbInputMethods(
179     std::vector<std::string>* input_method_ids) {
180   return false;
181 }
182
183 }  // namespace input_method
184 }  // namespace chromeos