Commit 57a77062 authored by Nicholas Verne's avatar Nicholas Verne Committed by Commit Bot

Disable buttons in the Crostini Recovery

When the user has clicked the Restart button, there is a delay while
Crostini is shutting down before we close the dialog. We disable the
buttons in this state as feedback that something is happening and the
user shouldn't proceed yet.

Bug: 1060830
Change-Id: If0e654c6f63e182efc3e8d178cd2237db9a09807
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2099346Reviewed-by: default avatarNic Hollingum <hollingum@google.com>
Reviewed-by: default avatarDavid Munro <davidmunro@google.com>
Commit-Queue: Nicholas Verne <nverne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#749516}
parent 52edcd2c
...@@ -68,6 +68,12 @@ bool CrostiniRecoveryView::ShouldShowCloseButton() const { ...@@ -68,6 +68,12 @@ bool CrostiniRecoveryView::ShouldShowCloseButton() const {
return false; return false;
} }
bool CrostiniRecoveryView::IsDialogButtonEnabled(
ui::DialogButton button) const {
// Buttons are disabled after Accept or Cancel have been clicked.
return closed_reason_ == views::Widget::ClosedReason::kUnspecified;
}
gfx::Size CrostiniRecoveryView::CalculatePreferredSize() const { gfx::Size CrostiniRecoveryView::CalculatePreferredSize() const {
const int dialog_width = ChromeLayoutProvider::Get()->GetDistanceMetric( const int dialog_width = ChromeLayoutProvider::Get()->GetDistanceMetric(
DISTANCE_STANDALONE_BUBBLE_PREFERRED_WIDTH) - DISTANCE_STANDALONE_BUBBLE_PREFERRED_WIDTH) -
...@@ -90,6 +96,7 @@ bool CrostiniRecoveryView::Accept() { ...@@ -90,6 +96,7 @@ bool CrostiniRecoveryView::Accept() {
} }
}, },
weak_ptr_factory_.GetWeakPtr())); weak_ptr_factory_.GetWeakPtr()));
DialogModelChanged();
return false; return false;
} }
...@@ -116,6 +123,7 @@ bool CrostiniRecoveryView::Cancel() { ...@@ -116,6 +123,7 @@ bool CrostiniRecoveryView::Cancel() {
} }
app_id_ = crostini::GetTerminalId(); app_id_ = crostini::GetTerminalId();
ScheduleAppLaunch(); ScheduleAppLaunch();
DialogModelChanged();
return false; return false;
} }
......
...@@ -29,6 +29,7 @@ class CrostiniRecoveryView : public views::BubbleDialogDelegateView { ...@@ -29,6 +29,7 @@ class CrostiniRecoveryView : public views::BubbleDialogDelegateView {
gfx::Size CalculatePreferredSize() const override; gfx::Size CalculatePreferredSize() const override;
bool Accept() override; bool Accept() override;
bool Cancel() override; bool Cancel() override;
bool IsDialogButtonEnabled(ui::DialogButton button) const override;
static CrostiniRecoveryView* GetActiveViewForTesting(); static CrostiniRecoveryView* GetActiveViewForTesting();
......
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