Commit ab867f3e authored by Rouslan Solomakhin's avatar Rouslan Solomakhin Committed by Commit Bot

[Payments] Block interactions when spinning.

Bug: 792961
Change-Id: I9643f51f355711af731e2e77021d50598099327c
Reviewed-on: https://chromium-review.googlesource.com/849152Reviewed-by: default avataranthonyvd <anthonyvd@chromium.org>
Commit-Queue: Rouslan Solomakhin <rouslan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#526743}
parent 5270651f
......@@ -286,6 +286,9 @@ std::unique_ptr<views::Button> CvcUnmaskViewController::CreatePrimaryButton() {
void CvcUnmaskViewController::ButtonPressed(views::Button* sender,
const ui::Event& event) {
if (!dialog()->IsInteractive())
return;
switch (sender->tag()) {
case static_cast<int>(Tags::CONFIRM_TAG):
CvcConfirmed();
......@@ -396,6 +399,9 @@ void CvcUnmaskViewController::ContentsChanged(
}
void CvcUnmaskViewController::OnPerformAction(views::Combobox* combobox) {
if (!dialog()->IsInteractive())
return;
UpdatePayButtonState();
}
......
......@@ -166,6 +166,10 @@ void PaymentRequestDialogView::ShowProcessingSpinner() {
observer_for_testing_->OnProcessingSpinnerShown();
}
bool PaymentRequestDialogView::IsInteractive() const {
return !throbber_overlay_.visible();
}
void PaymentRequestDialogView::OnStartUpdating(
PaymentRequestSpec::UpdateReason reason) {
ShowProcessingSpinner();
......
......@@ -109,6 +109,7 @@ class PaymentRequestDialogView : public views::DialogDelegateView,
void CloseDialog() override;
void ShowErrorMessage() override;
void ShowProcessingSpinner() override;
bool IsInteractive() const override;
// PaymentRequestSpec::Observer:
void OnStartUpdating(PaymentRequestSpec::UpdateReason reason) override;
......
......@@ -321,6 +321,9 @@ PaymentRequestSheetController::CreateExtraFooterView() {
void PaymentRequestSheetController::ButtonPressed(views::Button* sender,
const ui::Event& event) {
if (!dialog()->IsInteractive())
return;
switch (static_cast<PaymentRequestCommonTags>(sender->tag())) {
case PaymentRequestCommonTags::CLOSE_BUTTON_TAG:
dialog()->CloseDialog();
......@@ -349,11 +352,11 @@ std::unique_ptr<views::View> PaymentRequestSheetController::CreateFooterView() {
std::make_unique<views::GridLayout>(container.get()));
views::ColumnSet* columns = layout->AddColumnSet(0);
columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER,
0, views::GridLayout::USE_PREF, 0, 0);
columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER, 0,
views::GridLayout::USE_PREF, 0, 0);
columns->AddPaddingColumn(1, 0);
columns->AddColumn(views::GridLayout::TRAILING, views::GridLayout::CENTER,
0, views::GridLayout::USE_PREF, 0, 0);
columns->AddColumn(views::GridLayout::TRAILING, views::GridLayout::CENTER, 0,
views::GridLayout::USE_PREF, 0, 0);
layout->StartRow(0, 0);
std::unique_ptr<views::View> extra_view = CreateExtraFooterView();
......@@ -397,6 +400,10 @@ bool PaymentRequestSheetController::GetSheetId(DialogViewID* sheet_id) {
}
bool PaymentRequestSheetController::PerformPrimaryButtonAction() {
// Return "true" to prevent other views from handling the event.
if (!dialog()->IsInteractive())
return true;
if (primary_button_ && primary_button_->enabled())
ButtonPressed(primary_button_.get(), DummyEvent());
return true;
......
......@@ -474,6 +474,9 @@ PaymentSheetViewController::CreateExtraFooterView() {
void PaymentSheetViewController::ButtonPressed(views::Button* sender,
const ui::Event& event) {
if (!dialog()->IsInteractive())
return;
switch (sender->tag()) {
case static_cast<int>(
PaymentSheetViewControllerTags::SHOW_ORDER_SUMMARY_BUTTON):
......@@ -542,6 +545,9 @@ void PaymentSheetViewController::StyledLabelLinkClicked(
views::StyledLabel* label,
const gfx::Range& range,
int event_flags) {
if (!dialog()->IsInteractive())
return;
// The only thing that can trigger this is the user clicking on the "settings"
// link in the data attribution text.
chrome::ShowSettingsSubPageForProfile(dialog()->GetProfile(),
......
......@@ -25,8 +25,12 @@ class PaymentRequestDialog {
virtual void ShowErrorMessage() = 0;
// Shows a "Processing..." spinner.
virtual void ShowProcessingSpinner() = 0;
// Whether a "Processing..." spinner is showing.
virtual bool IsInteractive() const = 0;
// Shows the CVC unmask sheet and starts a FullCardRequest with the info
// entered by the user.
virtual void ShowCvcUnmaskPrompt(
......
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