Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(800)

Unified Diff: ui/message_center/message_view.cc

Issue 12277024: Notificaitons refactor step 2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix the remaining test Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/message_center/message_view.cc
diff --git a/ui/message_center/message_view.cc b/ui/message_center/message_view.cc
index 27535b74c1d54e27c9cdf0e5283cc3e019407858..203cc5089ffd4a898c5963983b6f8c19fe351698 100644
--- a/ui/message_center/message_view.cc
+++ b/ui/message_center/message_view.cc
@@ -144,20 +144,20 @@ class WebNotificationMenuModel : public ui::SimpleMenuModel,
public ui::SimpleMenuModel::Delegate {
public:
WebNotificationMenuModel(NotificationList::Delegate* list_delegate,
- const Notification& notification)
+ Notification* notification)
: ALLOW_THIS_IN_INITIALIZER_LIST(ui::SimpleMenuModel(this)),
list_delegate_(list_delegate),
notification_(notification) {
// Add 'disable notifications' menu item.
- if (!notification.extension_id.empty()) {
+ if (!notification->extension_id().empty()) {
AddItem(kToggleExtensionCommand,
GetLabelForCommandId(kToggleExtensionCommand));
- } else if (!notification.display_source.empty()) {
+ } else if (!notification->display_source().empty()) {
AddItem(kTogglePermissionCommand,
GetLabelForCommandId(kTogglePermissionCommand));
}
// Add settings menu item.
- if (!notification.display_source.empty()) {
+ if (!notification->display_source().empty()) {
AddItem(kShowSettingsCommand,
GetLabelForCommandId(kShowSettingsCommand));
}
@@ -173,7 +173,7 @@ class WebNotificationMenuModel : public ui::SimpleMenuModel,
return l10n_util::GetStringUTF16(IDS_MESSAGE_CENTER_EXTENSIONS_DISABLE);
case kTogglePermissionCommand:
return l10n_util::GetStringFUTF16(IDS_MESSAGE_CENTER_SITE_DISABLE,
- notification_.display_source);
+ notification_->display_source());
case kShowSettingsCommand:
return l10n_util::GetStringUTF16(IDS_MESSAGE_CENTER_SETTINGS);
default:
@@ -200,13 +200,13 @@ class WebNotificationMenuModel : public ui::SimpleMenuModel,
virtual void ExecuteCommand(int command_id) OVERRIDE {
switch (command_id) {
case kToggleExtensionCommand:
- list_delegate_->DisableNotificationByExtension(notification_.id);
+ list_delegate_->DisableNotificationByExtension(notification_->id());
break;
case kTogglePermissionCommand:
- list_delegate_->DisableNotificationByUrl(notification_.id);
+ list_delegate_->DisableNotificationByUrl(notification_->id());
break;
case kShowSettingsCommand:
- list_delegate_->ShowNotificationSettings(notification_.id);
+ list_delegate_->ShowNotificationSettings(notification_->id());
break;
default:
NOTREACHED();
@@ -214,15 +214,15 @@ class WebNotificationMenuModel : public ui::SimpleMenuModel,
}
private:
- NotificationList::Delegate* list_delegate_;
- Notification notification_;
+ NotificationList::Delegate* list_delegate_; // Weak, global MessageCenter
+ Notification* notification_; // Weak, owned by NotificationList
DISALLOW_COPY_AND_ASSIGN(WebNotificationMenuModel);
};
MessageView::MessageView(
NotificationList::Delegate* list_delegate,
- const Notification& notification)
+ Notification* notification)
: list_delegate_(list_delegate),
notification_(notification),
scroller_(NULL) {
@@ -245,13 +245,13 @@ bool MessageView::OnMousePressed(const ui::MouseEvent& event) {
ShowMenu(event.location());
return true;
}
- list_delegate_->OnNotificationClicked(notification_.id);
+ list_delegate_->OnNotificationClicked(notification_->id());
return true;
}
void MessageView::OnGestureEvent(ui::GestureEvent* event) {
if (event->type() == ui::ET_GESTURE_TAP) {
- list_delegate_->OnNotificationClicked(notification_.id);
+ list_delegate_->OnNotificationClicked(notification_->id());
event->SetHandled();
return;
}
@@ -278,7 +278,7 @@ void MessageView::OnGestureEvent(ui::GestureEvent* event) {
void MessageView::ButtonPressed(views::Button* sender,
const ui::Event& event) {
if (sender == close_button())
- list_delegate_->SendRemoveNotification(notification_.id);
+ list_delegate_->SendRemoveNotification(notification_->id());
}
void MessageView::ShowMenu(gfx::Point screen_location) {
@@ -299,7 +299,7 @@ void MessageView::ShowMenu(gfx::Point screen_location) {
}
void MessageView::OnSlideOut() {
- list_delegate_->SendRemoveNotification(notification_.id);
+ list_delegate_->SendRemoveNotification(notification_->id());
}
} // namespace message_center

Powered by Google App Engine
This is Rietveld 408576698