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

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

Issue 2884051: Merge 53276 - AutoFill Empty profiles should not be saved from AutoFillDialog... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/472/src/
Patch Set: Created 10 years, 4 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/autofill/autofill_profile.h ('k') | chrome/browser/autofill/credit_card.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) 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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 // E.g. "John Smith, 123 Main Street". 198 // E.g. "John Smith, 123 Main Street".
199 string16 summary_format = l10n_util::GetStringFUTF16( 199 string16 summary_format = l10n_util::GetStringFUTF16(
200 IDS_AUTOFILL_DIALOG_ADDRESS_SUMMARY_FORMAT, 200 IDS_AUTOFILL_DIALOG_ADDRESS_SUMMARY_FORMAT,
201 name_format, 201 name_format,
202 summary_separator, 202 summary_separator,
203 address); 203 address);
204 204
205 return summary_format; 205 return summary_format;
206 } 206 }
207 207
208 // static
208 bool AutoFillProfile::AdjustInferredLabels( 209 bool AutoFillProfile::AdjustInferredLabels(
209 std::vector<AutoFillProfile*>* profiles) { 210 std::vector<AutoFillProfile*>* profiles) {
210 std::vector<string16> created_labels; 211 std::vector<string16> created_labels;
211 const size_t kMinimalFieldsShown = 2; 212 const size_t kMinimalFieldsShown = 2;
212 CreateInferredLabels(profiles, &created_labels, kMinimalFieldsShown, 213 CreateInferredLabels(profiles, &created_labels, kMinimalFieldsShown,
213 UNKNOWN_TYPE); 214 UNKNOWN_TYPE);
214 DCHECK(profiles->size() == created_labels.size()); 215 DCHECK(profiles->size() == created_labels.size());
215 bool updated_labels = false; 216 bool updated_labels = false;
216 for (size_t i = 0; i < profiles->size(); ++i) { 217 for (size_t i = 0; i < profiles->size(); ++i) {
217 if (profiles->at(i)->Label() != created_labels[i]) { 218 if (profiles->at(i)->Label() != created_labels[i]) {
218 updated_labels = true; 219 updated_labels = true;
219 profiles->at(i)->set_label(created_labels[i]); 220 profiles->at(i)->set_label(created_labels[i]);
220 } 221 }
221 } 222 }
222 return updated_labels; 223 return updated_labels;
223 } 224 }
224 225
226 // static
225 void AutoFillProfile::CreateInferredLabels( 227 void AutoFillProfile::CreateInferredLabels(
226 const std::vector<AutoFillProfile*>* profiles, 228 const std::vector<AutoFillProfile*>* profiles,
227 std::vector<string16>* created_labels, 229 std::vector<string16>* created_labels,
228 size_t minimal_fields_shown, 230 size_t minimal_fields_shown,
229 AutoFillFieldType exclude_field) { 231 AutoFillFieldType exclude_field) {
230 // These fields are use to distinguish between two profiles in the order of 232 // These fields are use to distinguish between two profiles in the order of
231 // importance, e. g. if both EMAIL_ADDRESS and COMPANY_NAME are different, 233 // importance, e. g. if both EMAIL_ADDRESS and COMPANY_NAME are different,
232 // EMAIL_ADDRESS will be used to distinguish them. 234 // EMAIL_ADDRESS will be used to distinguish them.
233 const AutoFillFieldType distinguishing_fields[] = { 235 const AutoFillFieldType distinguishing_fields[] = {
234 // First non empty data are always present in the label, even if it matches. 236 // First non empty data are always present in the label, even if it matches.
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 } 370 }
369 } 371 }
370 372
371 (*created_labels)[label_iterator->second.front()] = 373 (*created_labels)[label_iterator->second.front()] =
372 profiles->at(label_iterator->second.front())->ConstructInferredLabel( 374 profiles->at(label_iterator->second.front())->ConstructInferredLabel(
373 &non_empty_fields); 375 &non_empty_fields);
374 } 376 }
375 } 377 }
376 } 378 }
377 379
380 bool AutoFillProfile::IsEmpty() const {
381 FieldTypeSet types;
382 GetAvailableFieldTypes(&types);
383 return types.empty();
384 }
385
378 void AutoFillProfile::operator=(const AutoFillProfile& source) { 386 void AutoFillProfile::operator=(const AutoFillProfile& source) {
379 label_ = source.label_; 387 label_ = source.label_;
380 unique_id_ = source.unique_id_; 388 unique_id_ = source.unique_id_;
381 389
382 STLDeleteContainerPairSecondPointers(personal_info_.begin(), 390 STLDeleteContainerPairSecondPointers(personal_info_.begin(),
383 personal_info_.end()); 391 personal_info_.end());
384 personal_info_.clear(); 392 personal_info_.clear();
385 393
386 FormGroupMap::const_iterator iter; 394 FormGroupMap::const_iterator iter;
387 for (iter = source.personal_info_.begin(); 395 for (iter = source.personal_info_.begin();
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 << UTF16ToUTF8(profile.GetFieldText(AutoFillType(ADDRESS_HOME_ZIP))) 491 << UTF16ToUTF8(profile.GetFieldText(AutoFillType(ADDRESS_HOME_ZIP)))
484 << " " 492 << " "
485 << UTF16ToUTF8(profile.GetFieldText(AutoFillType(ADDRESS_HOME_COUNTRY))) 493 << UTF16ToUTF8(profile.GetFieldText(AutoFillType(ADDRESS_HOME_COUNTRY)))
486 << " " 494 << " "
487 << UTF16ToUTF8(profile.GetFieldText(AutoFillType( 495 << UTF16ToUTF8(profile.GetFieldText(AutoFillType(
488 PHONE_HOME_WHOLE_NUMBER))) 496 PHONE_HOME_WHOLE_NUMBER)))
489 << " " 497 << " "
490 << UTF16ToUTF8(profile.GetFieldText(AutoFillType( 498 << UTF16ToUTF8(profile.GetFieldText(AutoFillType(
491 PHONE_FAX_WHOLE_NUMBER))); 499 PHONE_FAX_WHOLE_NUMBER)));
492 } 500 }
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_profile.h ('k') | chrome/browser/autofill/credit_card.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698