Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / chromeos / input_method / mock_input_method_manager.cc
blobd1d4bfcfa8e36cff3e46adb6fd97a58d907a6f54
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::MockInputMethodManager()
11 : add_observer_count_(0),
12 remove_observer_count_(0),
13 util_(&delegate_, whitelist_.GetSupportedInputMethods()) {
14 active_input_method_ids_.push_back("xkb:us::eng");
17 MockInputMethodManager::~MockInputMethodManager() {
20 void MockInputMethodManager::AddObserver(
21 InputMethodManager::Observer* observer) {
22 ++add_observer_count_;
25 void MockInputMethodManager::AddCandidateWindowObserver(
26 InputMethodManager::CandidateWindowObserver* observer) {
29 void MockInputMethodManager::RemoveObserver(
30 InputMethodManager::Observer* observer) {
31 ++remove_observer_count_;
34 void MockInputMethodManager::RemoveCandidateWindowObserver(
35 InputMethodManager::CandidateWindowObserver* observer) {
38 scoped_ptr<InputMethodDescriptors>
39 MockInputMethodManager::GetSupportedInputMethods() const {
40 scoped_ptr<InputMethodDescriptors> result(new InputMethodDescriptors);
41 result->push_back(
42 InputMethodUtil::GetFallbackInputMethodDescriptor());
43 return result.Pass();
46 scoped_ptr<InputMethodDescriptors>
47 MockInputMethodManager::GetActiveInputMethods() const {
48 scoped_ptr<InputMethodDescriptors> result(new InputMethodDescriptors);
49 result->push_back(
50 InputMethodUtil::GetFallbackInputMethodDescriptor());
51 return result.Pass();
54 const std::vector<std::string>&
55 MockInputMethodManager::GetActiveInputMethodIds() const {
56 return active_input_method_ids_;
59 size_t MockInputMethodManager::GetNumActiveInputMethods() const {
60 return 1;
63 const InputMethodDescriptor* MockInputMethodManager::GetInputMethodFromId(
64 const std::string& input_method_id) const {
65 static const InputMethodDescriptor defaultInputMethod =
66 InputMethodUtil::GetFallbackInputMethodDescriptor();
67 for (size_t i = 0; i < active_input_method_ids_.size(); i++) {
68 if (input_method_id == active_input_method_ids_[i]) {
69 return &defaultInputMethod;
72 return NULL;
75 void MockInputMethodManager::EnableLayouts(const std::string& language_code,
76 const std::string& initial_layout) {
79 bool MockInputMethodManager::EnableInputMethods(
80 const std::vector<std::string>& new_active_input_method_ids) {
81 return true;
84 bool MockInputMethodManager::EnableInputMethod(
85 const std::string& new_active_input_method_id) {
86 return true;
89 void MockInputMethodManager::ChangeInputMethod(
90 const std::string& input_method_id) {
93 void MockInputMethodManager::ActivateInputMethodProperty(
94 const std::string& key) {
97 void MockInputMethodManager::AddInputMethodExtension(
98 const std::string& id,
99 InputMethodEngineInterface* instance) {
102 void MockInputMethodManager::RemoveInputMethodExtension(const std::string& id) {
105 void MockInputMethodManager::GetInputMethodExtensions(
106 InputMethodDescriptors* result) {
109 void MockInputMethodManager::SetEnabledExtensionImes(
110 std::vector<std::string>* ids) {
113 void MockInputMethodManager::SetInputMethodDefault() {
116 bool MockInputMethodManager::SwitchToNextInputMethod() {
117 return true;
120 bool MockInputMethodManager::SwitchToPreviousInputMethod(
121 const ui::Accelerator& accelerator) {
122 return true;
125 bool MockInputMethodManager::SwitchInputMethod(
126 const ui::Accelerator& accelerator) {
127 return true;
130 InputMethodDescriptor MockInputMethodManager::GetCurrentInputMethod() const {
131 InputMethodDescriptor descriptor =
132 InputMethodUtil::GetFallbackInputMethodDescriptor();
133 if (!current_input_method_id_.empty()) {
134 return InputMethodDescriptor(current_input_method_id_,
135 descriptor.name(),
136 descriptor.keyboard_layouts(),
137 descriptor.language_codes(),
138 true,
139 GURL(), // options page url.
140 GURL()); // input view page url.
142 return descriptor;
145 InputMethodPropertyList
146 MockInputMethodManager::GetCurrentInputMethodProperties() const {
147 return InputMethodPropertyList();
150 void MockInputMethodManager::SetCurrentInputMethodProperties(
151 const InputMethodPropertyList& property_list) {
154 XKeyboard* MockInputMethodManager::GetXKeyboard() {
155 return &xkeyboard_;
158 InputMethodUtil* MockInputMethodManager::GetInputMethodUtil() {
159 return &util_;
162 ComponentExtensionIMEManager*
163 MockInputMethodManager::GetComponentExtensionIMEManager() {
164 return NULL;
167 void MockInputMethodManager::set_application_locale(const std::string& value) {
168 delegate_.set_active_locale(value);
171 void MockInputMethodManager::set_hardware_keyboard_layout(
172 const std::string& value) {
173 delegate_.set_hardware_keyboard_layout(value);
176 bool MockInputMethodManager::IsLoginKeyboard(
177 const std::string& layout) const {
178 return true;
180 } // namespace input_method
181 } // namespace chromeos