| OLD | NEW |
| (Empty) | |
| 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/input_method_whitelist.h" |
| 6 |
| 7 #include <vector> |
| 8 |
| 9 #include "chrome/browser/chromeos/input_method/ibus_input_methods.h" |
| 10 #include "chrome/browser/chromeos/input_method/input_method_descriptor.h" |
| 11 |
| 12 namespace chromeos { |
| 13 namespace input_method { |
| 14 |
| 15 InputMethodWhitelist::InputMethodWhitelist() { |
| 16 for (size_t i = 0; i < arraysize(kIBusEngines); ++i) { |
| 17 supported_input_methods_.insert(kIBusEngines[i].input_method_id); |
| 18 } |
| 19 for (size_t i = 0; i < arraysize(kIBusEngines); ++i) { |
| 20 supported_layouts_.insert(kIBusEngines[i].xkb_layout_id); |
| 21 } |
| 22 } |
| 23 |
| 24 InputMethodWhitelist::~InputMethodWhitelist() { |
| 25 } |
| 26 |
| 27 bool InputMethodWhitelist::InputMethodIdIsWhitelisted( |
| 28 const std::string& input_method_id) const { |
| 29 return supported_input_methods_.count(input_method_id) > 0; |
| 30 } |
| 31 |
| 32 bool InputMethodWhitelist::XkbLayoutIsSupported( |
| 33 const std::string& xkb_layout) const { |
| 34 return supported_layouts_.count(xkb_layout) > 0; |
| 35 } |
| 36 |
| 37 InputMethodDescriptors* InputMethodWhitelist::GetSupportedInputMethods() const { |
| 38 InputMethodDescriptors* input_methods = new InputMethodDescriptors; |
| 39 input_methods->reserve(arraysize(kIBusEngines)); |
| 40 for (size_t i = 0; i < arraysize(kIBusEngines); ++i) { |
| 41 input_methods->push_back(InputMethodDescriptor( |
| 42 *this, |
| 43 kIBusEngines[i].input_method_id, |
| 44 "", |
| 45 kIBusEngines[i].xkb_layout_id, |
| 46 kIBusEngines[i].language_code)); |
| 47 } |
| 48 return input_methods; |
| 49 } |
| 50 |
| 51 } // namespace input_method |
| 52 } // namespace chromeos |
| OLD | NEW |