1 // Copyright 2013 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 "chromeos/ime/input_method_whitelist.h"
9 #include "base/strings/string_util.h"
10 #include "chromeos/ime/input_method_descriptor.h"
11 #include "chromeos/ime/input_methods.h"
14 namespace input_method
{
16 const char kLanguageDelimiter
[] = ",";
18 InputMethodWhitelist::InputMethodWhitelist() {
19 for (size_t i
= 0; i
< arraysize(kInputMethods
); ++i
) {
20 supported_input_methods_
.insert(kInputMethods
[i
].input_method_id
);
24 InputMethodWhitelist::~InputMethodWhitelist() {
27 bool InputMethodWhitelist::InputMethodIdIsWhitelisted(
28 const std::string
& input_method_id
) const {
29 return supported_input_methods_
.count(input_method_id
) > 0;
32 scoped_ptr
<InputMethodDescriptors
>
33 InputMethodWhitelist::GetSupportedInputMethods() const {
34 scoped_ptr
<InputMethodDescriptors
> input_methods(new InputMethodDescriptors
);
35 input_methods
->reserve(arraysize(kInputMethods
));
36 for (size_t i
= 0; i
< arraysize(kInputMethods
); ++i
) {
37 std::vector
<std::string
> layouts
;
38 layouts
.push_back(kInputMethods
[i
].xkb_layout_id
);
40 std::vector
<std::string
> languages
;
41 Tokenize(kInputMethods
[i
].language_code
, kLanguageDelimiter
, &languages
);
42 DCHECK(!languages
.empty());
44 input_methods
->push_back(InputMethodDescriptor(
45 kInputMethods
[i
].input_method_id
,
47 kInputMethods
[i
].indicator
,
50 kInputMethods
[i
].is_login_keyboard
,
51 GURL(), // options page url.
52 GURL() // input view page url.
55 return input_methods
.Pass();
58 } // namespace input_method
59 } // namespace chromeos