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

cbuiv: remove some GetDialogButtons overrides

Replace them with DialogDelegate::set_buttons() :)

Bug: 1011446
Change-Id: I3cadc0851e272d60a48a540ec6b3da03d47ee377
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1992561
Commit-Queue: Elly Fong-Jones <ellyjones@chromium.org>
Reviewed-by: default avatarPeter Boström <pbos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#729776}
parent 028101be
......@@ -203,7 +203,11 @@ ExtensionInstallDialogView::ExtensionInstallDialogView(
install_button_enabled_(false) {
DCHECK(prompt_->extension());
int buttons = prompt_->GetDialogButtons();
DCHECK(buttons & ui::DIALOG_BUTTON_CANCEL);
DialogDelegate::set_default_button(ui::DIALOG_BUTTON_CANCEL);
DialogDelegate::set_buttons(buttons);
DialogDelegate::set_draggable(true);
if (prompt_->has_webstore_data()) {
auto store_link = std::make_unique<views::Link>(
......@@ -361,14 +365,6 @@ bool ExtensionInstallDialogView::Accept() {
return true;
}
int ExtensionInstallDialogView::GetDialogButtons() const {
int buttons = prompt_->GetDialogButtons();
// Simply having just an OK button is *not* supported. See comment on function
// GetDialogButtons in dialog_delegate.h for reasons.
DCHECK_GT(buttons & ui::DIALOG_BUTTON_CANCEL, 0);
return buttons;
}
bool ExtensionInstallDialogView::IsDialogButtonEnabled(
ui::DialogButton button) const {
if (button == ui::DIALOG_BUTTON_OK)
......
......@@ -53,7 +53,6 @@ class ExtensionInstallDialogView : public views::BubbleDialogDelegateView {
void AddedToWidget() override;
bool Cancel() override;
bool Accept() override;
int GetDialogButtons() const override;
bool IsDialogButtonEnabled(ui::DialogButton button) const override;
bool ShouldShowCloseButton() const override;
......
......@@ -137,6 +137,10 @@ PasswordReuseModalWarningDialog::PasswordReuseModalWarningDialog(
service_(service),
url_(web_contents->GetLastCommittedURL()),
password_type_(password_type) {
DialogDelegate::set_buttons(
password_type_.account_type() == ReusedPasswordAccountType::SAVED_PASSWORD
? ui::DIALOG_BUTTON_OK
: ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL);
DialogDelegate::set_button_label(ui::DIALOG_BUTTON_OK,
GetOkButtonLabel(password_type_));
DialogDelegate::set_button_label(
......@@ -256,13 +260,6 @@ bool PasswordReuseModalWarningDialog::ShouldShowWindowIcon() const {
return true;
}
int PasswordReuseModalWarningDialog::GetDialogButtons() const {
return password_type_.account_type() ==
ReusedPasswordAccountType::SAVED_PASSWORD
? ui::DIALOG_BUTTON_OK
: ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL;
}
bool PasswordReuseModalWarningDialog::Cancel() {
std::move(done_callback_).Run(WarningAction::IGNORE_WARNING);
return true;
......
......@@ -47,7 +47,6 @@ class PasswordReuseModalWarningDialog
bool ShouldShowCloseButton() const override;
gfx::ImageSkia GetWindowIcon() override;
bool ShouldShowWindowIcon() const override;
int GetDialogButtons() const override;
bool Cancel() override;
bool Accept() override;
bool Close() override;
......
......@@ -177,6 +177,15 @@ SessionCrashedBubbleView::SessionCrashedBubbleView(views::View* anchor_view,
uma_option_(NULL),
offer_uma_optin_(offer_uma_optin),
ignored_(true) {
const SessionStartupPref session_startup_pref =
SessionStartupPref::GetStartupPref(browser_->profile());
// Offer the option to open the startup pages using the cancel button, but
// only when the user has selected the URLS option, and set at least one url.
DialogDelegate::set_buttons(
(session_startup_pref.type == SessionStartupPref::URLS &&
!session_startup_pref.urls.empty())
? ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL
: ui::DIALOG_BUTTON_OK);
DialogDelegate::set_button_label(
ui::DIALOG_BUTTON_OK,
l10n_util::GetStringUTF16(IDS_SESSION_CRASHED_VIEW_RESTORE_BUTTON));
......@@ -307,19 +316,6 @@ bool SessionCrashedBubbleView::Close() {
return true;
}
int SessionCrashedBubbleView::GetDialogButtons() const {
int buttons = ui::DIALOG_BUTTON_OK;
// Offer the option to open the startup pages using the cancel button, but
// only when the user has selected the URLS option, and set at least one url.
SessionStartupPref session_startup_pref =
SessionStartupPref::GetStartupPref(browser_->profile());
if (session_startup_pref.type == SessionStartupPref::URLS &&
!session_startup_pref.urls.empty()) {
buttons |= ui::DIALOG_BUTTON_CANCEL;
}
return buttons;
}
void SessionCrashedBubbleView::StyledLabelLinkClicked(views::StyledLabel* label,
const gfx::Range& range,
int event_flags) {
......
......@@ -52,7 +52,6 @@ class SessionCrashedBubbleView : public SessionCrashedBubble,
bool Accept() override;
bool Cancel() override;
bool Close() override;
int GetDialogButtons() const override;
// views::BubbleDialogDelegateView methods.
void Init() override;
......
......@@ -170,13 +170,6 @@ chrome::MessageBoxResult SimpleMessageBoxViews::Show(
return chrome::MESSAGE_BOX_RESULT_DEFERRED;
}
int SimpleMessageBoxViews::GetDialogButtons() const {
if (type_ == chrome::MESSAGE_BOX_TYPE_QUESTION)
return ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL;
return ui::DIALOG_BUTTON_OK;
}
bool SimpleMessageBoxViews::Close() {
return can_close_ ? DialogDelegate::Close() : false;
}
......@@ -248,6 +241,11 @@ SimpleMessageBoxViews::SimpleMessageBoxViews(
views::MessageBoxView::InitParams(message))),
is_system_modal_(is_system_modal),
can_close_(can_close) {
DialogDelegate::set_buttons(type_ == chrome::MESSAGE_BOX_TYPE_QUESTION
? ui::DIALOG_BUTTON_OK |
ui::DIALOG_BUTTON_CANCEL
: ui::DIALOG_BUTTON_OK);
base::string16 ok_text = yes_text;
if (ok_text.empty()) {
ok_text =
......
......@@ -29,7 +29,6 @@ class SimpleMessageBoxViews : public views::DialogDelegate,
MessageBoxResultCallback callback = MessageBoxResultCallback());
// views::DialogDelegate:
int GetDialogButtons() const override;
bool Cancel() override;
bool Accept() override;
bool Close() override;
......
......@@ -32,6 +32,7 @@ TabModalConfirmDialogViews::TabModalConfirmDialogViews(
std::unique_ptr<TabModalConfirmDialogDelegate> delegate,
content::WebContents* web_contents)
: delegate_(std::move(delegate)) {
DialogDelegate::set_buttons(delegate_->GetDialogButtons());
DialogDelegate::set_button_label(ui::DIALOG_BUTTON_OK,
delegate_->GetAcceptButtonTitle());
DialogDelegate::set_button_label(ui::DIALOG_BUTTON_CANCEL,
......@@ -79,10 +80,6 @@ void TabModalConfirmDialogViews::LinkClicked(views::Link* source,
delegate_->LinkClicked(ui::DispositionFromEventFlags(event_flags));
}
int TabModalConfirmDialogViews::GetDialogButtons() const {
return delegate_->GetDialogButtons();
}
base::string16 TabModalConfirmDialogViews::GetWindowTitle() const {
return delegate_->GetTitle();
}
......
......@@ -36,7 +36,6 @@ class TabModalConfirmDialogViews : public TabModalConfirmDialog,
content::WebContents* web_contents);
// views::DialogDelegate:
int GetDialogButtons() const override;
base::string16 GetWindowTitle() const override;
bool Cancel() override;
bool Accept() override;
......
......@@ -33,11 +33,18 @@ ToolbarActionsBarBubbleViews::ToolbarActionsBarBubbleViews(
views::BubbleBorder::TOP_RIGHT),
delegate_(std::move(delegate)),
anchored_to_action_(anchored_to_action) {
base::string16 ok_text = delegate_->GetActionButtonText();
base::string16 cancel_text = delegate_->GetDismissButtonText();
int buttons = ui::DIALOG_BUTTON_NONE;
if (!ok_text.empty())
buttons |= ui::DIALOG_BUTTON_OK;
if (!cancel_text.empty())
buttons |= ui::DIALOG_BUTTON_CANCEL;
DialogDelegate::set_buttons(buttons);
DialogDelegate::set_default_button(delegate_->GetDefaultDialogButton());
DialogDelegate::set_button_label(ui::DIALOG_BUTTON_OK,
delegate_->GetActionButtonText());
DialogDelegate::set_button_label(ui::DIALOG_BUTTON_CANCEL,
delegate_->GetDismissButtonText());
DialogDelegate::set_button_label(ui::DIALOG_BUTTON_OK, ok_text);
DialogDelegate::set_button_label(ui::DIALOG_BUTTON_CANCEL, cancel_text);
DialogDelegate::SetExtraView(CreateExtraInfoView());
DCHECK(anchor_view);
......@@ -178,15 +185,6 @@ void ToolbarActionsBarBubbleViews::Init() {
}
}
int ToolbarActionsBarBubbleViews::GetDialogButtons() const {
int buttons = ui::DIALOG_BUTTON_NONE;
if (!delegate_->GetActionButtonText().empty())
buttons |= ui::DIALOG_BUTTON_OK;
if (!delegate_->GetDismissButtonText().empty())
buttons |= ui::DIALOG_BUTTON_CANCEL;
return buttons;
}
void ToolbarActionsBarBubbleViews::ButtonPressed(views::Button* sender,
const ui::Event& event) {
DCHECK(!delegate_notified_of_close_);
......
......@@ -49,7 +49,6 @@ class ToolbarActionsBarBubbleViews : public views::BubbleDialogDelegateView,
bool Cancel() override;
bool Accept() override;
bool Close() override;
int GetDialogButtons() const override;
void Init() override;
// views::ButtonListener:
......
......@@ -145,15 +145,6 @@ bool AuthenticatorRequestDialogView::Close() {
return true;
}
int AuthenticatorRequestDialogView::GetDialogButtons() const {
int button_mask = 0;
if (sheet()->model()->IsAcceptButtonVisible())
button_mask |= ui::DIALOG_BUTTON_OK;
if (sheet()->model()->IsCancelButtonVisible())
button_mask |= ui::DIALOG_BUTTON_CANCEL;
return button_mask;
}
bool AuthenticatorRequestDialogView::IsDialogButtonEnabled(
ui::DialogButton button) const {
switch (button) {
......@@ -314,7 +305,14 @@ void AuthenticatorRequestDialogView::UpdateUIForCurrentSheet() {
DCHECK(sheet_);
sheet_->ReInitChildViews();
DialogDelegate::set_default_button(sheet_->model()->IsAcceptButtonVisible()
int buttons = ui::DIALOG_BUTTON_NONE;
if (sheet()->model()->IsAcceptButtonVisible())
buttons |= ui::DIALOG_BUTTON_OK;
if (sheet()->model()->IsCancelButtonVisible())
buttons |= ui::DIALOG_BUTTON_CANCEL;
DialogDelegate::set_buttons(buttons);
DialogDelegate::set_default_button((buttons & ui::DIALOG_BUTTON_OK)
? ui::DIALOG_BUTTON_OK
: ui::DIALOG_BUTTON_NONE);
DialogDelegate::set_button_label(ui::DIALOG_BUTTON_OK,
......
......@@ -69,7 +69,6 @@ class AuthenticatorRequestDialogView
bool Accept() override;
bool Cancel() override;
bool Close() override;
int GetDialogButtons() const override;
bool IsDialogButtonEnabled(ui::DialogButton button) const override;
View* GetInitiallyFocusedView() override;
ui::ModalType GetModalType() 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