| 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 24 matching lines...) Expand all Loading... |
| 47 } | 48 } |
| 48 | 49 |
| 49 gfx::Image DataModelWrapper::GetIcon() { | 50 gfx::Image DataModelWrapper::GetIcon() { |
| 50 return gfx::Image(); | 51 return gfx::Image(); |
| 51 } | 52 } |
| 52 | 53 |
| 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 // Format the address. | 57 // Format the address. |
| 57 ::i18n::addressinput::AddressData address_data; | 58 ::i18n::addressinput::AddressData address_data = i18ninput::CreateAddressData( |
| 58 address_data.recipient = UTF16ToUTF8( | 59 base::Bind(&DataModelWrapper::GetInfo, base::Unretained(this))); |
| 59 GetInfoForDisplay(AutofillType(NAME_FULL))); | |
| 60 address_data.country_code = UTF16ToUTF8( | |
| 61 GetInfoForDisplay(AutofillType(ADDRESS_HOME_COUNTRY))); | |
| 62 address_data.administrative_area = UTF16ToUTF8( | |
| 63 GetInfoForDisplay(AutofillType(ADDRESS_HOME_STATE))); | |
| 64 address_data.locality = UTF16ToUTF8( | |
| 65 GetInfoForDisplay(AutofillType(ADDRESS_HOME_CITY))); | |
| 66 address_data.dependent_locality = UTF16ToUTF8( | |
| 67 GetInfoForDisplay(AutofillType(ADDRESS_HOME_DEPENDENT_LOCALITY))); | |
| 68 address_data.sorting_code = UTF16ToUTF8( | |
| 69 GetInfoForDisplay(AutofillType(ADDRESS_HOME_SORTING_CODE))); | |
| 70 address_data.postal_code = UTF16ToUTF8( | |
| 71 GetInfoForDisplay(AutofillType(ADDRESS_HOME_ZIP))); | |
| 72 | |
| 73 address_data.address_lines.push_back(UTF16ToUTF8( | |
| 74 GetInfoForDisplay(AutofillType(ADDRESS_HOME_LINE1)))); | |
| 75 base::string16 address2 = GetInfoForDisplay(AutofillType(ADDRESS_HOME_LINE2)); | |
| 76 if (!address2.empty()) | |
| 77 address_data.address_lines.push_back(UTF16ToUTF8(address2)); | |
| 78 | |
| 79 std::vector<std::string> lines; | 60 std::vector<std::string> lines; |
| 80 address_data.FormatForDisplay(&lines); | 61 address_data.FormatForDisplay(&lines); |
| 81 | 62 |
| 82 // Email and phone number aren't part of address formatting. | 63 // Email and phone number aren't part of address formatting. |
| 83 base::string16 non_address_info; | 64 base::string16 non_address_info; |
| 84 base::string16 email = GetInfoForDisplay(AutofillType(EMAIL_ADDRESS)); | 65 base::string16 email = GetInfoForDisplay(AutofillType(EMAIL_ADDRESS)); |
| 85 if (!email.empty()) | 66 if (!email.empty()) |
| 86 non_address_info += ASCIIToUTF16("\n") + email; | 67 non_address_info += ASCIIToUTF16("\n") + email; |
| 87 | 68 |
| 88 non_address_info += ASCIIToUTF16("\n") + | 69 non_address_info += ASCIIToUTF16("\n") + |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 } | 330 } |
| 350 | 331 |
| 351 FullWalletShippingWrapper::~FullWalletShippingWrapper() {} | 332 FullWalletShippingWrapper::~FullWalletShippingWrapper() {} |
| 352 | 333 |
| 353 base::string16 FullWalletShippingWrapper::GetInfo( | 334 base::string16 FullWalletShippingWrapper::GetInfo( |
| 354 const AutofillType& type) const { | 335 const AutofillType& type) const { |
| 355 return full_wallet_->shipping_address()->GetInfo( | 336 return full_wallet_->shipping_address()->GetInfo( |
| 356 type, g_browser_process->GetApplicationLocale()); | 337 type, g_browser_process->GetApplicationLocale()); |
| 357 } | 338 } |
| 358 | 339 |
| 359 FieldMapWrapper::FieldMapWrapper(const FieldValueMap& field_map) | |
| 360 : field_map_(field_map) {} | |
| 361 | |
| 362 FieldMapWrapper::~FieldMapWrapper() {} | |
| 363 | |
| 364 base::string16 FieldMapWrapper::GetInfo(const AutofillType& type) const { | |
| 365 FieldValueMap::const_iterator it = field_map_.find(type.server_type()); | |
| 366 return it != field_map_.end() ? it->second : base::string16(); | |
| 367 } | |
| 368 | |
| 369 } // namespace autofill | 340 } // namespace autofill |
| OLD | NEW |