Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3716)

Unified Diff: chrome/browser/ui/autofill/autofill_dialog_models.cc

Issue 15500008: Persist the choice of AutofillDataModel when using the requestAutocomplete dialog. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: better comment Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;

Powered by Google App Engine
This is Rietveld 408576698