Chromium Code Reviews| Index: chrome/browser/chromeos/input_method/input_method_util.cc |
| diff --git a/chrome/browser/chromeos/input_method/input_method_util.cc b/chrome/browser/chromeos/input_method/input_method_util.cc |
| index e11dd25e34e545c664398cb4c900c5e7b21f1c90..800d0beb0bda8bc3ca476c1231a769a2e77738a5 100644 |
| --- a/chrome/browser/chromeos/input_method/input_method_util.cc |
| +++ b/chrome/browser/chromeos/input_method/input_method_util.cc |
| @@ -611,11 +611,45 @@ std::string InputMethodUtil::GetLanguageDefaultInputMethodId( |
| return std::string(); |
| } |
| +bool InputMethodUtil::MigrateXkbInputMethods( |
| + std::vector<std::string>* input_method_ids) { |
| + bool rewritten = false; |
| + std::vector<std::string>& ids = *input_method_ids; |
| + for (size_t i = 0; i < ids.size(); ++i) { |
| + std::string id = |
| + extension_ime_util::GetInputMethodIDByKeyboardLayout(ids[i]); |
| + if (id != ids[i]) { |
| + ids[i] = id; |
| + rewritten = true; |
| + } |
| + } |
| + if (rewritten) { |
| + // Removes the duplicates. |
| + size_t t = 0; |
| + for (size_t i = 0; i < ids.size(); ++i) { |
| + bool dup = false; |
| + for (size_t j = 0; j < i; ++j) { |
| + if (ids[i] == ids[j]) { |
| + dup = true; |
| + break; |
| + } |
| + } |
| + if (t != i) |
| + ids[t] = ids[i]; |
| + if (!dup) |
| + t++; |
| + } |
|
Seigo Nonaka
2014/02/28 06:14:07
How about simply
size_t t = 0;
for (size_t i = 0;
Shu Chen
2014/02/28 07:32:50
Done.
|
| + ids.resize(t); |
| + } |
| + return rewritten; |
| +} |
| + |
| void InputMethodUtil::UpdateHardwareLayoutCache() { |
| DCHECK(thread_checker_.CalledOnValidThread()); |
| hardware_layouts_.clear(); |
| hardware_login_layouts_.clear(); |
| Tokenize(delegate_->GetHardwareKeyboardLayouts(), ",", &hardware_layouts_); |
| + MigrateXkbInputMethods(&hardware_layouts_); |
| for (size_t i = 0; i < hardware_layouts_.size(); ++i) { |
| if (IsLoginKeyboard(hardware_layouts_[i])) |
| @@ -682,14 +716,15 @@ InputMethodDescriptor InputMethodUtil::GetFallbackInputMethodDescriptor() { |
| layouts.push_back("us"); |
| std::vector<std::string> languages; |
| languages.push_back("en-US"); |
| - return InputMethodDescriptor("xkb:us::eng", |
| - "", |
| - "US", |
| - layouts, |
| - languages, |
| - true, // login keyboard. |
| - GURL(), // options page, not available. |
| - GURL()); // input view page, not available. |
| + return InputMethodDescriptor( |
| + extension_ime_util::GetInputMethodIDByKeyboardLayout("xkb:us::eng"), |
| + "", |
| + "US", |
| + layouts, |
| + languages, |
| + true, // login keyboard. |
| + GURL(), // options page, not available. |
| + GURL()); // input view page, not available. |
| } |
| void InputMethodUtil::ReloadInternalMaps() { |