Chromium Code Reviews| Index: chrome/browser/ui/autofill/autofill_dialog_models.cc |
| diff --git a/chrome/browser/ui/autofill/autofill_dialog_models.cc b/chrome/browser/ui/autofill/autofill_dialog_models.cc |
| index 18b05aff3a1acb70f20e5e48c8a5d99db01127f5..8965a559262504d191daa9800d3b6e773efcd214 100644 |
| --- a/chrome/browser/ui/autofill/autofill_dialog_models.cc |
| +++ b/chrome/browser/ui/autofill/autofill_dialog_models.cc |
| @@ -76,14 +76,7 @@ std::string SuggestionsMenuModel::GetItemKeyForCheckedItem() const { |
| } |
| void SuggestionsMenuModel::SetCheckedItem(const std::string& item_key) { |
| - for (size_t i = 0; i < items_.size(); ++i) { |
| - if (items_[i].first == item_key) { |
| - checked_item_ = i; |
| - return; |
| - } |
| - } |
| - |
| - NOTREACHED(); |
| + SetCheckedItemNthWithKey(item_key, 1); |
| } |
| void SuggestionsMenuModel::SetCheckedIndex(size_t index) { |
| @@ -91,6 +84,17 @@ void SuggestionsMenuModel::SetCheckedIndex(size_t index) { |
| checked_item_ = index; |
| } |
| +void SuggestionsMenuModel::SetCheckedItemNthWithKey(const std::string& item_key, |
| + size_t n) { |
| + for (size_t i = 0; i < items_.size(); ++i) { |
| + if (items_[i].first == item_key) { |
| + checked_item_ = i; |
| + if (n-- <= 1) |
|
Ilya Sherman
2013/05/21 03:54:35
nit: Please write this as two separate statements,
Evan Stade
2013/05/21 17:34:41
I don't see anything about this in the style guide
|
| + return; |
| + } |
| + } |
| +} |
| + |
| bool SuggestionsMenuModel::IsCommandIdChecked( |
| int command_id) const { |
| return checked_item_ == command_id; |