Commit 4a804960 authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Change ButtonPressed overrides to callbacks: ash/system/toast/

Bug: 772945
Change-Id: I6d151607137066e5e7916e82c96c233d82159d69
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2506261
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Commit-Queue: Yoshiki Iguchi <yoshiki@chromium.org>
Reviewed-by: default avatarYoshiki Iguchi <yoshiki@chromium.org>
Cr-Commit-Position: refs/heads/master@{#822526}
parent 6b11534a
...@@ -118,9 +118,8 @@ class ToastOverlay::ToastDisplayObserver : public display::DisplayObserver { ...@@ -118,9 +118,8 @@ class ToastOverlay::ToastDisplayObserver : public display::DisplayObserver {
// ToastOverlayButton // ToastOverlayButton
class ToastOverlayButton : public views::LabelButton { class ToastOverlayButton : public views::LabelButton {
public: public:
ToastOverlayButton(views::ButtonListener* listener, ToastOverlayButton(PressedCallback callback, const base::string16& text)
const base::string16& text) : views::LabelButton(std::move(callback), text, CONTEXT_TOAST_OVERLAY) {
: views::LabelButton(listener, text, CONTEXT_TOAST_OVERLAY) {
SetInkDropMode(InkDropMode::ON); SetInkDropMode(InkDropMode::ON);
SetHasInkDropActionOnClick(true); SetHasInkDropActionOnClick(true);
...@@ -163,14 +162,13 @@ class ToastOverlayButton : public views::LabelButton { ...@@ -163,14 +162,13 @@ class ToastOverlayButton : public views::LabelButton {
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// ToastOverlayView // ToastOverlayView
class ToastOverlayView : public views::View, public views::ButtonListener { class ToastOverlayView : public views::View {
public: public:
// This object is not owned by the views hierarchy or by the widget. // This object is not owned by the views hierarchy or by the widget.
ToastOverlayView(ToastOverlay* overlay, ToastOverlayView(ToastOverlay* overlay,
const base::string16& text, const base::string16& text,
const base::Optional<base::string16>& dismiss_text, const base::Optional<base::string16>& dismiss_text,
const bool is_managed) const bool is_managed) {
: overlay_(overlay) {
SetPaintToLayer(); SetPaintToLayer();
layer()->SetFillsBoundsOpaquely(false); layer()->SetFillsBoundsOpaquely(false);
layer()->SetRoundedCornerRadius(gfx::RoundedCornersF(kToastCornerRounding)); layer()->SetRoundedCornerRadius(gfx::RoundedCornersF(kToastCornerRounding));
...@@ -198,7 +196,9 @@ class ToastOverlayView : public views::View, public views::ButtonListener { ...@@ -198,7 +196,9 @@ class ToastOverlayView : public views::View, public views::ButtonListener {
return; return;
button_ = AddChildView(std::make_unique<ToastOverlayButton>( button_ = AddChildView(std::make_unique<ToastOverlayButton>(
this, dismiss_text.value().empty() base::BindRepeating(&ToastOverlay::Show, base::Unretained(overlay),
false),
dismiss_text.value().empty()
? l10n_util::GetStringUTF16(IDS_ASH_TOAST_DISMISS_BUTTON) ? l10n_util::GetStringUTF16(IDS_ASH_TOAST_DISMISS_BUTTON)
: dismiss_text.value())); : dismiss_text.value()));
...@@ -242,13 +242,6 @@ class ToastOverlayView : public views::View, public views::ButtonListener { ...@@ -242,13 +242,6 @@ class ToastOverlayView : public views::View, public views::ButtonListener {
} }
} }
// views::ButtonListener:
void ButtonPressed(views::Button* sender, const ui::Event& event) override {
DCHECK_EQ(button_, sender);
overlay_->Show(false);
}
ToastOverlay* overlay_ = nullptr; // weak
ToastOverlayButton* button_ = nullptr; // weak ToastOverlayButton* button_ = nullptr; // weak
views::ImageView* managed_icon_ = nullptr; views::ImageView* managed_icon_ = nullptr;
}; };
......
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