OLD | NEW |
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 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 | 410 |
411 bool AutofillProfile::IsEmpty(const std::string& app_locale) const { | 411 bool AutofillProfile::IsEmpty(const std::string& app_locale) const { |
412 ServerFieldTypeSet types; | 412 ServerFieldTypeSet types; |
413 GetNonEmptyTypes(app_locale, &types); | 413 GetNonEmptyTypes(app_locale, &types); |
414 return types.empty(); | 414 return types.empty(); |
415 } | 415 } |
416 | 416 |
417 bool AutofillProfile::IsPresentButInvalid(ServerFieldType type) const { | 417 bool AutofillProfile::IsPresentButInvalid(ServerFieldType type) const { |
418 std::string country = UTF16ToUTF8(GetRawInfo(ADDRESS_HOME_COUNTRY)); | 418 std::string country = UTF16ToUTF8(GetRawInfo(ADDRESS_HOME_COUNTRY)); |
419 base::string16 data = GetRawInfo(type); | 419 base::string16 data = GetRawInfo(type); |
| 420 if (data.empty()) |
| 421 return false; |
| 422 |
420 switch (type) { | 423 switch (type) { |
421 case ADDRESS_HOME_STATE: | 424 case ADDRESS_HOME_STATE: |
422 if (!data.empty() && country == "US" && !autofill::IsValidState(data)) | 425 return country == "US" && !autofill::IsValidState(data); |
423 return true; | |
424 break; | |
425 | 426 |
426 case ADDRESS_HOME_ZIP: | 427 case ADDRESS_HOME_ZIP: |
427 if (!data.empty() && country == "US" && !autofill::IsValidZip(data)) | 428 return country == "US" && !autofill::IsValidZip(data); |
428 return true; | |
429 break; | |
430 | 429 |
431 case PHONE_HOME_WHOLE_NUMBER: { | 430 case PHONE_HOME_WHOLE_NUMBER: |
432 if (!data.empty() && !i18n::PhoneObject(data, country).IsValidNumber()) | 431 return !i18n::PhoneObject(data, country).IsValidNumber(); |
433 return true; | 432 |
434 break; | 433 case EMAIL_ADDRESS: |
435 } | 434 return !autofill::IsValidEmailAddress(data); |
436 | 435 |
437 default: | 436 default: |
438 NOTREACHED(); | 437 NOTREACHED(); |
439 break; | 438 return false; |
440 } | 439 } |
441 | |
442 return false; | |
443 } | 440 } |
444 | 441 |
445 | 442 |
446 int AutofillProfile::Compare(const AutofillProfile& profile) const { | 443 int AutofillProfile::Compare(const AutofillProfile& profile) const { |
447 const ServerFieldType single_value_types[] = { COMPANY_NAME, | 444 const ServerFieldType single_value_types[] = { COMPANY_NAME, |
448 ADDRESS_HOME_LINE1, | 445 ADDRESS_HOME_LINE1, |
449 ADDRESS_HOME_LINE2, | 446 ADDRESS_HOME_LINE2, |
450 ADDRESS_HOME_CITY, | 447 ADDRESS_HOME_CITY, |
451 ADDRESS_HOME_STATE, | 448 ADDRESS_HOME_STATE, |
452 ADDRESS_HOME_ZIP, | 449 ADDRESS_HOME_ZIP, |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
897 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_STATE)) | 894 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_STATE)) |
898 << " " | 895 << " " |
899 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_ZIP)) | 896 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_ZIP)) |
900 << " " | 897 << " " |
901 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_COUNTRY)) | 898 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_COUNTRY)) |
902 << " " | 899 << " " |
903 << UTF16ToUTF8(MultiString(profile, PHONE_HOME_WHOLE_NUMBER)); | 900 << UTF16ToUTF8(MultiString(profile, PHONE_HOME_WHOLE_NUMBER)); |
904 } | 901 } |
905 | 902 |
906 } // namespace autofill | 903 } // namespace autofill |
OLD | NEW |