diff options
author | nona@chromium.org <nona@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-22 22:24:40 +0000 |
---|---|---|
committer | nona@chromium.org <nona@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-22 22:24:40 +0000 |
commit | 8a4677ed7ace8b86c3b09eae39375210c255c3e6 (patch) | |
tree | 6cc8cbaee5db8bdcbace267ea22696a39d2d1f73 | |
parent | 70d9195e96ca9e684f913653c18c1971b28050a8 (diff) | |
download | chromium_src-8a4677ed7ace8b86c3b09eae39375210c255c3e6.zip chromium_src-8a4677ed7ace8b86c3b09eae39375210c255c3e6.tar.gz chromium_src-8a4677ed7ace8b86c3b09eae39375210c255c3e6.tar.bz2 |
Remove ExtraLanguage entries from InputMethodUtil.
Now InputMethod can be associated with multiple languages, so ExtraLanguage
struct in InputMethodUtil is no longer necessary and update input_methods.txt to
be able to specify multiple languages.
BUG=None
TEST=US-international keyboard layout is still available on Portuguese entry.
Review URL: https://chromiumcodereview.appspot.com/23297004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@219131 0039d316-1c4b-4281-b951-d872f2087c98
6 files changed, 12 insertions, 122 deletions
diff --git a/chrome/browser/chromeos/input_method/input_method_util.cc b/chrome/browser/chromeos/input_method/input_method_util.cc index fc91b63..e8ed45b 100644 --- a/chrome/browser/chromeos/input_method/input_method_util.cc +++ b/chrome/browser/chromeos/input_method/input_method_util.cc @@ -293,32 +293,6 @@ const struct EnglishToResouceId { const size_t kEnglishToResourceIdArraySize = arraysize(kEnglishToResourceIdArray); -// The list of language that do not have associated input methods in IBus. -// For these languages, we associate input methods here. -const struct ExtraLanguage { - const char* language_code; - const char* input_method_id; -} kExtraLanguages[] = { - // Language Code Input Method ID - { "en-AU", "xkb:us::eng" }, // For Austrailia, use US keyboard layout. - { "id", "xkb:us::eng" }, // For Indonesian, use US keyboard layout. - // The code "fil" comes from l10_util.cc. - { "fil", "xkb:us::eng" }, // For Filipino, use US keyboard layout. - // For Netherlands, use US international keyboard layout. - { "nl", "xkb:us:intl:eng" }, - // The code "es-419" comes from l10_util.cc. - // For Spanish in Latin America, use Latin American keyboard layout. - { "es-419", "xkb:latam::spa" }, - // For Malay, use US keyboard layout. crosbug.com/p/8288 - { "ms", "xkb:us::eng" }, - // For Brazil, it is common to use US-international keyboard layout. - { "pt-BR", "xkb:us:intl:eng" }, - - // TODO(yusukes): Add {"sw", "xkb:us::eng"} once Swahili is removed from the - // blacklist in src/ui/base/l10n/l10n_util_posix.cc. -}; -const size_t kExtraLanguagesLength = arraysize(kExtraLanguages); - } // namespace InputMethodUtil::InputMethodUtil( @@ -509,23 +483,6 @@ const InputMethodDescriptor* InputMethodUtil::GetInputMethodDescriptorFromId( return (iter == id_to_descriptor_.end()) ? NULL : &(iter->second); } -std::vector<std::string> InputMethodUtil::GetExtraLanguageCodesFromId( - const std::string& input_method_id) const { - std::vector<std::string> result; - for (size_t i = 0; i < kExtraLanguagesLength; ++i) { - if (input_method_id == kExtraLanguages[i].input_method_id) - result.push_back(kExtraLanguages[i].language_code); - } - return result; -} - -std::vector<std::string> InputMethodUtil::GetExtraLanguageCodeList() const { - std::vector<std::string> result; - for (size_t i = 0; i < kExtraLanguagesLength; ++i) - result.push_back(kExtraLanguages[i].language_code); - return result; -} - bool InputMethodUtil::GetInputMethodIdsFromLanguageCode( const std::string& normalized_language_code, InputMethodType type, @@ -715,21 +672,6 @@ void InputMethodUtil::ReloadInternalMaps() { input_method)); } } - - // Go through the languages listed in kExtraLanguages. - for (size_t i = 0; i < kExtraLanguagesLength; ++i) { - const char* language_code = kExtraLanguages[i].language_code; - const char* input_method_id = kExtraLanguages[i].input_method_id; - InputMethodIdToDescriptorMap::const_iterator iter = - id_to_descriptor_.find(input_method_id); - // If the associated input method descriptor is found, add the language - // code and the input method. - if (iter != id_to_descriptor_.end()) { - const InputMethodDescriptor& input_method = iter->second; - language_code_to_ids_.insert( - std::make_pair(language_code, input_method.id())); - } - } } } // namespace input_method diff --git a/chrome/browser/chromeos/input_method/input_method_util.h b/chrome/browser/chromeos/input_method/input_method_util.h index ac1fdf7..6f70fea 100644 --- a/chrome/browser/chromeos/input_method/input_method_util.h +++ b/chrome/browser/chromeos/input_method/input_method_util.h @@ -103,14 +103,6 @@ class InputMethodUtil { // Returns true if the given input method id is for a keyboard layout. static bool IsKeyboardLayout(const std::string& input_method_id); - // Returns extra language code list associated with |input_method_id|. If - // there is no associated langauge code, this function returns empty list. - std::vector<std::string> GetExtraLanguageCodesFromId( - const std::string& input_method_id) const; - - // Returns all extra language code list. - std::vector<std::string> GetExtraLanguageCodeList() const; - // Sets the list of component extension IMEs. void SetComponentExtensions(const InputMethodDescriptors& imes); diff --git a/chrome/browser/ui/webui/options/chromeos/cros_language_options_handler.cc b/chrome/browser/ui/webui/options/chromeos/cros_language_options_handler.cc index 25fecc1..e04df15 100644 --- a/chrome/browser/ui/webui/options/chromeos/cros_language_options_handler.cc +++ b/chrome/browser/ui/webui/options/chromeos/cros_language_options_handler.cc @@ -165,13 +165,6 @@ ListValue* CrosLanguageOptionsHandler::GetInputMethodList( for (size_t i = 0; i < descriptor.language_codes().size(); ++i) { languages->SetBoolean(descriptor.language_codes().at(i), true); } - // Check extra languages to see if there are languages associated with - // this input method. If these are present, add these. - const std::vector<std::string> extra_language_codes = - manager->GetInputMethodUtil()->GetExtraLanguageCodesFromId( - descriptor.id()); - for (size_t j = 0; j < extra_language_codes.size(); ++j) - languages->SetBoolean(extra_language_codes[j], true); dictionary->Set("languageCodeSet", languages); input_method_list->Append(dictionary); @@ -195,12 +188,6 @@ ListValue* CrosLanguageOptionsHandler::GetLanguageListInternal( for (size_t i = 0; i < languages.size(); ++i) language_codes.insert(languages[i]); } - // Collect the language codes from extra languages. - const std::vector<std::string> extra_language_codes = - input_method::InputMethodManager::Get()->GetInputMethodUtil() - ->GetExtraLanguageCodeList(); - for (size_t i = 0; i < extra_language_codes.size(); ++i) - language_codes.insert(extra_language_codes[i]); // Map of display name -> {language code, native_display_name}. // In theory, we should be able to create a map that is sorted by diff --git a/chrome/browser/ui/webui/options/chromeos/cros_language_options_handler_unittest.cc b/chrome/browser/ui/webui/options/chromeos/cros_language_options_handler_unittest.cc index b51e0f0..7ba873e 100644 --- a/chrome/browser/ui/webui/options/chromeos/cros_language_options_handler_unittest.cc +++ b/chrome/browser/ui/webui/options/chromeos/cros_language_options_handler_unittest.cc @@ -35,7 +35,6 @@ class CrosLanguageOptionsHandlerTest : public testing::Test { descriptors.push_back(GetDesc("xkb:fr::fra", "fr", "fr")); descriptors.push_back(GetDesc("xkb:be::fra", "be", "fr")); descriptors.push_back(GetDesc("xkb:is::ice", "is", "is")); - descriptors.push_back(GetDesc("mozc", "us", "ja")); return descriptors; } @@ -62,7 +61,7 @@ TEST_F(CrosLanguageOptionsHandlerTest, GetInputMethodList) { scoped_ptr<ListValue> list( chromeos::options::CrosLanguageOptionsHandler::GetInputMethodList( descriptors)); - ASSERT_EQ(5U, list->GetSize()); + ASSERT_EQ(4U, list->GetSize()); DictionaryValue* entry = NULL; DictionaryValue *language_code_set = NULL; @@ -81,8 +80,6 @@ TEST_F(CrosLanguageOptionsHandlerTest, GetInputMethodList) { // (i.e. makes the test fragile). // EXPECT_EQ("English (USA) keyboard layout", display_name); ASSERT_TRUE(language_code_set->HasKey("en-US")); - ASSERT_TRUE(language_code_set->HasKey("id")); // From kExtraLanguages. - ASSERT_TRUE(language_code_set->HasKey("fil")); // From kExtraLanguages. ASSERT_TRUE(list->GetDictionary(1, &entry)); ASSERT_TRUE(entry->GetString("id", &input_method_id)); @@ -110,15 +107,6 @@ TEST_F(CrosLanguageOptionsHandlerTest, GetInputMethodList) { // Commented out. See above. // EXPECT_EQ("Japanese input method (for US keyboard)", display_name); ASSERT_TRUE(language_code_set->HasKey("is")); - - ASSERT_TRUE(list->GetDictionary(4, &entry)); - ASSERT_TRUE(entry->GetString("id", &input_method_id)); - ASSERT_TRUE(entry->GetString("displayName", &display_name)); - ASSERT_TRUE(entry->GetDictionary("languageCodeSet", &language_code_set)); - EXPECT_EQ("mozc", input_method_id); - // Commented out. See above. - // EXPECT_EQ("Japanese input method (for US keyboard)", display_name); - ASSERT_TRUE(language_code_set->HasKey("ja")); } TEST_F(CrosLanguageOptionsHandlerTest, GetUILanguageList) { diff --git a/chromeos/ime/input_method_whitelist.cc b/chromeos/ime/input_method_whitelist.cc index cea052c..d798e09 100644 --- a/chromeos/ime/input_method_whitelist.cc +++ b/chromeos/ime/input_method_whitelist.cc @@ -6,12 +6,15 @@ #include <vector> +#include "base/strings/string_util.h" #include "chromeos/ime/input_method_descriptor.h" #include "chromeos/ime/input_methods.h" namespace chromeos { namespace input_method { +const char kLanguageDelimiter[] = ","; + InputMethodWhitelist::InputMethodWhitelist() { for (size_t i = 0; i < arraysize(kInputMethods); ++i) { supported_input_methods_.insert(kInputMethods[i].input_method_id); @@ -35,7 +38,8 @@ InputMethodWhitelist::GetSupportedInputMethods() const { layouts.push_back(kInputMethods[i].xkb_layout_id); std::vector<std::string> languages; - languages.push_back(kInputMethods[i].language_code); + Tokenize(kInputMethods[i].language_code, kLanguageDelimiter, &languages); + DCHECK(!languages.empty()); input_methods->push_back(InputMethodDescriptor( kInputMethods[i].input_method_id, diff --git a/chromeos/ime/input_methods.txt b/chromeos/ime/input_methods.txt index 2b4bc91..d1e33cf 100644 --- a/chromeos/ime/input_methods.txt +++ b/chromeos/ime/input_methods.txt @@ -1,27 +1,5 @@ -# The list of input methods that we support. The input methods metadata is -# also defined here. We use this data for the following purposes. -# -# 1. Exclude unnecessary input methods. For example, we don't need -# "ja:anthy", and "zh:pinyin" engines in ibus-m17n since we have better -# alternatives outside of ibus-m17n. Excluding these input methods from -# the IBus engine XML files, such as /usr/share/ibus/component/m17n.xml, -# makes the startup time of the IBus daemon faster. This filtering is -# done using a python script at build time of ibus-m17n. -# See crosbug.com/4161 for details. -# -# 2. Provide the input methods metadata to Chrome at build time. Chrome -# needs to know about the supported input methods for the input method -# features, such as the input method switching and the options page, -# to work. Note that we can retrieve the same metadata from the IBus -# daemon, but Chrome needs be able to get the metadata without talking -# to the IBus daemon. This requirement comes from the fact that the -# IBus daemon should not run if the user is just using keyboard layouts -# such as US keyboard. The metadata generation is done using a python -# script at build time of Chrome. See crosbug.com/16961 for details. -# -# The order of the list is important. In Chrome's "Languages and input" options -# page, we list input methods in this order, when more than one input methods -# are available for a language (ex. French). +# The list of keyboard layouts that we support. The keyboard layout metadata is +# also defined here. # # Each non-comment line contains the following tab-separated columns. # @@ -37,8 +15,7 @@ # three-letter ones (ISO 639-2/T and 639-2/B) here. For "en", "pt", and "zh", # two-letter upper-case country code should be added (ex. "en-US", "zh-TW"). # See http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes for details. -# 4) [optional] The #if condition for the input method. -# (ex. "defined(A)", "!defined(A)||defined(B)") +# We can specify multiple language code with comma separator. # # Notes: # When adding a line to this list, please also add a mapping from the input @@ -67,8 +44,8 @@ # that information in kHasLatinKeyboardLanguageList[] is still correct. # U.S. English -xkb:us::eng us en-US -xkb:us:intl:eng us(intl) en-US +xkb:us::eng us en-US,en-AU,id,fil,ms +xkb:us:intl:eng us(intl) en-US,nl,pt-BR xkb:us:altgr-intl:eng us(altgr-intl) en-US xkb:us:dvorak:eng us(dvorak) en-US xkb:us:colemak:eng us(colemak) en-US @@ -114,7 +91,7 @@ xkb:es:cat:cat es(cat) ca xkb:dk::dan dk da xkb:gr::gre gr el xkb:il::heb il he -xkb:latam::spa latam es +xkb:latam::spa latam es,es-419 xkb:lt::lit lt lt xkb:lv:apostrophe:lav lv(apostrophe) lv xkb:hr::scr hr hr |