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. 4 5#include "chromeos/ime/input_method_whitelist.h" 6 7#include <vector> 8 9#include "base/strings/string_util.h" 10#include "chromeos/ime/input_method_descriptor.h" 11#include "chromeos/ime/input_methods.h" 12 13namespace chromeos { 14namespace input_method { 15 16const char kLanguageDelimiter[] = ","; 17 18InputMethodWhitelist::InputMethodWhitelist() { 19 for (size_t i = 0; i < arraysize(kInputMethods); ++i) { 20 supported_input_methods_.insert(kInputMethods[i].input_method_id); 21 } 22} 23 24InputMethodWhitelist::~InputMethodWhitelist() { 25} 26 27bool InputMethodWhitelist::InputMethodIdIsWhitelisted( 28 const std::string& input_method_id) const { 29 return supported_input_methods_.count(input_method_id) > 0; 30} 31 32scoped_ptr<InputMethodDescriptors> 33InputMethodWhitelist::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); 39 40 std::vector<std::string> languages; 41 Tokenize(kInputMethods[i].language_code, kLanguageDelimiter, &languages); 42 DCHECK(!languages.empty()); 43 44 input_methods->push_back(InputMethodDescriptor( 45 kInputMethods[i].input_method_id, 46 "", 47 layouts, 48 languages, 49 kInputMethods[i].is_login_keyboard, 50 GURL(), // options page url. 51 GURL() // input view page url. 52 )); 53 } 54 return input_methods.Pass(); 55} 56 57} // namespace input_method 58} // namespace chromeos 59