diff options
Diffstat (limited to 'chrome/browser')
4 files changed, 2 insertions, 98 deletions
diff --git a/chrome/browser/chromeos/input_method/input_method_util.cc b/chrome/browser/chromeos/input_method/input_method_util.cc index b044bd9..e424338 100644 --- a/chrome/browser/chromeos/input_method/input_method_util.cc +++ b/chrome/browser/chromeos/input_method/input_method_util.cc @@ -234,20 +234,6 @@ const char* kIso639VariantMapping[][2] = { {"slo", "slk"}, }; -// The list defines pairs of language code and the default input method -// id. The list is used for reordering input method ids. -// -// TODO(satorux): We may need to handle secondary, and ternary input -// methods, rather than handling the default input method only. -const struct LanguageDefaultInputMethodId { - const char* language_code; - const char* input_method_id; -} kLanguageDefaultInputMethodIds[] = { - { "en-US", "xkb:us::eng", }, // US - English - { "fr", "xkb:fr::fra", }, // France - French - { "de", "xkb:de::ger", }, // Germany - German -}; - // The comparator is used for sorting language codes by their // corresponding language names, using the ICU collator. struct CompareLanguageCodesByLanguageName @@ -267,6 +253,7 @@ struct CompareLanguageCodesByLanguageName return l10n_util::StringComparator<std::wstring>(collator_)(key1, key2); } + private: icu::Collator* collator_; }; @@ -296,6 +283,7 @@ struct CompareInputMethodIdsByLanguageName return comparator_(language_code_1, language_code_2); } + private: const CompareLanguageCodesByLanguageName comparator_; const std::map<std::string, std::string>& id_to_language_code_map_; }; @@ -546,24 +534,6 @@ void SortInputMethodIdsByNamesInternal( collator.get(), id_to_language_code_map)); } -void ReorderInputMethodIdsForLanguageCode( - const std::string& language_code, - std::vector<std::string>* input_method_ids) { - for (size_t i = 0; i < arraysize(kLanguageDefaultInputMethodIds); ++i) { - if (language_code == kLanguageDefaultInputMethodIds[i].language_code) { - std::vector<std::string>::iterator iter = - std::find(input_method_ids->begin(), input_method_ids->end(), - kLanguageDefaultInputMethodIds[i].input_method_id); - // If it's not on the top of |input_method_id|, swap it with the top one. - if (iter != input_method_ids->end() && - iter != input_method_ids->begin()) { - std::swap(*input_method_ids->begin(), *iter); - } - break; // Don't have to check other language codes. - } - } -} - bool GetInputMethodIdsFromLanguageCode( const std::string& normalized_language_code, InputMethodType type, diff --git a/chrome/browser/chromeos/input_method/input_method_util.h b/chrome/browser/chromeos/input_method/input_method_util.h index 79a1b1a..22327967 100644 --- a/chrome/browser/chromeos/input_method/input_method_util.h +++ b/chrome/browser/chromeos/input_method/input_method_util.h @@ -115,15 +115,6 @@ void SortLanguageCodesByNames(std::vector<std::string>* language_codes); // using the unicode string comparator. Uses stable sorting. void SortInputMethodIdsByNames(std::vector<std::string>* input_method_ids); -// Reorders the given input method ids for the language code. For -// example, if |language_codes| is "fr" and |input_method_ids| contains -// ["xkb:be::fra", and "xkb:fr::fra"], the list is reordered to -// ["xkb:fr::fra", and "xkb:be::fra"], so that French keyboard layout -// comes before Belgian keyboard layout. -void ReorderInputMethodIdsForLanguageCode( - const std::string& language_code, - std::vector<std::string>* input_method_ids); - enum InputMethodType { kKeyboardLayoutsOnly, kAllInputMethods, diff --git a/chrome/browser/chromeos/input_method/input_method_util_unittest.cc b/chrome/browser/chromeos/input_method/input_method_util_unittest.cc index f177417..c0b021a 100644 --- a/chrome/browser/chromeos/input_method/input_method_util_unittest.cc +++ b/chrome/browser/chromeos/input_method/input_method_util_unittest.cc @@ -224,59 +224,6 @@ TEST(LanguageConfigModelTest, SortInputMethodIdsByNamesInternal) { ASSERT_EQ("m17n:latn-pre", input_method_ids[4]); // Others } -TEST(InputMethodUtilTest, ReorderInputMethodIdsForLanguageCode_DE) { - std::vector<std::string> input_method_ids; - input_method_ids.push_back("xkb:ch::ger"); // Switzerland - German - input_method_ids.push_back("xkb:de::ger"); // Germany - German - ReorderInputMethodIdsForLanguageCode("de", &input_method_ids); - // The list should be reordered. - ASSERT_EQ(2U, input_method_ids.size()); - EXPECT_EQ("xkb:de::ger", input_method_ids[0]); - EXPECT_EQ("xkb:ch::ger", input_method_ids[1]); -} - -TEST(InputMethodUtilTest, ReorderInputMethodIdsForLanguageCode_FR) { - std::vector<std::string> input_method_ids; - input_method_ids.push_back("xkb:be::fra"); // Belgium - French - input_method_ids.push_back("xkb:fr::fra"); // France - French - ReorderInputMethodIdsForLanguageCode("fr", &input_method_ids); - // The list should be reordered. - ASSERT_EQ(2U, input_method_ids.size()); - EXPECT_EQ("xkb:fr::fra", input_method_ids[0]); - EXPECT_EQ("xkb:be::fra", input_method_ids[1]); -} - -TEST(InputMethodUtilTest, ReorderInputMethodIdsForLanguageCode_EN_US) { - std::vector<std::string> input_method_ids; - input_method_ids.push_back("xkb:us:dvorak:eng"); // US - Dvorak - English - input_method_ids.push_back("xkb:us::eng"); // US - English - ReorderInputMethodIdsForLanguageCode("en-US", &input_method_ids); - // The list should be reordered. - ASSERT_EQ(2U, input_method_ids.size()); - EXPECT_EQ("xkb:us::eng", input_method_ids[0]); - EXPECT_EQ("xkb:us:dvorak:eng", input_method_ids[1]); -} - -TEST(InputMethodUtilTest, ReorderInputMethodIdsForLanguageCode_FI) { - std::vector<std::string> input_method_ids; - input_method_ids.push_back("xkb:fi::fin"); // Finland - Finnish - ReorderInputMethodIdsForLanguageCode("fi", &input_method_ids); - // There is no rule for reordering for Finnish. - ASSERT_EQ(1U, input_method_ids.size()); - EXPECT_EQ("xkb:fi::fin", input_method_ids[0]); -} - -TEST(InputMethodUtilTest, ReorderInputMethodIdsForLanguageCode_Noop) { - std::vector<std::string> input_method_ids; - input_method_ids.push_back("xkb:fr::fra"); // France - French - input_method_ids.push_back("xkb:be::fra"); // Belgium - French - // If the list is already sorted, nothing should happen. - ReorderInputMethodIdsForLanguageCode("fr", &input_method_ids); - ASSERT_EQ(2U, input_method_ids.size()); - EXPECT_EQ("xkb:fr::fra", input_method_ids[0]); - EXPECT_EQ("xkb:be::fra", input_method_ids[1]); -} - TEST(LanguageConfigModelTest, GetInputMethodIdsForLanguageCode) { std::multimap<std::string, std::string> language_code_to_ids_map; language_code_to_ids_map.insert(std::make_pair("ja", "mozc")); diff --git a/chrome/browser/chromeos/options/language_config_model.cc b/chrome/browser/chromeos/options/language_config_model.cc index fafa2f6..e045506 100644 --- a/chrome/browser/chromeos/options/language_config_model.cc +++ b/chrome/browser/chromeos/options/language_config_model.cc @@ -213,10 +213,6 @@ void LanguageConfigModel::GetInputMethodIdsFromLanguageCode( input_method_ids->clear(); input_method::GetInputMethodIdsFromLanguageCode( language_code, input_method::kAllInputMethods, input_method_ids); - - // Reorder the input methods. - input_method::ReorderInputMethodIdsForLanguageCode( - language_code, input_method_ids); } void LanguageConfigModel::NotifyPrefChanged() { |