| 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_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 | 246 |
| 247 return dict.Pass(); | 247 return dict.Pass(); |
| 248 } | 248 } |
| 249 | 249 |
| 250 base::string16 Address::DisplayName() const { | 250 base::string16 Address::DisplayName() const { |
| 251 #if defined(OS_ANDROID) | 251 #if defined(OS_ANDROID) |
| 252 // TODO(aruslan): improve this stub implementation. | 252 // TODO(aruslan): improve this stub implementation. |
| 253 return recipient_name(); | 253 return recipient_name(); |
| 254 #else | 254 #else |
| 255 // TODO(estade): improve this stub implementation + l10n. | 255 // TODO(estade): improve this stub implementation + l10n. |
| 256 return recipient_name() + ASCIIToUTF16(", ") + address_line_1(); | 256 return recipient_name() + base::ASCIIToUTF16(", ") + address_line_1(); |
| 257 #endif | 257 #endif |
| 258 } | 258 } |
| 259 | 259 |
| 260 base::string16 Address::DisplayNameDetail() const { | 260 base::string16 Address::DisplayNameDetail() const { |
| 261 #if defined(OS_ANDROID) | 261 #if defined(OS_ANDROID) |
| 262 // TODO(aruslan): improve this stub implementation. | 262 // TODO(aruslan): improve this stub implementation. |
| 263 return address_line_1(); | 263 return address_line_1(); |
| 264 #else | 264 #else |
| 265 return base::string16(); | 265 return base::string16(); |
| 266 #endif | 266 #endif |
| 267 } | 267 } |
| 268 | 268 |
| 269 base::string16 Address::DisplayPhoneNumber() const { | 269 base::string16 Address::DisplayPhoneNumber() const { |
| 270 // Return a formatted phone number. Wallet doesn't store user formatting, so | 270 // Return a formatted phone number. Wallet doesn't store user formatting, so |
| 271 // impose our own. phone_number() always includes a country code, so using | 271 // impose our own. phone_number() always includes a country code, so using |
| 272 // PhoneObject to format it would result in an internationalized format. Since | 272 // PhoneObject to format it would result in an internationalized format. Since |
| 273 // Wallet only supports the US right now, stick to national formatting. | 273 // Wallet only supports the US right now, stick to national formatting. |
| 274 return i18n::PhoneObject(phone_number(), country_name_code()). | 274 return i18n::PhoneObject(phone_number(), country_name_code()). |
| 275 GetNationallyFormattedNumber(); | 275 GetNationallyFormattedNumber(); |
| 276 } | 276 } |
| 277 | 277 |
| 278 base::string16 Address::GetInfo(const AutofillType& type, | 278 base::string16 Address::GetInfo(const AutofillType& type, |
| 279 const std::string& app_locale) const { | 279 const std::string& app_locale) const { |
| 280 if (type.html_type() == HTML_TYPE_COUNTRY_CODE) { | 280 if (type.html_type() == HTML_TYPE_COUNTRY_CODE) { |
| 281 DCHECK(IsStringASCII(country_name_code())); | 281 DCHECK(IsStringASCII(country_name_code())); |
| 282 return ASCIIToUTF16(country_name_code()); | 282 return base::ASCIIToUTF16(country_name_code()); |
| 283 } else if (type.html_type() == HTML_TYPE_STREET_ADDRESS) { | 283 } else if (type.html_type() == HTML_TYPE_STREET_ADDRESS) { |
| 284 base::string16 address = address_line_1(); | 284 base::string16 address = address_line_1(); |
| 285 if (!address_line_2().empty()) | 285 if (!address_line_2().empty()) |
| 286 address += ASCIIToUTF16(", ") + address_line_2(); | 286 address += base::ASCIIToUTF16(", ") + address_line_2(); |
| 287 return address; | 287 return address; |
| 288 } | 288 } |
| 289 | 289 |
| 290 switch (type.GetStorableType()) { | 290 switch (type.GetStorableType()) { |
| 291 case NAME_FULL: | 291 case NAME_FULL: |
| 292 return recipient_name(); | 292 return recipient_name(); |
| 293 | 293 |
| 294 case ADDRESS_HOME_LINE1: | 294 case ADDRESS_HOME_LINE1: |
| 295 return address_line_1(); | 295 return address_line_1(); |
| 296 | 296 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 bool Address::operator==(const Address& other) const { | 350 bool Address::operator==(const Address& other) const { |
| 351 return object_id_ == other.object_id_ && EqualsIgnoreID(other); | 351 return object_id_ == other.object_id_ && EqualsIgnoreID(other); |
| 352 } | 352 } |
| 353 | 353 |
| 354 bool Address::operator!=(const Address& other) const { | 354 bool Address::operator!=(const Address& other) const { |
| 355 return !(*this == other); | 355 return !(*this == other); |
| 356 } | 356 } |
| 357 | 357 |
| 358 } // namespace wallet | 358 } // namespace wallet |
| 359 } // namespace autofill | 359 } // namespace autofill |
| OLD | NEW |