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

Side by Side Diff: chrome/browser/autofill/autofill_profile.cc

Issue 3806008: Never allow empty preview entries. As some data is always present (we drop co... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 2 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/autofill/autofill_profile.h" 5 #include "chrome/browser/autofill/autofill_profile.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <list> 8 #include <list>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 profile->personal_info_[iter->first] = iter->second->Clone(); 168 profile->personal_info_[iter->first] = iter->second->Clone();
169 } 169 }
170 170
171 return profile; 171 return profile;
172 } 172 }
173 173
174 const string16& AutoFillProfile::Label() const { 174 const string16& AutoFillProfile::Label() const {
175 return label_; 175 return label_;
176 } 176 }
177 177
178 string16 AutoFillProfile::PreviewSummary() const {
179 // Fetch the components of the summary string. Any or all of these
180 // may be an empty string.
181 string16 first_name = GetFieldText(AutoFillType(NAME_FIRST));
182 string16 last_name = GetFieldText(AutoFillType(NAME_LAST));
183 string16 address = GetFieldText(AutoFillType(ADDRESS_HOME_LINE1));
184
185 // String separators depend (below) on the existence of the various fields.
186 bool have_first_name = first_name.length() > 0;
187 bool have_last_name = last_name.length() > 0;
188 bool have_address = address.length() > 0;
189
190 // Name separator defaults to "". Space if we have first and last name.
191 string16 name_separator;
192
193 if (have_first_name && have_last_name) {
194 name_separator = l10n_util::GetStringUTF16(
195 IDS_AUTOFILL_DIALOG_ADDRESS_NAME_SEPARATOR);
196 }
197
198 // E.g. "John Smith", or "John", or "Smith", or "".
199 string16 name_format = l10n_util::GetStringFUTF16(
200 IDS_AUTOFILL_DIALOG_ADDRESS_SUMMARY_NAME_FORMAT,
201 first_name,
202 name_separator,
203 last_name);
204
205 // Summary separator defaults to "". ", " if we have name and address.
206 string16 summary_separator;
207 if ((have_first_name || have_last_name) && have_address) {
208 summary_separator = l10n_util::GetStringUTF16(
209 IDS_AUTOFILL_DIALOG_ADDRESS_SUMMARY_SEPARATOR);
210 }
211
212 // E.g. "John Smith, 123 Main Street".
213 string16 summary_format = l10n_util::GetStringFUTF16(
214 IDS_AUTOFILL_DIALOG_ADDRESS_SUMMARY_FORMAT,
215 name_format,
216 summary_separator,
217 address);
218
219 return summary_format;
220 }
221
222 // static 178 // static
223 bool AutoFillProfile::AdjustInferredLabels( 179 bool AutoFillProfile::AdjustInferredLabels(
224 std::vector<AutoFillProfile*>* profiles) { 180 std::vector<AutoFillProfile*>* profiles) {
225 std::vector<string16> created_labels; 181 std::vector<string16> created_labels;
226 const size_t kMinimalFieldsShown = 2; 182 const size_t kMinimalFieldsShown = 2;
227 CreateInferredLabels(profiles, &created_labels, kMinimalFieldsShown, 183 CreateInferredLabels(profiles, &created_labels, kMinimalFieldsShown,
228 UNKNOWN_TYPE); 184 UNKNOWN_TYPE);
229 DCHECK(profiles->size() == created_labels.size()); 185 DCHECK(profiles->size() == created_labels.size());
230 bool updated_labels = false; 186 bool updated_labels = false;
231 for (size_t i = 0; i < profiles->size(); ++i) { 187 for (size_t i = 0; i < profiles->size(); ++i) {
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 << UTF16ToUTF8(profile.GetFieldText(AutoFillType(ADDRESS_HOME_ZIP))) 490 << UTF16ToUTF8(profile.GetFieldText(AutoFillType(ADDRESS_HOME_ZIP)))
535 << " " 491 << " "
536 << UTF16ToUTF8(profile.GetFieldText(AutoFillType(ADDRESS_HOME_COUNTRY))) 492 << UTF16ToUTF8(profile.GetFieldText(AutoFillType(ADDRESS_HOME_COUNTRY)))
537 << " " 493 << " "
538 << UTF16ToUTF8(profile.GetFieldText(AutoFillType( 494 << UTF16ToUTF8(profile.GetFieldText(AutoFillType(
539 PHONE_HOME_WHOLE_NUMBER))) 495 PHONE_HOME_WHOLE_NUMBER)))
540 << " " 496 << " "
541 << UTF16ToUTF8(profile.GetFieldText(AutoFillType( 497 << UTF16ToUTF8(profile.GetFieldText(AutoFillType(
542 PHONE_FAX_WHOLE_NUMBER))); 498 PHONE_FAX_WHOLE_NUMBER)));
543 } 499 }
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_profile.h ('k') | chrome/browser/autofill/autofill_profile_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698