OLD | NEW |
---|---|
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/payments/content/payment_response_helper.h" | 5 #include "components/payments/content/payment_response_helper.h" |
6 | 6 |
7 #include <string> | |
8 | |
7 #include "base/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
8 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
9 #include "components/autofill/core/browser/autofill_country.h" | 11 #include "components/autofill/core/browser/autofill_country.h" |
10 #include "components/autofill/core/browser/autofill_data_util.h" | 12 #include "components/autofill/core/browser/autofill_data_util.h" |
11 #include "components/autofill/core/browser/autofill_type.h" | 13 #include "components/autofill/core/browser/autofill_type.h" |
12 #include "components/payments/content/payment_request_spec.h" | 14 #include "components/payments/content/payment_request_spec.h" |
13 #include "components/payments/core/payment_request_data_util.h" | 15 #include "components/payments/core/payment_request_data_util.h" |
14 #include "components/payments/core/payment_request_delegate.h" | 16 #include "components/payments/core/payment_request_delegate.h" |
15 | 17 |
16 namespace payments { | 18 namespace payments { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
54 } | 56 } |
55 | 57 |
56 payment_request_delegate_->GetAddressNormalizer() | 58 payment_request_delegate_->GetAddressNormalizer() |
57 ->StartAddressNormalization(*selected_shipping_profile, country_code, | 59 ->StartAddressNormalization(*selected_shipping_profile, country_code, |
58 /*timeout_seconds=*/5, this); | 60 /*timeout_seconds=*/5, this); |
59 } | 61 } |
60 | 62 |
61 // Start to get the instrument details. Will call back into | 63 // Start to get the instrument details. Will call back into |
62 // OnInstrumentDetailsReady. | 64 // OnInstrumentDetailsReady. |
63 selected_instrument_->InvokePaymentApp(this); | 65 selected_instrument_->InvokePaymentApp(this); |
64 }; | 66 } |
65 | 67 |
66 PaymentResponseHelper::~PaymentResponseHelper(){}; | 68 PaymentResponseHelper::~PaymentResponseHelper() {} |
67 | 69 |
68 // static | 70 // static |
69 mojom::PaymentAddressPtr | 71 mojom::PaymentAddressPtr |
70 PaymentResponseHelper::GetMojomPaymentAddressFromAutofillProfile( | 72 PaymentResponseHelper::GetMojomPaymentAddressFromAutofillProfile( |
71 const autofill::AutofillProfile& profile, | 73 const autofill::AutofillProfile& profile, |
72 const std::string& app_locale) { | 74 const std::string& app_locale) { |
73 mojom::PaymentAddressPtr payment_address = mojom::PaymentAddress::New(); | 75 mojom::PaymentAddressPtr payment_address = mojom::PaymentAddress::New(); |
74 | 76 |
75 payment_address->country = | 77 payment_address->country = |
76 base::UTF16ToUTF8(profile.GetRawInfo(autofill::ADDRESS_HOME_COUNTRY)); | 78 base::UTF16ToUTF8(profile.GetRawInfo(autofill::ADDRESS_HOME_COUNTRY)); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
178 autofill::AutofillType(autofill::PHONE_HOME_WHOLE_NUMBER), | 180 autofill::AutofillType(autofill::PHONE_HOME_WHOLE_NUMBER), |
179 app_locale_)); | 181 app_locale_)); |
180 | 182 |
181 const std::string default_region_code = | 183 const std::string default_region_code = |
182 autofill::AutofillCountry::CountryCodeForLocale(app_locale_); | 184 autofill::AutofillCountry::CountryCodeForLocale(app_locale_); |
183 payment_response->payer_phone = | 185 payment_response->payer_phone = |
184 data_util::FormatPhoneForResponse(original_number, default_region_code); | 186 data_util::FormatPhoneForResponse(original_number, default_region_code); |
185 } | 187 } |
186 | 188 |
187 delegate_->OnPaymentResponseReady(std::move(payment_response)); | 189 delegate_->OnPaymentResponseReady(std::move(payment_response)); |
190 payment_request_delegate_->MarkFirstTransactionAsCompleted(); | |
Mathieu
2017/05/11 00:28:04
probably fine to write to the pref directly in Pay
anthonyvd
2017/05/11 00:56:46
Unfortunately, the PrefService hangs off Profile,
Mathieu
2017/05/11 01:08:37
PaymentRequest::OnPaymentResponseAvailable could s
Mathieu
2017/05/11 01:20:25
Actually another review reminds me, should probabl
anthonyvd
2017/05/11 13:24:42
Done.
| |
188 } | 191 } |
189 | 192 |
190 } // namespace payments | 193 } // namespace payments |
OLD | NEW |