Commit 7494dadd authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Change ButtonPressed overrides to callbacks: c/b/ui/views/safe_browsing/

Bug: 772945
Change-Id: I70086bea566951bf153eee521e2ec76102470dfa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2469440
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Commit-Queue: Daniel Rubery <drubery@chromium.org>
Reviewed-by: default avatarDaniel Rubery <drubery@chromium.org>
Cr-Commit-Position: refs/heads/master@{#818054}
parent 2aa0b3d2
...@@ -44,9 +44,15 @@ DeepScanningFailureModalDialog::DeepScanningFailureModalDialog( ...@@ -44,9 +44,15 @@ DeepScanningFailureModalDialog::DeepScanningFailureModalDialog(
IDS_DEEP_SCANNING_TIMED_OUT_DIALOG_CANCEL_BUTTON)); IDS_DEEP_SCANNING_TIMED_OUT_DIALOG_CANCEL_BUTTON));
SetAcceptCallback(std::move(accept_callback)); SetAcceptCallback(std::move(accept_callback));
SetCancelCallback(std::move(cancel_callback)); SetCancelCallback(std::move(cancel_callback));
open_now_button_ = SetExtraView(std::make_unique<views::MdTextButton>( SetExtraView(std::make_unique<views::MdTextButton>(
this, l10n_util::GetStringUTF16( base::BindRepeating(
IDS_DEEP_SCANNING_INFO_DIALOG_OPEN_NOW_BUTTON))); [](DeepScanningFailureModalDialog* dialog) {
std::move(dialog->open_now_callback_).Run();
dialog->CancelDialog();
},
base::Unretained(this)),
l10n_util::GetStringUTF16(
IDS_DEEP_SCANNING_INFO_DIALOG_OPEN_NOW_BUTTON)));
set_margins(ChromeLayoutProvider::Get()->GetDialogInsetsForContentType( set_margins(ChromeLayoutProvider::Get()->GetDialogInsetsForContentType(
views::TEXT, views::TEXT)); views::TEXT, views::TEXT));
...@@ -86,12 +92,4 @@ ui::ModalType DeepScanningFailureModalDialog::GetModalType() const { ...@@ -86,12 +92,4 @@ ui::ModalType DeepScanningFailureModalDialog::GetModalType() const {
return ui::MODAL_TYPE_CHILD; return ui::MODAL_TYPE_CHILD;
} }
void DeepScanningFailureModalDialog::ButtonPressed(views::Button* sender,
const ui::Event& event) {
if (sender == open_now_button_) {
std::move(open_now_callback_).Run();
CancelDialog();
}
}
} // namespace safe_browsing } // namespace safe_browsing
...@@ -20,8 +20,7 @@ namespace safe_browsing { ...@@ -20,8 +20,7 @@ namespace safe_browsing {
// A tab modal dialog that provides more information to the user about the // A tab modal dialog that provides more information to the user about the
// prompt for deep scanning. // prompt for deep scanning.
class DeepScanningFailureModalDialog : public views::DialogDelegateView, class DeepScanningFailureModalDialog : public views::DialogDelegateView {
public views::ButtonListener {
public: public:
// Show this dialog for the given |web_contents|. // Show this dialog for the given |web_contents|.
static void ShowForWebContents(content::WebContents* web_contents, static void ShowForWebContents(content::WebContents* web_contents,
...@@ -47,15 +46,7 @@ class DeepScanningFailureModalDialog : public views::DialogDelegateView, ...@@ -47,15 +46,7 @@ class DeepScanningFailureModalDialog : public views::DialogDelegateView,
// views::WidgetDelegate implementation: // views::WidgetDelegate implementation:
ui::ModalType GetModalType() const override; ui::ModalType GetModalType() const override;
// views::ButtonListener implementation:
void ButtonPressed(views::Button* sender, const ui::Event& event) override;
private: private:
// The open now button for this dialog. The pointer is unowned, but this is a
// child View of this dialog's View, so it has the same lifetime.
views::Button* open_now_button_;
// The callbacks to trigger on each way the dialog is resolved.
base::OnceClosure open_now_callback_; base::OnceClosure open_now_callback_;
}; };
......
...@@ -43,8 +43,7 @@ PromptForScanningModalDialog::PromptForScanningModalDialog( ...@@ -43,8 +43,7 @@ PromptForScanningModalDialog::PromptForScanningModalDialog(
content::WebContents* web_contents, content::WebContents* web_contents,
const base::string16& filename, const base::string16& filename,
base::OnceClosure accept_callback, base::OnceClosure accept_callback,
base::OnceClosure open_now_callback) base::OnceClosure open_now_callback) {
: filename_(filename), open_now_callback_(std::move(open_now_callback)) {
SetTitle(IDS_DEEP_SCANNING_INFO_DIALOG_TITLE); SetTitle(IDS_DEEP_SCANNING_INFO_DIALOG_TITLE);
SetButtonLabel( SetButtonLabel(
ui::DIALOG_BUTTON_OK, ui::DIALOG_BUTTON_OK,
...@@ -53,9 +52,15 @@ PromptForScanningModalDialog::PromptForScanningModalDialog( ...@@ -53,9 +52,15 @@ PromptForScanningModalDialog::PromptForScanningModalDialog(
ui::DIALOG_BUTTON_CANCEL, ui::DIALOG_BUTTON_CANCEL,
l10n_util::GetStringUTF16(IDS_DEEP_SCANNING_INFO_DIALOG_CANCEL_BUTTON)); l10n_util::GetStringUTF16(IDS_DEEP_SCANNING_INFO_DIALOG_CANCEL_BUTTON));
SetAcceptCallback(std::move(accept_callback)); SetAcceptCallback(std::move(accept_callback));
open_now_button_ = SetExtraView(std::make_unique<views::MdTextButton>( SetExtraView(std::make_unique<views::MdTextButton>(
this, l10n_util::GetStringUTF16( base::BindRepeating(
IDS_DEEP_SCANNING_INFO_DIALOG_OPEN_NOW_BUTTON))); [](PromptForScanningModalDialog* dialog) {
std::move(dialog->open_now_callback_).Run();
dialog->CancelDialog();
},
base::Unretained(this)),
l10n_util::GetStringUTF16(
IDS_DEEP_SCANNING_INFO_DIALOG_OPEN_NOW_BUTTON)));
set_margins(ChromeLayoutProvider::Get()->GetDialogInsetsForContentType( set_margins(ChromeLayoutProvider::Get()->GetDialogInsetsForContentType(
views::TEXT, views::TEXT)); views::TEXT, views::TEXT));
...@@ -74,7 +79,7 @@ PromptForScanningModalDialog::PromptForScanningModalDialog( ...@@ -74,7 +79,7 @@ PromptForScanningModalDialog::PromptForScanningModalDialog(
base::string16 message_text = base::ReplaceStringPlaceholders( base::string16 message_text = base::ReplaceStringPlaceholders(
base::ASCIIToUTF16("$1 $2"), base::ASCIIToUTF16("$1 $2"),
{l10n_util::GetStringFUTF16(IDS_DEEP_SCANNING_INFO_DIALOG_MESSAGE, {l10n_util::GetStringFUTF16(IDS_DEEP_SCANNING_INFO_DIALOG_MESSAGE,
filename_), filename),
l10n_util::GetStringUTF16(IDS_LEARN_MORE)}, l10n_util::GetStringUTF16(IDS_LEARN_MORE)},
&offsets); &offsets);
...@@ -117,12 +122,4 @@ ui::ModalType PromptForScanningModalDialog::GetModalType() const { ...@@ -117,12 +122,4 @@ ui::ModalType PromptForScanningModalDialog::GetModalType() const {
return ui::MODAL_TYPE_CHILD; return ui::MODAL_TYPE_CHILD;
} }
void PromptForScanningModalDialog::ButtonPressed(views::Button* sender,
const ui::Event& event) {
if (sender == open_now_button_) {
std::move(open_now_callback_).Run();
CancelDialog();
}
}
} // namespace safe_browsing } // namespace safe_browsing
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#include "base/callback_forward.h" #include "base/callback_forward.h"
#include "base/timer/timer.h" #include "base/timer/timer.h"
#include "ui/base/ui_base_types.h" #include "ui/base/ui_base_types.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/controls/styled_label.h" #include "ui/views/controls/styled_label.h"
#include "ui/views/window/dialog_delegate.h" #include "ui/views/window/dialog_delegate.h"
...@@ -21,8 +20,7 @@ namespace safe_browsing { ...@@ -21,8 +20,7 @@ namespace safe_browsing {
// A tab modal dialog that provides more information to the user about the // A tab modal dialog that provides more information to the user about the
// prompt for deep scanning. // prompt for deep scanning.
class PromptForScanningModalDialog : public views::DialogDelegateView, class PromptForScanningModalDialog : public views::DialogDelegateView {
public views::ButtonListener {
public: public:
// Show this dialog for the given |web_contents|. // Show this dialog for the given |web_contents|.
static void ShowForWebContents(content::WebContents* web_contents, static void ShowForWebContents(content::WebContents* web_contents,
...@@ -48,18 +46,7 @@ class PromptForScanningModalDialog : public views::DialogDelegateView, ...@@ -48,18 +46,7 @@ class PromptForScanningModalDialog : public views::DialogDelegateView,
// views::WidgetDelegate implementation: // views::WidgetDelegate implementation:
ui::ModalType GetModalType() const override; ui::ModalType GetModalType() const override;
// views::ButtonListener implementation:
void ButtonPressed(views::Button* sender, const ui::Event& event) override;
private: private:
// The name of the file that this prompt was created for.
base::string16 filename_;
// The open now button for this dialog. The pointer is unowned, but this is a
// child View of this dialog's View, so it has the same lifetime.
views::Button* open_now_button_;
// The callbacks to trigger on each way the dialog is resolved.
base::OnceClosure open_now_callback_; base::OnceClosure open_now_callback_;
}; };
......
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