Chromium Code Reviews| 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/content/browser/wallet/wallet_address.h" | 5 #include "components/autofill/content/browser/wallet/wallet_address.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/string_split.h" | |
| 8 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 10 #include "base/values.h" | 11 #include "base/values.h" |
| 11 #include "components/autofill/core/browser/autofill_country.h" | 12 #include "components/autofill/core/browser/autofill_country.h" |
| 12 #include "components/autofill/core/browser/autofill_profile.h" | 13 #include "components/autofill/core/browser/autofill_profile.h" |
| 13 #include "components/autofill/core/browser/autofill_type.h" | 14 #include "components/autofill/core/browser/autofill_type.h" |
| 14 #include "components/autofill/core/browser/phone_number.h" | 15 #include "components/autofill/core/browser/phone_number.h" |
| 15 #include "components/autofill/core/browser/state_names.h" | 16 #include "components/autofill/core/browser/state_names.h" |
| 16 | 17 |
| 17 namespace autofill { | 18 namespace autofill { |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 37 DLOG(ERROR) << "Response from Google Wallet missing recipient name"; | 38 DLOG(ERROR) << "Response from Google Wallet missing recipient name"; |
| 38 return NULL; | 39 return NULL; |
| 39 } | 40 } |
| 40 | 41 |
| 41 base::string16 postal_code_number; | 42 base::string16 postal_code_number; |
| 42 if (!dictionary.GetString("postal_address.postal_code_number", | 43 if (!dictionary.GetString("postal_address.postal_code_number", |
| 43 &postal_code_number)) { | 44 &postal_code_number)) { |
| 44 DLOG(ERROR) << "Response from Google Wallet missing postal code number"; | 45 DLOG(ERROR) << "Response from Google Wallet missing postal code number"; |
| 45 return NULL; | 46 return NULL; |
| 46 } | 47 } |
| 48 // TODO(estade): what about postal_code_number_extension? | |
| 49 | |
| 50 base::string16 sorting_code; | |
| 51 if (!dictionary.GetString("postal_address.sorting_code", | |
| 52 &sorting_code)) { | |
| 53 DVLOG(1) << "Response from Google Wallet missing sorting code"; | |
|
Dan Beam
2014/02/12 21:34:33
^ I don't think these things are particularly usef
Evan Stade
2014/02/12 23:32:13
just following convention; feel free to create a s
| |
| 54 } | |
| 47 | 55 |
| 48 base::string16 phone_number; | 56 base::string16 phone_number; |
| 49 if (!dictionary.GetString("phone_number", &phone_number)) | 57 if (!dictionary.GetString("phone_number", &phone_number)) |
| 50 DVLOG(1) << "Response from Google Wallet missing phone number"; | 58 DVLOG(1) << "Response from Google Wallet missing phone number"; |
| 51 | 59 |
| 52 base::string16 address_line_1; | 60 std::vector<base::string16> street_address; |
| 53 base::string16 address_line_2; | |
| 54 const base::ListValue* address_line_list; | 61 const base::ListValue* address_line_list; |
| 55 if (dictionary.GetList("postal_address.address_line", &address_line_list)) { | 62 if (dictionary.GetList("postal_address.address_line", &address_line_list)) { |
| 56 if (!address_line_list->GetString(0, &address_line_1)) | 63 for (size_t i = 0; i < address_line_list->GetSize(); ++i) { |
| 57 DVLOG(1) << "Response from Google Wallet missing address line 1"; | 64 base::string16 line; |
| 58 if (!address_line_list->GetString(1, &address_line_2)) | 65 address_line_list->GetString(i, &line); |
| 59 DVLOG(1) << "Response from Google Wallet missing address line 2"; | 66 street_address.push_back(line); |
| 67 } | |
| 60 } else { | 68 } else { |
| 61 DVLOG(1) << "Response from Google Wallet missing address lines"; | 69 DVLOG(1) << "Response from Google Wallet missing address lines"; |
| 62 } | 70 } |
| 63 | 71 |
| 64 base::string16 locality_name; | 72 base::string16 locality_name; |
| 65 if (!dictionary.GetString("postal_address.locality_name", | 73 if (!dictionary.GetString("postal_address.locality_name", |
| 66 &locality_name)) { | 74 &locality_name)) { |
| 67 DVLOG(1) << "Response from Google Wallet missing locality name"; | 75 DVLOG(1) << "Response from Google Wallet missing locality name"; |
| 68 } | 76 } |
| 69 | 77 |
| 78 base::string16 dependent_locality_name; | |
| 79 if (!dictionary.GetString("postal_address.dependent_locality_name", | |
| 80 &dependent_locality_name)) { | |
| 81 DVLOG(1) << "Response from Google Wallet missing dependent locality name"; | |
| 82 } | |
| 83 | |
| 70 base::string16 administrative_area_name; | 84 base::string16 administrative_area_name; |
| 71 if (!dictionary.GetString("postal_address.administrative_area_name", | 85 if (!dictionary.GetString("postal_address.administrative_area_name", |
| 72 &administrative_area_name)) { | 86 &administrative_area_name)) { |
| 73 DVLOG(1) << "Response from Google Wallet missing administrative area name"; | 87 DVLOG(1) << "Response from Google Wallet missing administrative area name"; |
| 74 } | 88 } |
| 75 | 89 |
| 76 Address* address = new Address(country_name_code, | 90 Address* address = new Address(country_name_code, |
| 77 recipient_name, | 91 recipient_name, |
| 78 address_line_1, | 92 street_address, |
| 79 address_line_2, | |
| 80 locality_name, | 93 locality_name, |
| 94 dependent_locality_name, | |
| 81 administrative_area_name, | 95 administrative_area_name, |
| 82 postal_code_number, | 96 postal_code_number, |
| 97 sorting_code, | |
| 83 phone_number, | 98 phone_number, |
| 84 object_id); | 99 object_id); |
| 85 | 100 |
| 86 bool is_minimal_address = false; | 101 bool is_minimal_address = false; |
| 87 if (dictionary.GetBoolean("is_minimal_address", &is_minimal_address)) | 102 if (dictionary.GetBoolean("is_minimal_address", &is_minimal_address)) |
| 88 address->set_is_complete_address(!is_minimal_address); | 103 address->set_is_complete_address(!is_minimal_address); |
| 89 else | 104 else |
| 90 DVLOG(1) << "Response from Google Wallet missing is_minimal_address bit"; | 105 DVLOG(1) << "Response from Google Wallet missing is_minimal_address bit"; |
| 91 | 106 |
| 92 return address; | 107 return address; |
| 93 } | 108 } |
| 94 | 109 |
| 95 } // namespace | 110 } // namespace |
| 96 | 111 |
| 97 Address::Address() {} | 112 Address::Address() {} |
| 98 | 113 |
| 99 Address::Address(const AutofillProfile& profile) | 114 Address::Address(const AutofillProfile& profile) |
| 100 : country_name_code_( | 115 : country_name_code_( |
| 101 UTF16ToASCII(profile.GetRawInfo(ADDRESS_HOME_COUNTRY))), | 116 UTF16ToASCII(profile.GetRawInfo(ADDRESS_HOME_COUNTRY))), |
| 102 recipient_name_(profile.GetRawInfo(NAME_FULL)), | 117 recipient_name_(profile.GetRawInfo(NAME_FULL)), |
| 103 address_line_1_(profile.GetRawInfo(ADDRESS_HOME_LINE1)), | |
| 104 address_line_2_(profile.GetRawInfo(ADDRESS_HOME_LINE2)), | |
| 105 locality_name_(profile.GetRawInfo(ADDRESS_HOME_CITY)), | 118 locality_name_(profile.GetRawInfo(ADDRESS_HOME_CITY)), |
| 119 dependent_locality_name_( | |
| 120 profile.GetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY)), | |
| 106 administrative_area_name_(profile.GetRawInfo(ADDRESS_HOME_STATE)), | 121 administrative_area_name_(profile.GetRawInfo(ADDRESS_HOME_STATE)), |
| 107 postal_code_number_(profile.GetRawInfo(ADDRESS_HOME_ZIP)), | 122 postal_code_number_(profile.GetRawInfo(ADDRESS_HOME_ZIP)), |
| 123 sorting_code_(profile.GetRawInfo(ADDRESS_HOME_SORTING_CODE)), | |
| 108 phone_number_(profile.GetRawInfo(PHONE_HOME_WHOLE_NUMBER)), | 124 phone_number_(profile.GetRawInfo(PHONE_HOME_WHOLE_NUMBER)), |
| 109 is_complete_address_(true) { | 125 is_complete_address_(true) { |
| 126 base::SplitString( | |
| 127 profile.GetRawInfo(ADDRESS_HOME_STREET_ADDRESS), '\n', &street_address_); | |
| 128 | |
| 110 if (!country_name_code_.empty()) | 129 if (!country_name_code_.empty()) |
| 111 phone_object_ = i18n::PhoneObject(phone_number_, country_name_code_); | 130 phone_object_ = i18n::PhoneObject(phone_number_, country_name_code_); |
| 112 } | 131 } |
| 113 | 132 |
| 114 Address::Address(const std::string& country_name_code, | 133 Address::Address(const std::string& country_name_code, |
| 115 const base::string16& recipient_name, | 134 const base::string16& recipient_name, |
| 116 const base::string16& address_line_1, | 135 const std::vector<base::string16>& street_address, |
| 117 const base::string16& address_line_2, | |
| 118 const base::string16& locality_name, | 136 const base::string16& locality_name, |
| 137 const base::string16& dependent_locality_name, | |
| 119 const base::string16& administrative_area_name, | 138 const base::string16& administrative_area_name, |
| 120 const base::string16& postal_code_number, | 139 const base::string16& postal_code_number, |
| 140 const base::string16& sorting_code, | |
| 121 const base::string16& phone_number, | 141 const base::string16& phone_number, |
| 122 const std::string& object_id) | 142 const std::string& object_id) |
| 123 : country_name_code_(country_name_code), | 143 : country_name_code_(country_name_code), |
| 124 recipient_name_(recipient_name), | 144 recipient_name_(recipient_name), |
| 125 address_line_1_(address_line_1), | 145 street_address_(street_address), |
| 126 address_line_2_(address_line_2), | |
| 127 locality_name_(locality_name), | 146 locality_name_(locality_name), |
| 147 dependent_locality_name_(dependent_locality_name), | |
| 128 administrative_area_name_(administrative_area_name), | 148 administrative_area_name_(administrative_area_name), |
| 129 postal_code_number_(postal_code_number), | 149 postal_code_number_(postal_code_number), |
| 150 sorting_code_(sorting_code), | |
| 130 phone_number_(phone_number), | 151 phone_number_(phone_number), |
| 131 phone_object_(phone_number, country_name_code), | 152 phone_object_(phone_number, country_name_code), |
| 132 object_id_(object_id), | 153 object_id_(object_id), |
| 133 is_complete_address_(true) {} | 154 is_complete_address_(true) {} |
| 134 | 155 |
| 135 Address::~Address() {} | 156 Address::~Address() {} |
| 136 | 157 |
| 137 // static | 158 // static |
| 138 scoped_ptr<Address> Address::CreateAddressWithID( | 159 scoped_ptr<Address> Address::CreateAddressWithID( |
| 139 const base::DictionaryValue& dictionary) { | 160 const base::DictionaryValue& dictionary) { |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 167 DLOG(ERROR) << "Reponse from Google Wallet missing name"; | 188 DLOG(ERROR) << "Reponse from Google Wallet missing name"; |
| 168 return scoped_ptr<Address>(); | 189 return scoped_ptr<Address>(); |
| 169 } | 190 } |
| 170 | 191 |
| 171 base::string16 postal_code; | 192 base::string16 postal_code; |
| 172 if (!dictionary.GetString("postal_code", &postal_code)) { | 193 if (!dictionary.GetString("postal_code", &postal_code)) { |
| 173 DLOG(ERROR) << "Reponse from Google Wallet missing postal code"; | 194 DLOG(ERROR) << "Reponse from Google Wallet missing postal code"; |
| 174 return scoped_ptr<Address>(); | 195 return scoped_ptr<Address>(); |
| 175 } | 196 } |
| 176 | 197 |
| 198 base::string16 sorting_code; | |
| 199 if (!dictionary.GetString("sorting_code", &sorting_code)) { | |
| 200 DVLOG(1) << "Reponse from Google Wallet missing sorting code"; | |
| 201 } | |
| 202 | |
| 203 std::vector<base::string16> street_address; | |
| 177 base::string16 address1; | 204 base::string16 address1; |
| 178 if (!dictionary.GetString("address1", &address1)) | 205 if (dictionary.GetString("address1", &address1)) |
| 206 street_address.push_back(address1); | |
| 207 else | |
| 179 DVLOG(1) << "Reponse from Google Wallet missing address1"; | 208 DVLOG(1) << "Reponse from Google Wallet missing address1"; |
|
Dan Beam
2014/02/12 21:34:33
nit:
if (!dictionary.GetString("address1", &add
Evan Stade
2014/02/12 23:32:13
why? I'd rather have this struct accurately reflec
| |
| 180 | 209 |
| 181 base::string16 address2; | 210 base::string16 address2; |
| 182 if (!dictionary.GetString("address2", &address2)) | 211 if (dictionary.GetString("address2", &address2) && !address2.empty()) { |
| 183 DVLOG(1) << "Reponse from Google Wallet missing address2"; | 212 street_address.resize(2); |
| 213 street_address[1] = address2; | |
| 214 } else { | |
| 215 DVLOG(1) << "Reponse from Google Wallet missing or empty address2"; | |
| 216 } | |
| 184 | 217 |
| 185 base::string16 city; | 218 base::string16 city; |
| 186 if (!dictionary.GetString("city", &city)) | 219 if (!dictionary.GetString("city", &city)) |
| 187 DVLOG(1) << "Reponse from Google Wallet missing city"; | 220 DVLOG(1) << "Reponse from Google Wallet missing city"; |
| 188 | 221 |
| 222 base::string16 dependent_locality_name; | |
| 223 if (!dictionary.GetString("dependent_locality_name", | |
| 224 &dependent_locality_name)) { | |
| 225 DVLOG(1) << "Reponse from Google Wallet missing district"; | |
| 226 } | |
| 227 | |
| 189 base::string16 state; | 228 base::string16 state; |
| 190 if (!dictionary.GetString("state", &state)) | 229 if (!dictionary.GetString("state", &state)) |
| 191 DVLOG(1) << "Reponse from Google Wallet missing state"; | 230 DVLOG(1) << "Reponse from Google Wallet missing state"; |
| 192 | 231 |
| 193 base::string16 phone_number; | 232 base::string16 phone_number; |
| 194 if (!dictionary.GetString("phone_number", &phone_number)) | 233 if (!dictionary.GetString("phone_number", &phone_number)) |
| 195 DVLOG(1) << "Reponse from Google Wallet missing phone number"; | 234 DVLOG(1) << "Reponse from Google Wallet missing phone number"; |
| 196 | 235 |
| 197 std::string address_state; | 236 std::string address_state; |
| 198 if (!dictionary.GetString("type", &address_state)) | 237 if (!dictionary.GetString("type", &address_state)) |
| 199 DVLOG(1) << "Response from Google Wallet missing type/state of address"; | 238 DVLOG(1) << "Response from Google Wallet missing type/state of address"; |
| 200 | 239 |
| 201 scoped_ptr<Address> address( | 240 scoped_ptr<Address> address( |
| 202 new Address(country_code, | 241 new Address(country_code, |
| 203 name, | 242 name, |
| 204 address1, | 243 street_address, |
| 205 address2, | |
| 206 city, | 244 city, |
| 245 dependent_locality_name, | |
| 207 state, | 246 state, |
| 208 postal_code, | 247 postal_code, |
| 248 sorting_code, | |
| 209 phone_number, | 249 phone_number, |
| 210 std::string())); | 250 std::string())); |
| 211 address->set_is_complete_address(address_state == kFullAddress); | 251 address->set_is_complete_address(address_state == kFullAddress); |
| 212 | 252 |
| 213 return address.Pass(); | 253 return address.Pass(); |
| 214 } | 254 } |
| 215 | 255 |
| 216 scoped_ptr<base::DictionaryValue> Address::ToDictionaryWithID() const { | 256 scoped_ptr<base::DictionaryValue> Address::ToDictionaryWithID() const { |
| 217 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 257 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 218 | 258 |
| 219 if (!object_id_.empty()) | 259 if (!object_id_.empty()) |
| 220 dict->SetString("id", object_id_); | 260 dict->SetString("id", object_id_); |
| 221 dict->SetString("phone_number", phone_number_); | 261 dict->SetString("phone_number", phone_number_); |
| 222 dict->Set("postal_address", ToDictionaryWithoutID().release()); | 262 dict->Set("postal_address", ToDictionaryWithoutID().release()); |
| 223 | 263 |
| 224 return dict.Pass(); | 264 return dict.Pass(); |
| 225 } | 265 } |
| 226 | 266 |
| 227 scoped_ptr<base::DictionaryValue> Address::ToDictionaryWithoutID() const { | 267 scoped_ptr<base::DictionaryValue> Address::ToDictionaryWithoutID() const { |
| 228 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 268 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 229 | 269 |
| 230 scoped_ptr<base::ListValue> address_lines(new base::ListValue()); | 270 scoped_ptr<base::ListValue> address_lines(new base::ListValue()); |
| 231 address_lines->AppendString(address_line_1_); | 271 address_lines->AppendStrings(street_address_); |
| 232 if (!address_line_2_.empty()) | |
| 233 address_lines->AppendString(address_line_2_); | |
| 234 dict->Set("address_line", address_lines.release()); | 272 dict->Set("address_line", address_lines.release()); |
| 235 | 273 |
| 236 dict->SetString("country_name_code", country_name_code_); | 274 dict->SetString("country_name_code", country_name_code_); |
| 237 dict->SetString("recipient_name", recipient_name_); | 275 dict->SetString("recipient_name", recipient_name_); |
| 238 dict->SetString("locality_name", locality_name_); | 276 dict->SetString("locality_name", locality_name_); |
| 277 dict->SetString("dependent_locality_name", dependent_locality_name_); | |
| 239 dict->SetString("administrative_area_name", | 278 dict->SetString("administrative_area_name", |
| 240 administrative_area_name_); | 279 administrative_area_name_); |
| 241 dict->SetString("postal_code_number", postal_code_number_); | 280 dict->SetString("postal_code_number", postal_code_number_); |
| 281 dict->SetString("sorting_code", sorting_code_); | |
| 242 | 282 |
| 243 return dict.Pass(); | 283 return dict.Pass(); |
| 244 } | 284 } |
| 245 | 285 |
| 246 base::string16 Address::DisplayName() const { | 286 base::string16 Address::DisplayName() const { |
| 247 #if defined(OS_ANDROID) | 287 #if defined(OS_ANDROID) |
| 248 // TODO(aruslan): improve this stub implementation. | 288 // TODO(aruslan): improve this stub implementation. |
| 249 return recipient_name(); | 289 return recipient_name(); |
| 250 #else | 290 #else |
| 251 // TODO(estade): improve this stub implementation + l10n. | 291 // TODO(estade): improve this stub implementation + l10n. |
| 252 return recipient_name() + base::ASCIIToUTF16(", ") + address_line_1(); | 292 return recipient_name() + base::ASCIIToUTF16(", ") + GetStreetAddressLine(0); |
| 253 #endif | 293 #endif |
| 254 } | 294 } |
| 255 | 295 |
| 256 base::string16 Address::DisplayNameDetail() const { | 296 base::string16 Address::DisplayNameDetail() const { |
| 257 #if defined(OS_ANDROID) | 297 #if defined(OS_ANDROID) |
|
Dan Beam
2014/02/12 21:34:33
^ I wonder if this is even being used still on And
| |
| 258 // TODO(aruslan): improve this stub implementation. | 298 // TODO(aruslan): improve this stub implementation. |
| 259 return address_line_1(); | 299 return GetStreetAddressLine(0); |
| 260 #else | 300 #else |
| 261 return base::string16(); | 301 return base::string16(); |
| 262 #endif | 302 #endif |
| 263 } | 303 } |
| 264 | 304 |
| 265 base::string16 Address::DisplayPhoneNumber() const { | 305 base::string16 Address::DisplayPhoneNumber() const { |
| 266 // Return a formatted phone number. Wallet doesn't store user formatting, so | 306 // Return a formatted phone number. Wallet doesn't store user formatting, so |
| 267 // impose our own. phone_number() always includes a country code, so using | 307 // impose our own. phone_number() always includes a country code, so using |
| 268 // PhoneObject to format it would result in an internationalized format. Since | 308 // PhoneObject to format it would result in an internationalized format. Since |
| 269 // Wallet only supports the US right now, stick to national formatting. | 309 // Wallet only supports the US right now, stick to national formatting. |
| 270 return i18n::PhoneObject(phone_number(), country_name_code()). | 310 return i18n::PhoneObject(phone_number(), country_name_code()). |
| 271 GetNationallyFormattedNumber(); | 311 GetNationallyFormattedNumber(); |
| 272 } | 312 } |
| 273 | 313 |
| 274 base::string16 Address::GetInfo(const AutofillType& type, | 314 base::string16 Address::GetInfo(const AutofillType& type, |
| 275 const std::string& app_locale) const { | 315 const std::string& app_locale) const { |
| 276 if (type.html_type() == HTML_TYPE_COUNTRY_CODE) { | 316 if (type.html_type() == HTML_TYPE_COUNTRY_CODE) { |
| 277 DCHECK(IsStringASCII(country_name_code())); | 317 DCHECK(IsStringASCII(country_name_code())); |
| 278 return base::ASCIIToUTF16(country_name_code()); | 318 return base::ASCIIToUTF16(country_name_code()); |
| 279 } | 319 } |
| 280 | 320 |
| 281 switch (type.GetStorableType()) { | 321 switch (type.GetStorableType()) { |
| 282 case NAME_FULL: | 322 case NAME_FULL: |
| 283 return recipient_name(); | 323 return recipient_name(); |
| 284 | 324 |
| 285 case ADDRESS_HOME_STREET_ADDRESS: { | 325 case ADDRESS_HOME_STREET_ADDRESS: |
| 286 base::string16 address = address_line_1(); | 326 return JoinString(street_address_, base::ASCIIToUTF16("\n")); |
| 287 if (!address_line_2().empty()) | |
| 288 address += base::ASCIIToUTF16("\n") + address_line_2(); | |
| 289 return address; | |
| 290 } | |
| 291 | 327 |
| 292 case ADDRESS_HOME_LINE1: | 328 case ADDRESS_HOME_LINE1: |
| 293 return address_line_1(); | 329 return GetStreetAddressLine(0); |
| 294 | 330 |
| 295 case ADDRESS_HOME_LINE2: | 331 case ADDRESS_HOME_LINE2: |
| 296 return address_line_2(); | 332 return GetStreetAddressLine(1); |
| 297 | 333 |
| 298 case ADDRESS_HOME_CITY: | 334 case ADDRESS_HOME_CITY: |
| 299 return locality_name(); | 335 return locality_name(); |
| 300 | 336 |
| 301 case ADDRESS_HOME_STATE: | 337 case ADDRESS_HOME_STATE: |
| 302 return administrative_area_name(); | 338 return administrative_area_name(); |
| 303 | 339 |
| 304 case ADDRESS_HOME_ZIP: | 340 case ADDRESS_HOME_ZIP: |
| 305 return postal_code_number(); | 341 return postal_code_number(); |
| 306 | 342 |
| 307 case ADDRESS_HOME_COUNTRY: { | 343 case ADDRESS_HOME_COUNTRY: { |
| 308 AutofillCountry country(country_name_code(), app_locale); | 344 AutofillCountry country(country_name_code(), app_locale); |
| 309 return country.name(); | 345 return country.name(); |
| 310 } | 346 } |
| 311 | 347 |
| 312 case PHONE_HOME_WHOLE_NUMBER: | 348 case PHONE_HOME_WHOLE_NUMBER: |
| 313 // Wallet doesn't store user phone number formatting, so just strip all | 349 // Wallet doesn't store user phone number formatting, so just strip all |
| 314 // formatting. | 350 // formatting. |
| 315 return phone_object_.GetWholeNumber(); | 351 return phone_object_.GetWholeNumber(); |
| 316 | 352 |
| 317 case ADDRESS_HOME_DEPENDENT_LOCALITY: | 353 case ADDRESS_HOME_DEPENDENT_LOCALITY: |
| 354 return dependent_locality_name_; | |
| 355 | |
| 318 case ADDRESS_HOME_SORTING_CODE: | 356 case ADDRESS_HOME_SORTING_CODE: |
| 357 return sorting_code_; | |
| 358 | |
| 319 case COMPANY_NAME: | 359 case COMPANY_NAME: |
| 320 // Fields that some countries request but Wallet doesn't support. | 360 // A field that Wallet doesn't support. TODO(dbeam): can it be supported? |
| 321 // TODO(dbeam): can these be supported by Wallet? | |
| 322 return base::string16(); | 361 return base::string16(); |
| 323 | 362 |
| 324 // TODO(estade): implement more. | |
| 325 default: | 363 default: |
| 326 NOTREACHED(); | 364 NOTREACHED(); |
| 327 return base::string16(); | 365 return base::string16(); |
| 328 } | 366 } |
| 329 } | 367 } |
| 330 | 368 |
| 331 void Address::SetPhoneNumber(const base::string16& phone_number) { | 369 void Address::SetPhoneNumber(const base::string16& phone_number) { |
| 332 phone_number_ = phone_number; | 370 phone_number_ = phone_number; |
| 333 phone_object_ = i18n::PhoneObject(phone_number_, country_name_code_); | 371 phone_object_ = i18n::PhoneObject(phone_number_, country_name_code_); |
| 334 } | 372 } |
| 335 | 373 |
| 336 bool Address::EqualsIgnoreID(const Address& other) const { | 374 bool Address::EqualsIgnoreID(const Address& other) const { |
| 337 return country_name_code_ == other.country_name_code_ && | 375 return country_name_code_ == other.country_name_code_ && |
| 338 recipient_name_ == other.recipient_name_ && | 376 recipient_name_ == other.recipient_name_ && |
| 339 address_line_1_ == other.address_line_1_ && | 377 street_address_ == other.street_address_ && |
| 340 address_line_2_ == other.address_line_2_ && | |
| 341 locality_name_ == other.locality_name_ && | 378 locality_name_ == other.locality_name_ && |
| 379 dependent_locality_name_ == other.dependent_locality_name_ && | |
| 342 administrative_area_name_ == other.administrative_area_name_ && | 380 administrative_area_name_ == other.administrative_area_name_ && |
| 343 postal_code_number_ == other.postal_code_number_ && | 381 postal_code_number_ == other.postal_code_number_ && |
| 382 sorting_code_ == other.sorting_code_ && | |
| 344 phone_number_ == other.phone_number_ && | 383 phone_number_ == other.phone_number_ && |
| 345 is_complete_address_ == other.is_complete_address_; | 384 is_complete_address_ == other.is_complete_address_; |
| 346 } | 385 } |
| 347 | 386 |
| 387 base::string16 Address::GetStreetAddressLine(size_t line) const { | |
| 388 return street_address_.size() > line ? street_address_[line] : | |
| 389 base::string16(); | |
| 390 } | |
| 391 | |
| 348 bool Address::operator==(const Address& other) const { | 392 bool Address::operator==(const Address& other) const { |
| 349 return object_id_ == other.object_id_ && EqualsIgnoreID(other); | 393 return object_id_ == other.object_id_ && EqualsIgnoreID(other); |
| 350 } | 394 } |
| 351 | 395 |
| 352 bool Address::operator!=(const Address& other) const { | 396 bool Address::operator!=(const Address& other) const { |
| 353 return !(*this == other); | 397 return !(*this == other); |
| 354 } | 398 } |
| 355 | 399 |
| 356 } // namespace wallet | 400 } // namespace wallet |
| 357 } // namespace autofill | 401 } // namespace autofill |
| OLD | NEW |