Commit 4b6206a1 authored by Clemens Arbesser's avatar Clemens Arbesser Committed by Commit Bot

[Autofill Assistant] Make the billing profile of the credit card available for autofill actions.

To this end, the billing profile of the credit card is retrieved and stored in client memory.

Bug: 806868
Change-Id: Ic29020f70f4c00f06ee4014ca7322ff2c8039c92
Reviewed-on: https://chromium-review.googlesource.com/c/1344143
Commit-Queue: Clemens Arbesser <arbesser@google.com>
Reviewed-by: default avatarStephane Zermatten <szermatt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#610021}
parent d5158770
...@@ -226,11 +226,21 @@ void UiControllerAndroid::OnGetPaymentInformation( ...@@ -226,11 +226,21 @@ void UiControllerAndroid::OnGetPaymentInformation(
payment_info->card = std::make_unique<autofill::CreditCard>(); payment_info->card = std::make_unique<autofill::CreditCard>();
autofill::PersonalDataManagerAndroid::PopulateNativeCreditCardFromJava( autofill::PersonalDataManagerAndroid::PopulateNativeCreditCardFromJava(
jcard, env, payment_info->card.get()); jcard, env, payment_info->card.get());
auto guid = payment_info->card->billing_address_id();
if (!guid.empty()) {
autofill::AutofillProfile* profile =
GetPersonalDataManager()->GetProfileByGUID(guid);
if (profile != nullptr)
payment_info->billing_address =
std::make_unique<autofill::AutofillProfile>(*profile);
}
} }
if (jaddress != nullptr) { if (jaddress != nullptr) {
payment_info->address = std::make_unique<autofill::AutofillProfile>(); payment_info->shipping_address =
std::make_unique<autofill::AutofillProfile>();
autofill::PersonalDataManagerAndroid::PopulateNativeProfileFromJava( autofill::PersonalDataManagerAndroid::PopulateNativeProfileFromJava(
jaddress, env, payment_info->address.get()); jaddress, env, payment_info->shipping_address.get());
} }
if (jpayer_name != nullptr) { if (jpayer_name != nullptr) {
base::android::ConvertJavaStringToUTF8(env, jpayer_name, base::android::ConvertJavaStringToUTF8(env, jpayer_name,
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "components/autofill/core/browser/autofill_data_util.h" #include "components/autofill/core/browser/autofill_data_util.h"
#include "components/autofill/core/browser/autofill_profile.h" #include "components/autofill/core/browser/autofill_profile.h"
#include "components/autofill/core/browser/credit_card.h" #include "components/autofill/core/browser/credit_card.h"
#include "components/autofill/core/browser/personal_data_manager.h"
#include "components/autofill_assistant/browser/actions/action_delegate.h" #include "components/autofill_assistant/browser/actions/action_delegate.h"
#include "components/autofill_assistant/browser/client_memory.h" #include "components/autofill_assistant/browser/client_memory.h"
#include "third_party/blink/public/mojom/payments/payment_request.mojom.h" #include "third_party/blink/public/mojom/payments/payment_request.mojom.h"
...@@ -82,10 +83,17 @@ void GetPaymentInformationAction::OnGetPaymentInformation( ...@@ -82,10 +83,17 @@ void GetPaymentInformationAction::OnGetPaymentInformation(
} }
if (!get_payment_information.shipping_address_name().empty()) { if (!get_payment_information.shipping_address_name().empty()) {
DCHECK(payment_information->address); DCHECK(payment_information->shipping_address);
delegate->GetClientMemory()->set_selected_address( delegate->GetClientMemory()->set_selected_address(
get_payment_information.shipping_address_name(), get_payment_information.shipping_address_name(),
std::move(payment_information->address)); std::move(payment_information->shipping_address));
}
if (!get_payment_information.billing_address_name().empty()) {
DCHECK(payment_information->billing_address);
delegate->GetClientMemory()->set_selected_address(
get_payment_information.billing_address_name(),
std::move(payment_information->billing_address));
} }
if (get_payment_information.has_contact_details()) { if (get_payment_information.has_contact_details()) {
......
...@@ -21,7 +21,8 @@ struct PaymentInformation { ...@@ -21,7 +21,8 @@ struct PaymentInformation {
bool succeed; bool succeed;
std::unique_ptr<autofill::CreditCard> card; std::unique_ptr<autofill::CreditCard> card;
std::unique_ptr<autofill::AutofillProfile> address; std::unique_ptr<autofill::AutofillProfile> shipping_address;
std::unique_ptr<autofill::AutofillProfile> billing_address;
std::string payer_name; std::string payer_name;
std::string payer_phone; std::string payer_phone;
std::string payer_email; std::string payer_email;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment