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

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: fix bad merge resolution 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
« no previous file with comments | « chrome/browser/ui/autofill/autofill_dialog_models.h ('k') | chrome/common/pref_names.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 } 74 }
75 75
76 std::string SuggestionsMenuModel::GetItemKeyForCheckedItem() const { 76 std::string SuggestionsMenuModel::GetItemKeyForCheckedItem() const {
77 if (items_.empty()) 77 if (items_.empty())
78 return std::string(); 78 return std::string();
79 79
80 return items_[checked_item_].key; 80 return items_[checked_item_].key;
81 } 81 }
82 82
83 void SuggestionsMenuModel::SetCheckedItem(const std::string& item_key) { 83 void SuggestionsMenuModel::SetCheckedItem(const std::string& item_key) {
84 checked_item_ = GetItemIndex(item_key); 84 SetCheckedItemNthWithKey(item_key, 1);
85 } 85 }
86 86
87 void SuggestionsMenuModel::SetCheckedIndex(size_t index) { 87 void SuggestionsMenuModel::SetCheckedIndex(size_t index) {
88 DCHECK_LT(index, items_.size()); 88 DCHECK_LT(index, items_.size());
89 checked_item_ = index; 89 checked_item_ = index;
90 } 90 }
91 91
92 void SuggestionsMenuModel::SetCheckedItemNthWithKey(const std::string& item_key,
93 size_t n) {
94 for (size_t i = 0; i < items_.size(); ++i) {
95 if (items_[i].key == item_key) {
96 checked_item_ = i;
97 if (n-- <= 1)
98 return;
99 }
100 }
101 }
102
92 void SuggestionsMenuModel::SetEnabled(const std::string& item_key, 103 void SuggestionsMenuModel::SetEnabled(const std::string& item_key,
93 bool enabled) { 104 bool enabled) {
94 items_[GetItemIndex(item_key)].enabled = enabled; 105 items_[GetItemIndex(item_key)].enabled = enabled;
95 } 106 }
96 107
97 bool SuggestionsMenuModel::IsCommandIdChecked( 108 bool SuggestionsMenuModel::IsCommandIdChecked(
98 int command_id) const { 109 int command_id) const {
99 return checked_item_ == command_id; 110 return checked_item_ == command_id;
100 } 111 }
101 112
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 } 175 }
165 176
166 string16 YearComboboxModel::GetItemAt(int index) { 177 string16 YearComboboxModel::GetItemAt(int index) {
167 if (index == 0) 178 if (index == 0)
168 return string16(); 179 return string16();
169 180
170 return base::IntToString16(this_year_ + index - 1); 181 return base::IntToString16(this_year_ + index - 1);
171 } 182 }
172 183
173 } // autofill 184 } // autofill
OLDNEW
« no previous file with comments | « chrome/browser/ui/autofill/autofill_dialog_models.h ('k') | chrome/common/pref_names.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698