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

Side by Side Diff: components/autofill/core/browser/autofill_profile.cc

Issue 212873003: Store the language code for the address in autofill profile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixups Created 6 years, 8 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/autofill/core/browser/autofill_profile.h" 5 #include "components/autofill/core/browser/autofill_profile.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <map> 9 #include <map>
10 #include <ostream> 10 #include <ostream>
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 255
256 name_ = profile.name_; 256 name_ = profile.name_;
257 email_ = profile.email_; 257 email_ = profile.email_;
258 company_ = profile.company_; 258 company_ = profile.company_;
259 phone_number_ = profile.phone_number_; 259 phone_number_ = profile.phone_number_;
260 260
261 for (size_t i = 0; i < phone_number_.size(); ++i) 261 for (size_t i = 0; i < phone_number_.size(); ++i)
262 phone_number_[i].set_profile(this); 262 phone_number_[i].set_profile(this);
263 263
264 address_ = profile.address_; 264 address_ = profile.address_;
265 set_language_code(profile.language_code());
265 266
266 return *this; 267 return *this;
267 } 268 }
268 269
269 void AutofillProfile::GetMatchingTypes( 270 void AutofillProfile::GetMatchingTypes(
270 const base::string16& text, 271 const base::string16& text,
271 const std::string& app_locale, 272 const std::string& app_locale,
272 ServerFieldTypeSet* matching_types) const { 273 ServerFieldTypeSet* matching_types) const {
273 FormGroupList info = FormGroups(); 274 FormGroupList info = FormGroups();
274 for (FormGroupList::const_iterator it = info.begin(); it != info.end(); ++it) 275 for (FormGroupList::const_iterator it = info.begin(); it != info.end(); ++it)
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 395
395 case EMAIL_ADDRESS: 396 case EMAIL_ADDRESS:
396 return !autofill::IsValidEmailAddress(data); 397 return !autofill::IsValidEmailAddress(data);
397 398
398 default: 399 default:
399 NOTREACHED(); 400 NOTREACHED();
400 return false; 401 return false;
401 } 402 }
402 } 403 }
403 404
404
405 int AutofillProfile::Compare(const AutofillProfile& profile) const { 405 int AutofillProfile::Compare(const AutofillProfile& profile) const {
406 const ServerFieldType single_value_types[] = { 406 const ServerFieldType single_value_types[] = {
407 COMPANY_NAME, 407 COMPANY_NAME,
408 ADDRESS_HOME_LINE1, 408 ADDRESS_HOME_LINE1,
409 ADDRESS_HOME_LINE2, 409 ADDRESS_HOME_LINE2,
410 ADDRESS_HOME_DEPENDENT_LOCALITY, 410 ADDRESS_HOME_DEPENDENT_LOCALITY,
411 ADDRESS_HOME_CITY, 411 ADDRESS_HOME_CITY,
412 ADDRESS_HOME_STATE, 412 ADDRESS_HOME_STATE,
413 ADDRESS_HOME_ZIP, 413 ADDRESS_HOME_ZIP,
414 ADDRESS_HOME_SORTING_CODE, 414 ADDRESS_HOME_SORTING_CODE,
(...skipping 25 matching lines...) Expand all
440 for (size_t j = 0; j < values_a.size(); ++j) { 440 for (size_t j = 0; j < values_a.size(); ++j) {
441 int comparison = values_a[j].compare(values_b[j]); 441 int comparison = values_a[j].compare(values_b[j]);
442 if (comparison != 0) 442 if (comparison != 0)
443 return comparison; 443 return comparison;
444 } 444 }
445 } 445 }
446 446
447 return 0; 447 return 0;
448 } 448 }
449 449
450 bool AutofillProfile::EqualsSansOrigin(const AutofillProfile& profile) const {
451 return guid() == profile.guid() &&
452 language_code() == profile.language_code() &&
453 Compare(profile) == 0;
454 }
455
456 bool AutofillProfile::EqualsSansGuid(const AutofillProfile& profile) const {
457 return origin() == profile.origin() &&
458 language_code() == profile.language_code() &&
459 Compare(profile) == 0;
460 }
461
450 bool AutofillProfile::operator==(const AutofillProfile& profile) const { 462 bool AutofillProfile::operator==(const AutofillProfile& profile) const {
451 return guid() == profile.guid() && 463 return guid() == profile.guid() && EqualsSansGuid(profile);
452 origin() == profile.origin() &&
453 Compare(profile) == 0;
454 } 464 }
455 465
456 bool AutofillProfile::operator!=(const AutofillProfile& profile) const { 466 bool AutofillProfile::operator!=(const AutofillProfile& profile) const {
457 return !operator==(profile); 467 return !operator==(profile);
458 } 468 }
459 469
460 const base::string16 AutofillProfile::PrimaryValue() const { 470 const base::string16 AutofillProfile::PrimaryValue() const {
461 return GetRawInfo(ADDRESS_HOME_LINE1) + GetRawInfo(ADDRESS_HOME_CITY); 471 return GetRawInfo(ADDRESS_HOME_LINE1) + GetRawInfo(ADDRESS_HOME_CITY);
462 } 472 }
463 473
(...skipping 29 matching lines...) Expand all
493 } 503 }
494 504
495 return true; 505 return true;
496 } 506 }
497 507
498 void AutofillProfile::OverwriteWithOrAddTo(const AutofillProfile& profile, 508 void AutofillProfile::OverwriteWithOrAddTo(const AutofillProfile& profile,
499 const std::string& app_locale) { 509 const std::string& app_locale) {
500 // Verified profiles should never be overwritten with unverified data. 510 // Verified profiles should never be overwritten with unverified data.
501 DCHECK(!IsVerified() || profile.IsVerified()); 511 DCHECK(!IsVerified() || profile.IsVerified());
502 set_origin(profile.origin()); 512 set_origin(profile.origin());
513 set_language_code(profile.language_code());
503 514
504 ServerFieldTypeSet field_types; 515 ServerFieldTypeSet field_types;
505 profile.GetNonEmptyTypes(app_locale, &field_types); 516 profile.GetNonEmptyTypes(app_locale, &field_types);
506 517
507 // Only transfer "full" types (e.g. full name) and not fragments (e.g. 518 // Only transfer "full" types (e.g. full name) and not fragments (e.g.
508 // first name, last name). 519 // first name, last name).
509 CollapseCompoundFieldTypes(&field_types); 520 CollapseCompoundFieldTypes(&field_types);
510 521
511 // TODO(isherman): Revisit this decision in the context of i18n and storing 522 // TODO(isherman): Revisit this decision in the context of i18n and storing
512 // full addresses rather than storing 1-to-2 lines of an address. 523 // full addresses rather than storing 1-to-2 lines of an address.
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_CITY)) 849 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_CITY))
839 << " " 850 << " "
840 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_STATE)) 851 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_STATE))
841 << " " 852 << " "
842 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_ZIP)) 853 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_ZIP))
843 << " " 854 << " "
844 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_SORTING_CODE)) 855 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_SORTING_CODE))
845 << " " 856 << " "
846 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_COUNTRY)) 857 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_COUNTRY))
847 << " " 858 << " "
859 << profile.language_code()
860 << " "
848 << UTF16ToUTF8(MultiString(profile, PHONE_HOME_WHOLE_NUMBER)); 861 << UTF16ToUTF8(MultiString(profile, PHONE_HOME_WHOLE_NUMBER));
849 } 862 }
850 863
851 } // namespace autofill 864 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/autofill_profile.h ('k') | components/autofill/core/browser/autofill_profile_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698