Commit bfc447d5 authored by Elly Fong-Jones's avatar Elly Fong-Jones Committed by Commit Bot

cbuiv payments: make LocalCardMigrationDialogView not override Views

This change removes all overrides of BubbleDialogDelegateView from
LocalCardMigrationDialogView. A subsequent change will remove the
inheritance relationship between these classes altogether, but that
should be done separately to keep the lifetime changes clear.

Bug: 1075649
Change-Id: Iebf843b682c2a9f3bc445ca11174efbc7ef3d9ad
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2545487
Commit-Queue: Elly Fong-Jones <ellyjones@chromium.org>
Reviewed-by: default avatarVasilii Sukhanov <vasilii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#829009}
parent d245896b
...@@ -356,10 +356,16 @@ LocalCardMigrationDialogView::LocalCardMigrationDialogView( ...@@ -356,10 +356,16 @@ LocalCardMigrationDialogView::LocalCardMigrationDialogView(
base::Unretained(this))); base::Unretained(this)));
SetAcceptCallback(base::BindOnce( SetAcceptCallback(base::BindOnce(
&LocalCardMigrationDialogView::OnDialogAccepted, base::Unretained(this))); &LocalCardMigrationDialogView::OnDialogAccepted, base::Unretained(this)));
RegisterWindowClosingCallback(base::BindOnce(
&LocalCardMigrationDialogView::OnWindowClosing, base::Unretained(this)));
// This should be a modal dialog blocking the browser since we don't want
// users to lose progress in the migration workflow until they are done.
SetModalType(ui::MODAL_TYPE_WINDOW);
set_close_on_deactivate(false); set_close_on_deactivate(false);
set_margins(gfx::Insets()); set_margins(gfx::Insets());
set_fixed_width(ChromeLayoutProvider::Get()->GetDistanceMetric( set_fixed_width(ChromeLayoutProvider::Get()->GetDistanceMetric(
DISTANCE_LARGE_MODAL_DIALOG_PREFERRED_WIDTH)); DISTANCE_LARGE_MODAL_DIALOG_PREFERRED_WIDTH));
SetShowCloseButton(false);
} }
LocalCardMigrationDialogView::~LocalCardMigrationDialogView() {} LocalCardMigrationDialogView::~LocalCardMigrationDialogView() {}
...@@ -376,29 +382,6 @@ void LocalCardMigrationDialogView::CloseDialog() { ...@@ -376,29 +382,6 @@ void LocalCardMigrationDialogView::CloseDialog() {
GetWidget()->Close(); GetWidget()->Close();
} }
ui::ModalType LocalCardMigrationDialogView::GetModalType() const {
// This should be a modal dialog blocking the browser since we don't want
// users to lose progress in the migration workflow until they are done.
return ui::MODAL_TYPE_WINDOW;
}
bool LocalCardMigrationDialogView::ShouldShowCloseButton() const {
return false;
}
// TODO(crbug.com/867194): Update this method when adding feedback.
bool LocalCardMigrationDialogView::IsDialogButtonEnabled(
ui::DialogButton button) const {
// If the dialog is offer dialog and all checkboxes are unchecked, disable the
// save button.
if (controller_->GetViewState() == LocalCardMigrationDialogState::kOffered &&
button == ui::DIALOG_BUTTON_OK) {
DCHECK(offer_view_);
return !offer_view_->GetSelectedCardGuids().empty();
}
return true;
}
void LocalCardMigrationDialogView::OnDialogAccepted() { void LocalCardMigrationDialogView::OnDialogAccepted() {
switch (controller_->GetViewState()) { switch (controller_->GetViewState()) {
case LocalCardMigrationDialogState::kOffered: case LocalCardMigrationDialogState::kOffered:
...@@ -424,19 +407,31 @@ void LocalCardMigrationDialogView::OnDialogCancelled() { ...@@ -424,19 +407,31 @@ void LocalCardMigrationDialogView::OnDialogCancelled() {
} }
} }
void LocalCardMigrationDialogView::WindowClosing() { void LocalCardMigrationDialogView::OnWindowClosing() {
if (controller_) { if (controller_) {
controller_->OnDialogClosed(); controller_->OnDialogClosed();
controller_ = nullptr; controller_ = nullptr;
} }
} }
bool LocalCardMigrationDialogView::ShouldOkButtonBeEnabled() const {
if (controller_->GetViewState() == LocalCardMigrationDialogState::kOffered) {
DCHECK(offer_view_) << "This method can't be called before ConstructView";
return !offer_view_->GetSelectedCardGuids().empty();
}
return true;
}
void LocalCardMigrationDialogView::DeleteCard(const std::string& guid) { void LocalCardMigrationDialogView::DeleteCard(const std::string& guid) {
controller_->DeleteCard(guid); controller_->DeleteCard(guid);
ConstructView(); ConstructView();
UpdateLayout(); UpdateLayout();
} }
void LocalCardMigrationDialogView::OnCardCheckboxToggled() {
SetButtonEnabled(ui::DIALOG_BUTTON_OK, ShouldOkButtonBeEnabled());
}
// TODO(crbug.com/913571): Figure out a way to avoid two consecutive layouts. // TODO(crbug.com/913571): Figure out a way to avoid two consecutive layouts.
void LocalCardMigrationDialogView::UpdateLayout() { void LocalCardMigrationDialogView::UpdateLayout() {
Layout(); Layout();
...@@ -481,6 +476,7 @@ void LocalCardMigrationDialogView::ConstructView() { ...@@ -481,6 +476,7 @@ void LocalCardMigrationDialogView::ConstructView() {
offer_view_->SetID(DialogViewId::MAIN_CONTENT_VIEW_MIGRATION_OFFER_DIALOG); offer_view_->SetID(DialogViewId::MAIN_CONTENT_VIEW_MIGRATION_OFFER_DIALOG);
card_list_view_ = offer_view_->card_list_view_; card_list_view_ = offer_view_->card_list_view_;
AddChildView(offer_view_); AddChildView(offer_view_);
SetButtonEnabled(ui::DIALOG_BUTTON_OK, ShouldOkButtonBeEnabled());
} else { } else {
AddChildView(CreateFeedbackContentView(controller_, this).release()); AddChildView(CreateFeedbackContentView(controller_, this).release());
} }
......
...@@ -33,14 +33,9 @@ class LocalCardMigrationDialogView : public LocalCardMigrationDialog, ...@@ -33,14 +33,9 @@ class LocalCardMigrationDialogView : public LocalCardMigrationDialog,
void ShowDialog() override; void ShowDialog() override;
void CloseDialog() override; void CloseDialog() override;
// views::BubbleDialogDelegateView:
ui::ModalType GetModalType() const override;
bool ShouldShowCloseButton() const override;
bool IsDialogButtonEnabled(ui::DialogButton button) const override;
void WindowClosing() override;
// Called by MigratableCardView when the user clicks the trash can button. // Called by MigratableCardView when the user clicks the trash can button.
// |guid| is the GUID of the credit card to be deleted. // |guid| is the GUID of the credit card to be deleted.
void OnCardCheckboxToggled();
void DeleteCard(const std::string& guid); void DeleteCard(const std::string& guid);
void UpdateLayout(); void UpdateLayout();
...@@ -50,6 +45,8 @@ class LocalCardMigrationDialogView : public LocalCardMigrationDialog, ...@@ -50,6 +45,8 @@ class LocalCardMigrationDialogView : public LocalCardMigrationDialog,
void ConstructView(); void ConstructView();
void OnDialogAccepted(); void OnDialogAccepted();
void OnDialogCancelled(); void OnDialogCancelled();
void OnWindowClosing();
bool ShouldOkButtonBeEnabled() const;
base::string16 GetOkButtonLabel() const; base::string16 GetOkButtonLabel() const;
base::string16 GetCancelButtonLabel() const; base::string16 GetCancelButtonLabel() const;
......
...@@ -212,7 +212,7 @@ MigratableCardView::GetMigratableCardDescriptionView( ...@@ -212,7 +212,7 @@ MigratableCardView::GetMigratableCardDescriptionView(
void MigratableCardView::CheckboxPressed() { void MigratableCardView::CheckboxPressed() {
// If the button clicked is a checkbox. Enable/disable the save // If the button clicked is a checkbox. Enable/disable the save
// button if needed. // button if needed.
parent_dialog_->DialogModelChanged(); parent_dialog_->OnCardCheckboxToggled();
// The warning text will be visible only when user unchecks the checkbox. // The warning text will be visible only when user unchecks the checkbox.
checkbox_uncheck_text_container_->SetVisible(!checkbox_->GetChecked()); checkbox_uncheck_text_container_->SetVisible(!checkbox_->GetChecked());
InvalidateLayout(); InvalidateLayout();
......
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