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

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: Compare only content for merging. 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() &&
452 origin() == profile.origin() && 464 EqualsSansGuid(profile);
Ilya Sherman 2014/04/09 23:58:31 nit: Looks like this fits on a single line now?
please use gerrit instead 2014/04/10 00:14:23 Done.
453 Compare(profile) == 0;
454 } 465 }
455 466
456 bool AutofillProfile::operator!=(const AutofillProfile& profile) const { 467 bool AutofillProfile::operator!=(const AutofillProfile& profile) const {
457 return !operator==(profile); 468 return !operator==(profile);
458 } 469 }
459 470
460 const base::string16 AutofillProfile::PrimaryValue() const { 471 const base::string16 AutofillProfile::PrimaryValue() const {
461 return GetRawInfo(ADDRESS_HOME_LINE1) + GetRawInfo(ADDRESS_HOME_CITY); 472 return GetRawInfo(ADDRESS_HOME_LINE1) + GetRawInfo(ADDRESS_HOME_CITY);
462 } 473 }
463 474
(...skipping 29 matching lines...) Expand all
493 } 504 }
494 505
495 return true; 506 return true;
496 } 507 }
497 508
498 void AutofillProfile::OverwriteWithOrAddTo(const AutofillProfile& profile, 509 void AutofillProfile::OverwriteWithOrAddTo(const AutofillProfile& profile,
499 const std::string& app_locale) { 510 const std::string& app_locale) {
500 // Verified profiles should never be overwritten with unverified data. 511 // Verified profiles should never be overwritten with unverified data.
501 DCHECK(!IsVerified() || profile.IsVerified()); 512 DCHECK(!IsVerified() || profile.IsVerified());
502 set_origin(profile.origin()); 513 set_origin(profile.origin());
514 set_language_code(profile.language_code());
503 515
504 ServerFieldTypeSet field_types; 516 ServerFieldTypeSet field_types;
505 profile.GetNonEmptyTypes(app_locale, &field_types); 517 profile.GetNonEmptyTypes(app_locale, &field_types);
506 518
507 // Only transfer "full" types (e.g. full name) and not fragments (e.g. 519 // Only transfer "full" types (e.g. full name) and not fragments (e.g.
508 // first name, last name). 520 // first name, last name).
509 CollapseCompoundFieldTypes(&field_types); 521 CollapseCompoundFieldTypes(&field_types);
510 522
511 // TODO(isherman): Revisit this decision in the context of i18n and storing 523 // 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. 524 // 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)) 850 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_CITY))
839 << " " 851 << " "
840 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_STATE)) 852 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_STATE))
841 << " " 853 << " "
842 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_ZIP)) 854 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_ZIP))
843 << " " 855 << " "
844 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_SORTING_CODE)) 856 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_SORTING_CODE))
845 << " " 857 << " "
846 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_COUNTRY)) 858 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_COUNTRY))
847 << " " 859 << " "
860 << profile.language_code()
861 << " "
848 << UTF16ToUTF8(MultiString(profile, PHONE_HOME_WHOLE_NUMBER)); 862 << UTF16ToUTF8(MultiString(profile, PHONE_HOME_WHOLE_NUMBER));
849 } 863 }
850 864
851 } // namespace autofill 865 } // 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