Commit 5cab902a authored by Rouslan Solomakhin's avatar Rouslan Solomakhin Committed by Commit Bot

[Web Payment][Desktop] Shipping address selection flow

Before this patch, when merchant requested a shipping address before
providing any shipping options, Chrome would show the payment overview
sheet with deselected shipping address. The user would need to first
click [Select] in the shipping address section, then select the shipping
address.

This patch shows the shipping address selection when the user needs to
select a shipping address.

After this patch, Chromes shows the shipping address selection screen
when the merchant requests a shipping address before providing any
shipping options.

Disabled by default behind "StrictHasEnrolledAutofillInstrument"
feature. Can be tested with:
chrome://flags/#enable-web-payments-experimental-features

Bug: 1001644
Change-Id: I1eef3021f474f8de244412204afd7b5b63e84821
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1787702
Commit-Queue: Rouslan Solomakhin <rouslan@chromium.org>
Reviewed-by: default avatarDanyao Wang <danyao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#695588}
parent 0c0e1bbd
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
#include "components/autofill/core/browser/data_model/credit_card.h" #include "components/autofill/core/browser/data_model/credit_card.h"
#include "components/constrained_window/constrained_window_views.h" #include "components/constrained_window/constrained_window_views.h"
#include "components/payments/content/payment_request.h" #include "components/payments/content/payment_request.h"
#include "components/payments/core/features.h"
#include "components/payments/core/payments_experimental_features.h"
#include "components/strings/grit/components_strings.h" #include "components/strings/grit/components_strings.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
...@@ -246,10 +248,8 @@ void PaymentRequestDialogView::OnInitialized( ...@@ -246,10 +248,8 @@ void PaymentRequestDialogView::OnInitialized(
HideProcessingSpinner(); HideProcessingSpinner();
if (request_->state()->are_requested_methods_supported() && if (request_->state()->are_requested_methods_supported())
observer_for_testing_) { OnDialogOpened();
observer_for_testing_->OnDialogOpened();
}
} }
void PaymentRequestDialogView::Pay() { void PaymentRequestDialogView::Pay() {
...@@ -417,6 +417,23 @@ Profile* PaymentRequestDialogView::GetProfile() { ...@@ -417,6 +417,23 @@ Profile* PaymentRequestDialogView::GetProfile() {
request_->web_contents()->GetBrowserContext()); request_->web_contents()->GetBrowserContext());
} }
void PaymentRequestDialogView::OnDialogOpened() {
if (request_->spec()->request_shipping() &&
!request_->state()->selected_shipping_profile() &&
PaymentsExperimentalFeatures::IsEnabled(
features::kStrictHasEnrolledAutofillInstrument)) {
view_stack_->Push(
CreateViewAndInstallController(
ProfileListViewController::GetShippingProfileViewController(
request_->spec(), request_->state(), this),
&controller_map_),
/* animate = */ false);
}
if (observer_for_testing_)
observer_for_testing_->OnDialogOpened();
}
void PaymentRequestDialogView::ShowInitialPaymentSheet() { void PaymentRequestDialogView::ShowInitialPaymentSheet() {
view_stack_->Push(CreateViewAndInstallController( view_stack_->Push(CreateViewAndInstallController(
std::make_unique<PaymentSheetViewController>( std::make_unique<PaymentSheetViewController>(
...@@ -427,10 +444,8 @@ void PaymentRequestDialogView::ShowInitialPaymentSheet() { ...@@ -427,10 +444,8 @@ void PaymentRequestDialogView::ShowInitialPaymentSheet() {
if (number_of_initialization_tasks_ > 0) if (number_of_initialization_tasks_ > 0)
return; return;
if (request_->state()->are_requested_methods_supported() && if (request_->state()->are_requested_methods_supported())
observer_for_testing_) { OnDialogOpened();
observer_for_testing_->OnDialogOpened();
}
} }
void PaymentRequestDialogView::SetupSpinnerOverlay() { void PaymentRequestDialogView::SetupSpinnerOverlay() {
......
...@@ -183,6 +183,7 @@ class PaymentRequestDialogView : public views::DialogDelegateView, ...@@ -183,6 +183,7 @@ class PaymentRequestDialogView : public views::DialogDelegateView,
views::View* throbber_overlay_for_testing() { return throbber_overlay_; } views::View* throbber_overlay_for_testing() { return throbber_overlay_; }
private: private:
void OnDialogOpened();
void ShowInitialPaymentSheet(); void ShowInitialPaymentSheet();
void SetupSpinnerOverlay(); void SetupSpinnerOverlay();
......
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