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

crostini: remove DialogDelegate overrides in ansible config

This change removes overrides of DialogDelegate::GetDialogButtons and
DialogDelegate::GetDialogButtonLabel from
CrostiniAnsibleSoftwareConfigView in favor of the new setters for these
properties.

Bug: 1011446
Change-Id: Id1b90b7b62719562138db8c1eddbb53a63cb07ad
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1954665Reviewed-by: default avatarJoel Hockey <joelhockey@chromium.org>
Reviewed-by: default avatarOlya Kalitova <okalitova@chromium.org>
Commit-Queue: Elly Fong-Jones <ellyjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#722491}
parent 32eb4851
...@@ -47,37 +47,6 @@ void CloseCrostiniAnsibleSoftwareConfigViewForTesting() { ...@@ -47,37 +47,6 @@ void CloseCrostiniAnsibleSoftwareConfigViewForTesting() {
} // namespace crostini } // namespace crostini
int CrostiniAnsibleSoftwareConfigView::GetDialogButtons() const {
switch (state_) {
case State::CONFIGURING:
return ui::DIALOG_BUTTON_NONE;
case State::ERROR:
return ui::DIALOG_BUTTON_OK;
case State::ERROR_OFFLINE:
return ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL;
}
}
base::string16 CrostiniAnsibleSoftwareConfigView::GetDialogButtonLabel(
ui::DialogButton button) const {
switch (state_) {
case State::ERROR:
DCHECK_EQ(button, ui::DIALOG_BUTTON_OK);
return l10n_util::GetStringUTF16(IDS_APP_OK);
case State::ERROR_OFFLINE:
if (button == ui::DIALOG_BUTTON_OK) {
return l10n_util::GetStringUTF16(
IDS_CROSTINI_ANSIBLE_SOFTWARE_CONFIG_RETRY_BUTTON);
} else {
DCHECK_EQ(button, ui::DIALOG_BUTTON_CANCEL);
return l10n_util::GetStringUTF16(IDS_APP_CANCEL);
}
case State::CONFIGURING:
NOTREACHED();
return base::string16();
}
}
bool CrostiniAnsibleSoftwareConfigView::Accept() { bool CrostiniAnsibleSoftwareConfigView::Accept() {
if (state_ == State::ERROR_OFFLINE) { if (state_ == State::ERROR_OFFLINE) {
state_ = State::CONFIGURING; state_ = State::CONFIGURING;
...@@ -189,6 +158,10 @@ CrostiniAnsibleSoftwareConfigView::CrostiniAnsibleSoftwareConfigView( ...@@ -189,6 +158,10 @@ CrostiniAnsibleSoftwareConfigView::CrostiniAnsibleSoftwareConfigView(
chrome::RecordDialogCreation( chrome::RecordDialogCreation(
chrome::DialogIdentifier::CROSTINI_ANSIBLE_SOFTWARE_CONFIG); chrome::DialogIdentifier::CROSTINI_ANSIBLE_SOFTWARE_CONFIG);
// In the initial state (CONFIGURING), there are no buttons and hence no set
// labels.
DialogDelegate::set_buttons(ui::DIALOG_BUTTON_NONE);
} }
CrostiniAnsibleSoftwareConfigView::~CrostiniAnsibleSoftwareConfigView() { CrostiniAnsibleSoftwareConfigView::~CrostiniAnsibleSoftwareConfigView() {
...@@ -199,6 +172,19 @@ CrostiniAnsibleSoftwareConfigView::~CrostiniAnsibleSoftwareConfigView() { ...@@ -199,6 +172,19 @@ CrostiniAnsibleSoftwareConfigView::~CrostiniAnsibleSoftwareConfigView() {
void CrostiniAnsibleSoftwareConfigView::OnStateChanged() { void CrostiniAnsibleSoftwareConfigView::OnStateChanged() {
progress_bar_->SetVisible(state_ == State::CONFIGURING); progress_bar_->SetVisible(state_ == State::CONFIGURING);
subtext_label_->SetText(GetSubtextLabel()); subtext_label_->SetText(GetSubtextLabel());
DialogDelegate::set_buttons(
state_ == State::CONFIGURING
? ui::DIALOG_BUTTON_NONE
: (state_ == State::ERROR
? ui::DIALOG_BUTTON_OK
: ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL));
// The cancel button, even when present, always uses the default text.
DialogDelegate::set_button_label(
ui::DIALOG_BUTTON_OK,
state_ == State::ERROR
? l10n_util::GetStringUTF16(IDS_APP_OK)
: l10n_util::GetStringUTF16(
IDS_CROSTINI_ANSIBLE_SOFTWARE_CONFIG_RETRY_BUTTON));
DialogModelChanged(); DialogModelChanged();
GetWidget()->UpdateWindowTitle(); GetWidget()->UpdateWindowTitle();
GetWidget()->SetSize(GetWidget()->non_client_view()->GetPreferredSize()); GetWidget()->SetSize(GetWidget()->non_client_view()->GetPreferredSize());
......
...@@ -21,8 +21,6 @@ class CrostiniAnsibleSoftwareConfigView ...@@ -21,8 +21,6 @@ class CrostiniAnsibleSoftwareConfigView
public crostini::AnsibleManagementService::Observer { public crostini::AnsibleManagementService::Observer {
public: public:
// views::DialogDelegateView: // views::DialogDelegateView:
int GetDialogButtons() const override;
base::string16 GetDialogButtonLabel(ui::DialogButton button) const override;
bool Accept() override; bool Accept() override;
base::string16 GetWindowTitle() const override; base::string16 GetWindowTitle() const override;
gfx::Size CalculatePreferredSize() const override; gfx::Size CalculatePreferredSize() const override;
......
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