Chromium Code Reviews| Index: components/payments/content/payment_response_helper.cc |
| diff --git a/components/payments/content/payment_response_helper.cc b/components/payments/content/payment_response_helper.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b62bc69f6212dfffdf3740f11d00ebc7572b53e7 |
| --- /dev/null |
| +++ b/components/payments/content/payment_response_helper.cc |
| @@ -0,0 +1,51 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "components/payments/content/payment_response_helper.h" |
| + |
| +#include "base/strings/string_split.h" |
| +#include "base/strings/utf_string_conversions.h" |
| +#include "components/autofill/core/browser/autofill_type.h" |
| + |
| +namespace payments { |
| + |
| +PaymentResponseHelper::PaymentResponseHelper(){}; |
| +PaymentResponseHelper::~PaymentResponseHelper(){}; |
| + |
| +// static |
| +mojom::PaymentAddressPtr |
| +PaymentResponseHelper::GetMojomPaymentAddressFromAutofillProfile( |
| + const autofill::AutofillProfile* const profile, |
| + const std::string& app_locale) { |
| + mojom::PaymentAddressPtr payment_address = mojom::PaymentAddress::New(); |
| + |
| + payment_address->country = |
| + base::UTF16ToUTF8(profile->GetRawInfo(autofill::ADDRESS_HOME_COUNTRY)); |
| + payment_address->address_line = base::SplitString( |
| + base::UTF16ToUTF8(profile->GetInfo( |
| + autofill::AutofillType(autofill::ADDRESS_HOME_STREET_ADDRESS), |
| + app_locale)), |
| + "\n", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| + payment_address->region = |
| + base::UTF16ToUTF8(profile->GetRawInfo(autofill::ADDRESS_HOME_STATE)); |
| + payment_address->city = |
| + base::UTF16ToUTF8(profile->GetRawInfo(autofill::ADDRESS_HOME_CITY)); |
| + payment_address->dependent_locality = base::UTF16ToUTF8( |
| + profile->GetRawInfo(autofill::ADDRESS_HOME_DEPENDENT_LOCALITY)); |
| + payment_address->postal_code = |
| + base::UTF16ToUTF8(profile->GetRawInfo(autofill::ADDRESS_HOME_ZIP)); |
| + payment_address->sorting_code = base::UTF16ToUTF8( |
| + profile->GetRawInfo(autofill::ADDRESS_HOME_SORTING_CODE)); |
| + payment_address->language_code = profile->language_code(); |
| + payment_address->organization = |
| + base::UTF16ToUTF8(profile->GetRawInfo(autofill::COMPANY_NAME)); |
| + payment_address->recipient = base::UTF16ToUTF8(profile->GetInfo( |
| + autofill::AutofillType(autofill::NAME_FULL), app_locale)); |
| + payment_address->phone = |
|
Mathieu
2017/03/27 23:42:42
TODO(crbug.com/xxxxxx): Format phone number accord
sebsg
2017/03/28 20:33:53
Done.
|
| + base::UTF16ToUTF8(profile->GetRawInfo(autofill::PHONE_HOME_WHOLE_NUMBER)); |
| + |
| + return payment_address; |
| +} |
| + |
| +} // namespace payments |