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