Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 5 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <functional> | 10 #include <functional> |
| (...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 683 std::vector<std::string>& ids = *input_method_ids; | 683 std::vector<std::string>& ids = *input_method_ids; |
| 684 for (size_t i = 0; i < ids.size(); ++i) { | 684 for (size_t i = 0; i < ids.size(); ++i) { |
| 685 std::string id = MigrateInputMethod(ids[i]); | 685 std::string id = MigrateInputMethod(ids[i]); |
| 686 if (id != ids[i]) { | 686 if (id != ids[i]) { |
| 687 ids[i] = id; | 687 ids[i] = id; |
| 688 rewritten = true; | 688 rewritten = true; |
| 689 } | 689 } |
| 690 } | 690 } |
| 691 if (rewritten) { | 691 if (rewritten) { |
| 692 // Removes the duplicates. | 692 // Removes the duplicates. |
| 693 std::vector<std::string> new_ids; | 693 std::sort(ids.begin(), ids.end()); |
|
Shu Chen
2016/03/24 13:05:31
The sort() here is risky since the order of the in
chakshu
2016/04/04 05:28:32
Okay, I was not aware that the order of input meth
Shu Chen
2016/04/04 12:48:15
I'm not sure whether std::unique can do the thing.
chakshu
2016/04/11 06:54:37
Done !
Also if you want it to be done in-place wit
| |
| 694 for (size_t i = 0; i < ids.size(); ++i) { | 694 ids.erase(std::unique(ids.begin(), ids.end()), ids.end()); |
| 695 if (std::find(new_ids.begin(), new_ids.end(), ids[i]) == new_ids.end()) | |
| 696 new_ids.push_back(ids[i]); | |
| 697 } | |
| 698 ids.swap(new_ids); | |
| 699 } | 695 } |
| 700 return rewritten; | 696 return rewritten; |
| 701 } | 697 } |
| 702 | 698 |
| 703 void InputMethodUtil::UpdateHardwareLayoutCache() { | 699 void InputMethodUtil::UpdateHardwareLayoutCache() { |
| 704 DCHECK(thread_checker_.CalledOnValidThread()); | 700 DCHECK(thread_checker_.CalledOnValidThread()); |
| 705 hardware_layouts_.clear(); | 701 hardware_layouts_.clear(); |
| 706 hardware_login_layouts_.clear(); | 702 hardware_login_layouts_.clear(); |
| 707 if (cached_hardware_layouts_.empty()) { | 703 if (cached_hardware_layouts_.empty()) { |
| 708 cached_hardware_layouts_ = | 704 cached_hardware_layouts_ = |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 826 "US", | 822 "US", |
| 827 layouts, | 823 layouts, |
| 828 languages, | 824 languages, |
| 829 true, // login keyboard. | 825 true, // login keyboard. |
| 830 GURL(), // options page, not available. | 826 GURL(), // options page, not available. |
| 831 GURL()); // input view page, not available. | 827 GURL()); // input view page, not available. |
| 832 } | 828 } |
| 833 | 829 |
| 834 } // namespace input_method | 830 } // namespace input_method |
| 835 } // namespace chromeos | 831 } // namespace chromeos |
| OLD | NEW |