| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/ui/autofill/data_model_wrapper.h" | 5 #include "chrome/browser/ui/autofill/data_model_wrapper.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/browser/ui/autofill/autofill_dialog_common.h" | 12 #include "chrome/browser/ui/autofill/autofill_dialog_common.h" |
| 13 #include "chrome/browser/ui/autofill/autofill_dialog_i18n_input.h" |
| 13 #include "chrome/browser/ui/autofill/autofill_dialog_models.h" | 14 #include "chrome/browser/ui/autofill/autofill_dialog_models.h" |
| 14 #include "components/autofill/content/browser/wallet/full_wallet.h" | 15 #include "components/autofill/content/browser/wallet/full_wallet.h" |
| 15 #include "components/autofill/content/browser/wallet/wallet_address.h" | 16 #include "components/autofill/content/browser/wallet/wallet_address.h" |
| 16 #include "components/autofill/content/browser/wallet/wallet_items.h" | 17 #include "components/autofill/content/browser/wallet/wallet_items.h" |
| 17 #include "components/autofill/core/browser/autofill_data_model.h" | 18 #include "components/autofill/core/browser/autofill_data_model.h" |
| 18 #include "components/autofill/core/browser/autofill_field.h" | 19 #include "components/autofill/core/browser/autofill_field.h" |
| 19 #include "components/autofill/core/browser/autofill_profile.h" | 20 #include "components/autofill/core/browser/autofill_profile.h" |
| 20 #include "components/autofill/core/browser/autofill_type.h" | 21 #include "components/autofill/core/browser/autofill_type.h" |
| 21 #include "components/autofill/core/browser/credit_card.h" | 22 #include "components/autofill/core/browser/credit_card.h" |
| 22 #include "components/autofill/core/browser/form_structure.h" | 23 #include "components/autofill/core/browser/form_structure.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 53 bool DataModelWrapper::GetDisplayText( | 54 bool DataModelWrapper::GetDisplayText( |
| 54 base::string16* vertically_compact, | 55 base::string16* vertically_compact, |
| 55 base::string16* horizontally_compact) { | 56 base::string16* horizontally_compact) { |
| 56 base::string16 phone = | 57 base::string16 phone = |
| 57 GetInfoForDisplay(AutofillType(PHONE_HOME_WHOLE_NUMBER)); | 58 GetInfoForDisplay(AutofillType(PHONE_HOME_WHOLE_NUMBER)); |
| 58 if (phone.empty()) | 59 if (phone.empty()) |
| 59 return false; | 60 return false; |
| 60 | 61 |
| 61 // Format the address. | 62 // Format the address. |
| 62 ::i18n::addressinput::AddressData address_data; | 63 ::i18n::addressinput::AddressData address_data; |
| 63 address_data.recipient = UTF16ToUTF8( | 64 i18ninput::CreateAddressData( |
| 64 GetInfoForDisplay(AutofillType(NAME_FULL))); | 65 base::Bind(&DataModelWrapper::GetInfo, base::Unretained(this)), |
| 65 address_data.country_code = UTF16ToASCII( | 66 &address_data); |
| 66 GetInfoForDisplay(AutofillType(HTML_TYPE_COUNTRY_CODE, | |
| 67 HTML_MODE_SHIPPING))); | |
| 68 address_data.administrative_area = UTF16ToUTF8( | |
| 69 GetInfoForDisplay(AutofillType(ADDRESS_HOME_STATE))); | |
| 70 address_data.locality = UTF16ToUTF8( | |
| 71 GetInfoForDisplay(AutofillType(ADDRESS_HOME_CITY))); | |
| 72 address_data.dependent_locality = UTF16ToUTF8( | |
| 73 GetInfoForDisplay(AutofillType(ADDRESS_HOME_DEPENDENT_LOCALITY))); | |
| 74 address_data.sorting_code = UTF16ToUTF8( | |
| 75 GetInfoForDisplay(AutofillType(ADDRESS_HOME_SORTING_CODE))); | |
| 76 address_data.postal_code = UTF16ToUTF8( | |
| 77 GetInfoForDisplay(AutofillType(ADDRESS_HOME_ZIP))); | |
| 78 | |
| 79 address_data.address_lines.push_back(UTF16ToUTF8( | |
| 80 GetInfoForDisplay(AutofillType(ADDRESS_HOME_LINE1)))); | |
| 81 base::string16 address2 = GetInfoForDisplay(AutofillType(ADDRESS_HOME_LINE2)); | |
| 82 if (!address2.empty()) | |
| 83 address_data.address_lines.push_back(UTF16ToUTF8(address2)); | |
| 84 | |
| 85 std::vector<std::string> lines; | 67 std::vector<std::string> lines; |
| 86 address_data.FormatForDisplay(&lines); | 68 address_data.FormatForDisplay(&lines); |
| 87 | 69 |
| 88 // Email and phone number aren't part of address formatting. | 70 // Email and phone number aren't part of address formatting. |
| 89 base::string16 non_address_info; | 71 base::string16 non_address_info; |
| 90 base::string16 email = GetInfoForDisplay(AutofillType(EMAIL_ADDRESS)); | 72 base::string16 email = GetInfoForDisplay(AutofillType(EMAIL_ADDRESS)); |
| 91 if (!email.empty()) | 73 if (!email.empty()) |
| 92 non_address_info += ASCIIToUTF16("\n") + email; | 74 non_address_info += ASCIIToUTF16("\n") + email; |
| 93 | 75 |
| 94 non_address_info += ASCIIToUTF16("\n") + phone; | 76 non_address_info += ASCIIToUTF16("\n") + phone; |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 } | 337 } |
| 356 | 338 |
| 357 FullWalletShippingWrapper::~FullWalletShippingWrapper() {} | 339 FullWalletShippingWrapper::~FullWalletShippingWrapper() {} |
| 358 | 340 |
| 359 base::string16 FullWalletShippingWrapper::GetInfo( | 341 base::string16 FullWalletShippingWrapper::GetInfo( |
| 360 const AutofillType& type) const { | 342 const AutofillType& type) const { |
| 361 return full_wallet_->shipping_address()->GetInfo( | 343 return full_wallet_->shipping_address()->GetInfo( |
| 362 type, g_browser_process->GetApplicationLocale()); | 344 type, g_browser_process->GetApplicationLocale()); |
| 363 } | 345 } |
| 364 | 346 |
| 365 FieldMapWrapper::FieldMapWrapper(const FieldValueMap& field_map) | |
| 366 : field_map_(field_map) {} | |
| 367 | |
| 368 FieldMapWrapper::~FieldMapWrapper() {} | |
| 369 | |
| 370 base::string16 FieldMapWrapper::GetInfo(const AutofillType& type) const { | |
| 371 FieldValueMap::const_iterator it = field_map_.find(type.server_type()); | |
| 372 return it != field_map_.end() ? it->second : base::string16(); | |
| 373 } | |
| 374 | |
| 375 } // namespace autofill | 347 } // namespace autofill |
| OLD | NEW |