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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/ui/autofill/autofill_dialog_models.h" 5 #include "chrome/browser/ui/autofill/autofill_dialog_models.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 } 69 }
70 70
71 std::string SuggestionsMenuModel::GetItemKeyForCheckedItem() const { 71 std::string SuggestionsMenuModel::GetItemKeyForCheckedItem() const {
72 if (items_.empty()) 72 if (items_.empty())
73 return std::string(); 73 return std::string();
74 74
75 return items_[checked_item_].first; 75 return items_[checked_item_].first;
76 } 76 }
77 77
78 void SuggestionsMenuModel::SetCheckedItem(const std::string& item_key) { 78 void SuggestionsMenuModel::SetCheckedItem(const std::string& item_key) {
79 for (size_t i = 0; i < items_.size(); ++i) { 79 SetCheckedItemNthWithKey(item_key, 1);
80 if (items_[i].first == item_key) {
81 checked_item_ = i;
82 return;
83 }
84 }
85
86 NOTREACHED();
87 } 80 }
88 81
89 void SuggestionsMenuModel::SetCheckedIndex(size_t index) { 82 void SuggestionsMenuModel::SetCheckedIndex(size_t index) {
90 DCHECK_LE(index, items_.size()); 83 DCHECK_LE(index, items_.size());
91 checked_item_ = index; 84 checked_item_ = index;
92 } 85 }
93 86
87 void SuggestionsMenuModel::SetCheckedItemNthWithKey(const std::string& item_key,
88 size_t n) {
89 for (size_t i = 0; i < items_.size(); ++i) {
90 if (items_[i].first == item_key) {
91 checked_item_ = i;
92 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
93 return;
94 }
95 }
96 }
97
94 bool SuggestionsMenuModel::IsCommandIdChecked( 98 bool SuggestionsMenuModel::IsCommandIdChecked(
95 int command_id) const { 99 int command_id) const {
96 return checked_item_ == command_id; 100 return checked_item_ == command_id;
97 } 101 }
98 102
99 bool SuggestionsMenuModel::IsCommandIdEnabled( 103 bool SuggestionsMenuModel::IsCommandIdEnabled(
100 int command_id) const { 104 int command_id) const {
101 return true; 105 return true;
102 } 106 }
103 107
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 } 152 }
149 153
150 string16 YearComboboxModel::GetItemAt(int index) { 154 string16 YearComboboxModel::GetItemAt(int index) {
151 if (index == 0) 155 if (index == 0)
152 return string16(); 156 return string16();
153 157
154 return base::IntToString16(this_year_ + index - 1); 158 return base::IntToString16(this_year_ + index - 1);
155 } 159 }
156 160
157 } // autofill 161 } // autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698