summaryrefslogtreecommitdiffstats
path: root/ui/message_center/base_format_view.cc
diff options
context:
space:
mode:
authormiket@chromium.org <miket@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-14 01:53:10 +0000
committermiket@chromium.org <miket@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-14 01:53:10 +0000
commit7af7a3ec9ffc803d7fb19048920a7102f209bfe8 (patch)
treef482753affa3dc437a2e05cc7d5a08da311ef3c5 /ui/message_center/base_format_view.cc
parent61bf48eafc0f98f57036f777c253f178b8744ef0 (diff)
downloadchromium_src-7af7a3ec9ffc803d7fb19048920a7102f209bfe8.zip
chromium_src-7af7a3ec9ffc803d7fb19048920a7102f209bfe8.tar.gz
chromium_src-7af7a3ec9ffc803d7fb19048920a7102f209bfe8.tar.bz2
Plumb the ButtonPressed callback of the two buttons in BaseFormatView through to the NotificationDelegate's new ButtonClick() method.
The practical point of this CL is twofold: (1) provide a good stopping point for the larger goal of sending this new ButtonClick event to JavaScript callers, and (2) provide new useful functionality to C++ code that is interested in button-click events. 0. Remove vestigal intents fields, which we're replacing with explicit callbacks. 1. Make BaseFormatView's ButtonPressed() send a new NotificationList::Delegate::OnButtonClicked(). 2. MessageCenter passes that through to MessageCenter::Delegate::OnButtonClicked(), which has the same name as the above delegate method but is NOT directly related. 3. BalloonCollectionImplAsh looks up the specific balloon whose button was clicked, then calls the appropriate OnButtonClick() (note the change in tense). 4. chrome/browser/notifications/balloon passes the baton to the Notification that it owns, calling its ButtonClick() method. 5. The Notification's delegate handles ButtonClick(). Again, these two method share the name but are not strictly related. 6. In the case we'll eventually care about, notification_api.cc will implement a functional ButtonClick(). But for now this implementation is a stub. BUG=164249 Review URL: https://chromiumcodereview.appspot.com/11546003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@173043 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/message_center/base_format_view.cc')
-rw-r--r--ui/message_center/base_format_view.cc34
1 files changed, 20 insertions, 14 deletions
diff --git a/ui/message_center/base_format_view.cc b/ui/message_center/base_format_view.cc
index 027c724..f8ce583 100644
--- a/ui/message_center/base_format_view.cc
+++ b/ui/message_center/base_format_view.cc
@@ -76,19 +76,17 @@ void BaseFormatView::SetUpView() {
// TODO(miket): unreadCount
- views::LabelButton* button_one = NULL;
if (notification_.button_one_title.length() != 0) {
- button_one = new views::LabelButton(
+ button_one_ = new views::LabelButton(
this, notification_.button_one_title);
- button_one->SetHorizontalAlignment(gfx::ALIGN_CENTER);
- button_one->SetNativeTheme(true);
+ button_one_->SetHorizontalAlignment(gfx::ALIGN_CENTER);
+ button_one_->SetNativeTheme(true);
}
- views::LabelButton* button_two = NULL;
- if (button_one && notification_.button_two_title.length() != 0) {
- button_two = new views::LabelButton(
+ if (button_one_ && notification_.button_two_title.length() != 0) {
+ button_two_ = new views::LabelButton(
this, notification_.button_two_title);
- button_two->SetHorizontalAlignment(gfx::ALIGN_CENTER);
- button_two->SetNativeTheme(true);
+ button_two_->SetHorizontalAlignment(gfx::ALIGN_CENTER);
+ button_two_->SetNativeTheme(true);
}
views::Label* expanded_message = new views::Label(
@@ -168,9 +166,9 @@ void BaseFormatView::SetUpView() {
// Row 3: Continuation of big icon, two buttons, secondary icon.
layout->StartRow(0,0);
layout->SkipColumns(1);
- if (button_one) {
- layout->AddView(button_one, 1, 1);
- layout->AddView(button_two, 1, 1);
+ if (button_one_) {
+ layout->AddView(button_one_, 1, 1);
+ layout->AddView(button_two_, 1, 1);
} else {
layout->SkipColumns(3); // two buttons plus padding
}
@@ -189,8 +187,16 @@ void BaseFormatView::SetUpView() {
void BaseFormatView::ButtonPressed(views::Button* sender,
const ui::Event& event) {
- // TODO(miket): propagate to caller.
- MessageView::ButtonPressed(sender, event);
+ // TODO(miket): consider changing the _one, _two etc. widgets to an array or
+ // map so that we can move this behavior to the superclass. It seems like
+ // something we wouldn't want to keep recoding for each subclass.
+ if (sender == button_one_) {
+ list_delegate_->OnButtonClicked(notification_.id, 0);
+ } else if (sender == button_two_) {
+ list_delegate_->OnButtonClicked(notification_.id, 1);
+ } else {
+ MessageView::ButtonPressed(sender, event);
+ }
}
} // namespace message_center