| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/input_method/input_method_whitelist.h" | 5 #include "chrome/browser/chromeos/input_method/input_method_whitelist.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "chrome/browser/chromeos/input_method/ibus_input_methods.h" | |
| 10 #include "chrome/browser/chromeos/input_method/input_method_descriptor.h" | 9 #include "chrome/browser/chromeos/input_method/input_method_descriptor.h" |
| 10 #include "chrome/browser/chromeos/input_method/input_methods.h" |
| 11 | 11 |
| 12 namespace chromeos { | 12 namespace chromeos { |
| 13 namespace input_method { | 13 namespace input_method { |
| 14 | 14 |
| 15 InputMethodWhitelist::InputMethodWhitelist() { | 15 InputMethodWhitelist::InputMethodWhitelist() { |
| 16 for (size_t i = 0; i < arraysize(kIBusEngines); ++i) { | 16 for (size_t i = 0; i < arraysize(kInputMethods); ++i) { |
| 17 supported_input_methods_.insert(kIBusEngines[i].input_method_id); | 17 supported_input_methods_.insert(kInputMethods[i].input_method_id); |
| 18 } | 18 } |
| 19 for (size_t i = 0; i < arraysize(kIBusEngines); ++i) { | 19 for (size_t i = 0; i < arraysize(kInputMethods); ++i) { |
| 20 supported_layouts_.insert(kIBusEngines[i].xkb_layout_id); | 20 supported_layouts_.insert(kInputMethods[i].xkb_layout_id); |
| 21 } | 21 } |
| 22 } | 22 } |
| 23 | 23 |
| 24 InputMethodWhitelist::~InputMethodWhitelist() { | 24 InputMethodWhitelist::~InputMethodWhitelist() { |
| 25 } | 25 } |
| 26 | 26 |
| 27 bool InputMethodWhitelist::InputMethodIdIsWhitelisted( | 27 bool InputMethodWhitelist::InputMethodIdIsWhitelisted( |
| 28 const std::string& input_method_id) const { | 28 const std::string& input_method_id) const { |
| 29 return supported_input_methods_.count(input_method_id) > 0; | 29 return supported_input_methods_.count(input_method_id) > 0; |
| 30 } | 30 } |
| 31 | 31 |
| 32 bool InputMethodWhitelist::XkbLayoutIsSupported( | 32 bool InputMethodWhitelist::XkbLayoutIsSupported( |
| 33 const std::string& xkb_layout) const { | 33 const std::string& xkb_layout) const { |
| 34 return supported_layouts_.count(xkb_layout) > 0; | 34 return supported_layouts_.count(xkb_layout) > 0; |
| 35 } | 35 } |
| 36 | 36 |
| 37 InputMethodDescriptors* InputMethodWhitelist::GetSupportedInputMethods() const { | 37 InputMethodDescriptors* InputMethodWhitelist::GetSupportedInputMethods() const { |
| 38 InputMethodDescriptors* input_methods = new InputMethodDescriptors; | 38 InputMethodDescriptors* input_methods = new InputMethodDescriptors; |
| 39 input_methods->reserve(arraysize(kIBusEngines)); | 39 input_methods->reserve(arraysize(kInputMethods)); |
| 40 for (size_t i = 0; i < arraysize(kIBusEngines); ++i) { | 40 for (size_t i = 0; i < arraysize(kInputMethods); ++i) { |
| 41 input_methods->push_back(InputMethodDescriptor( | 41 input_methods->push_back(InputMethodDescriptor( |
| 42 *this, | 42 *this, |
| 43 kIBusEngines[i].input_method_id, | 43 kInputMethods[i].input_method_id, |
| 44 "", | 44 "", |
| 45 kIBusEngines[i].xkb_layout_id, | 45 kInputMethods[i].xkb_layout_id, |
| 46 kIBusEngines[i].language_code)); | 46 kInputMethods[i].language_code)); |
| 47 } | 47 } |
| 48 return input_methods; | 48 return input_methods; |
| 49 } | 49 } |
| 50 | 50 |
| 51 } // namespace input_method | 51 } // namespace input_method |
| 52 } // namespace chromeos | 52 } // namespace chromeos |
| OLD | NEW |