Index: chrome/browser/autofill/address.cc |
diff --git a/chrome/browser/autofill/address.cc b/chrome/browser/autofill/address.cc |
index 8e75eeca85e72ac4e48c43f2e2bb8a8f0ca06b2a..65f11d11afcb9a13ded06620b0fb574b75e52cd7 100644 |
--- a/chrome/browser/autofill/address.cc |
+++ b/chrome/browser/autofill/address.cc |
@@ -6,6 +6,8 @@ |
#include "base/basictypes.h" |
#include "base/string_util.h" |
+#include "base/utf_string_conversions.h" |
James Hawkins
2011/02/16 19:49:01
Where is it used?
Ilya Sherman
2011/02/17 23:09:11
Removed. I wish cpplint.py would tell me about th
|
+#include "chrome/browser/autofill/autofill_country.h" |
#include "chrome/browser/autofill/autofill_type.h" |
#include "chrome/browser/autofill/field_types.h" |
@@ -83,7 +85,7 @@ void Address::GetAvailableFieldTypes(FieldTypeSet* available_types) const { |
if (!zip_code().empty()) |
available_types->insert(GetZipCodeType()); |
- if (!country().empty()) |
+ if (!country_code().empty()) |
available_types->insert(GetCountryType()); |
} |
@@ -125,7 +127,7 @@ string16 Address::GetFieldText(const AutoFillType& type) const { |
return zip_code(); |
if (field_type == GetCountryType()) |
- return country(); |
+ return Country(); |
return string16(); |
} |
@@ -143,7 +145,7 @@ void Address::SetInfo(const AutoFillType& type, const string16& value) { |
else if (subgroup == AutoFillType::ADDRESS_STATE) |
set_state(value); |
else if (subgroup == AutoFillType::ADDRESS_COUNTRY) |
- set_country(value); |
+ SetCountry(value); |
else if (subgroup == AutoFillType::ADDRESS_ZIP) |
set_zip_code(value); |
else |
@@ -158,18 +160,20 @@ void Address::Clear() { |
apt_num_.clear(); |
city_.clear(); |
state_.clear(); |
- country_.clear(); |
+ country_code_.clear(); |
zip_code_.clear(); |
} |
void Address::Clone(const Address& address) { |
- set_line1(address.line1()); |
- set_line2(address.line2()); |
- set_apt_num(address.apt_num()); |
- set_city(address.city()); |
- set_state(address.state()); |
- set_country(address.country()); |
- set_zip_code(address.zip_code()); |
+ line1_tokens_ = address.line1_tokens_; |
+ line2_tokens_ = address.line2_tokens_; |
+ line1_ = address.line1_; |
+ line2_ = address.line2_; |
+ apt_num_ = address.apt_num_; |
+ city_ = address.city_; |
+ state_ = address.state_; |
+ country_code_ = address.country_code_; |
+ zip_code_ = address.zip_code_; |
} |
Address::Address(const Address& address) |
@@ -181,10 +185,17 @@ Address::Address(const Address& address) |
apt_num_(address.apt_num_), |
city_(address.city_), |
state_(address.state_), |
- country_(address.country_), |
+ country_code_(address.country_code_), |
zip_code_(address.zip_code_) { |
} |
+string16 Address::Country() const { |
+ if (country_code().empty()) |
+ return string16(); |
+ |
+ return AutoFillCountry(country_code()).name(); |
+} |
+ |
void Address::set_line1(const string16& line1) { |
line1_ = line1; |
line1_tokens_.clear(); |
@@ -203,6 +214,10 @@ void Address::set_line2(const string16& line2) { |
*iter = StringToLowerASCII(*iter); |
} |
+void Address::SetCountry(const string16& country) { |
+ country_code_ = AutoFillCountry::GetCountryCode(country); |
+} |
+ |
bool Address::IsLine1(const string16& text) const { |
return IsLineMatch(text, line1_tokens_); |
} |
@@ -224,7 +239,8 @@ bool Address::IsState(const string16& text) const { |
} |
bool Address::IsCountry(const string16& text) const { |
- return (StringToLowerASCII(country_) == StringToLowerASCII(text)); |
+ std::string country_code = AutoFillCountry::GetCountryCode(text); |
+ return (!country_code.empty() && country_code_ == country_code); |
} |
bool Address::IsZipCode(const string16& text) const { |
@@ -253,8 +269,8 @@ bool Address::FindInfoMatchesHelper(const FieldTypeSubGroup& subgroup, |
StartsWith(state(), info, false)) { |
*match = state(); |
} else if (subgroup == AutoFillType::ADDRESS_COUNTRY && |
- StartsWith(country(), info, false)) { |
- *match = country(); |
+ StartsWith(Country(), info, false)) { |
+ *match = Country(); |
} else if (subgroup == AutoFillType::ADDRESS_ZIP && |
StartsWith(zip_code(), info, true)) { |
*match = zip_code(); |