summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorjohnnyg@chromium.org <johnnyg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-07 20:00:46 +0000
committerjohnnyg@chromium.org <johnnyg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-07 20:00:46 +0000
commit13e451ef378b9129cbe09597714047c48c2aa10a (patch)
treea36302f379bc8fc1e874e4dea084ca54e2e8624d /chrome
parent13b290e700929fa5bee18ce68fa1ac50c2506a0a (diff)
downloadchromium_src-13e451ef378b9129cbe09597714047c48c2aa10a.zip
chromium_src-13e451ef378b9129cbe09597714047c48c2aa10a.tar.gz
chromium_src-13e451ef378b9129cbe09597714047c48c2aa10a.tar.bz2
notifications: Simplify the callback handler for the close button event.
BUG=None TEST=compiles and the close button still works as before Patch from Thiago Farina <thiago.farina@gmail.com> Review URL: http://codereview.chromium.org/1575018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43868 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/views/notifications/balloon_view.cc28
-rw-r--r--chrome/browser/views/notifications/balloon_view.h7
2 files changed, 12 insertions, 23 deletions
diff --git a/chrome/browser/views/notifications/balloon_view.cc b/chrome/browser/views/notifications/balloon_view.cc
index cc0c222..3919d5e 100644
--- a/chrome/browser/views/notifications/balloon_view.cc
+++ b/chrome/browser/views/notifications/balloon_view.cc
@@ -80,22 +80,6 @@ const int kRevokePermissionCommand = 0;
} // namespace
-class BalloonCloseButtonListener : public views::ButtonListener {
- public:
- explicit BalloonCloseButtonListener(BalloonView* view)
- : view_(view) {}
- virtual ~BalloonCloseButtonListener() {}
-
- // The only button currently is the close button.
- virtual void ButtonPressed(views::Button* sender, const views::Event&) {
- view_->Close(true);
- }
-
- private:
- // Non-owned pointer to the view which owns this object.
- BalloonView* view_;
-};
-
BalloonViewImpl::BalloonViewImpl(BalloonCollection* collection)
: balloon_(NULL),
collection_(collection),
@@ -106,7 +90,6 @@ BalloonViewImpl::BalloonViewImpl(BalloonCollection* collection)
shelf_background_(NULL),
balloon_background_(NULL),
close_button_(NULL),
- close_button_listener_(NULL),
animation_(NULL),
options_menu_contents_(NULL),
options_menu_menu_(NULL),
@@ -154,6 +137,13 @@ void BalloonViewImpl::DisplayChanged() {
collection_->DisplayChanged();
}
+void BalloonViewImpl::ButtonPressed(views::Button* sender,
+ const views::Event&) {
+ // The only button currently is the close button.
+ DCHECK(sender == close_button_);
+ Close(true);
+}
+
void BalloonViewImpl::DelayedClose(bool by_user) {
html_contents_->Shutdown();
html_container_->CloseNow();
@@ -281,7 +271,6 @@ void BalloonViewImpl::Show(Balloon* balloon) {
l10n_util::GetString(IDS_NOTIFICATION_BALLOON_DISMISS_LABEL);
balloon_ = balloon;
- close_button_listener_.reset(new BalloonCloseButtonListener(this));
SetBounds(balloon_->position().x(), balloon_->position().y(),
GetTotalWidth(), GetTotalHeight());
@@ -290,8 +279,7 @@ void BalloonViewImpl::Show(Balloon* balloon) {
AddChildView(source_label_);
options_menu_button_ = new views::MenuButton(NULL, options_text, this, false);
AddChildView(options_menu_button_);
- close_button_ = new views::TextButton(close_button_listener_.get(),
- dismiss_text);
+ close_button_ = new views::TextButton(this, dismiss_text);
AddChildView(close_button_);
// We have to create two windows: one for the contents and one for the
diff --git a/chrome/browser/views/notifications/balloon_view.h b/chrome/browser/views/notifications/balloon_view.h
index a92aae3..2e11f1c 100644
--- a/chrome/browser/views/notifications/balloon_view.h
+++ b/chrome/browser/views/notifications/balloon_view.h
@@ -45,6 +45,7 @@ class BalloonViewImpl : public BalloonView,
public views::View,
public views::ViewMenuDelegate,
public views::WidgetDelegate,
+ public views::ButtonListener,
public menus::SimpleMenuModel::Delegate,
public NotificationObserver,
public AnimationDelegate {
@@ -74,6 +75,9 @@ class BalloonViewImpl : public BalloonView,
// views::WidgetDelegate interface.
void DisplayChanged();
+ // views::ButtonListener interface.
+ virtual void ButtonPressed(views::Button* sender, const views::Event&);
+
// menus::SimpleMenuModel::Delegate interface.
virtual bool IsCommandIdChecked(int command_id) const;
virtual bool IsCommandIdEnabled(int command_id) const;
@@ -162,9 +166,6 @@ class BalloonViewImpl : public BalloonView,
// Pointer to sub-view is owned by View class.
views::Label* source_label_;
- // Listener for clicks on the close button.
- scoped_ptr<views::ButtonListener> close_button_listener_;
-
// An animation to move the balloon on the screen as its position changes.
scoped_ptr<SlideAnimation> animation_;
gfx::Rect anim_frame_start_;