Index: ui/message_center/views/message_view.cc |
diff --git a/ui/message_center/views/message_view.cc b/ui/message_center/views/message_view.cc |
index da65a0a87c266ad915401b7a08728e773e6db7ea..56e2202214ebf717a605a3d8c1cbd8460a529690 100644 |
--- a/ui/message_center/views/message_view.cc |
+++ b/ui/message_center/views/message_view.cc |
@@ -14,7 +14,6 @@ |
#include "ui/gfx/canvas.h" |
#include "ui/message_center/message_center.h" |
#include "ui/message_center/message_center_style.h" |
-#include "ui/message_center/message_center_tray.h" |
#include "ui/message_center/message_center_util.h" |
#include "ui/message_center/views/padded_button.h" |
#include "ui/views/context_menu_controller.h" |
@@ -40,11 +39,8 @@ const int kShowSettingsCommand = 1; |
class MenuModel : public ui::SimpleMenuModel, |
public ui::SimpleMenuModel::Delegate { |
public: |
- MenuModel(message_center::MessageCenter* message_center, |
- message_center::MessageCenterTray* tray, |
- const std::string& notification_id, |
- const string16& display_source, |
- const message_center::NotifierId& notifier_id); |
+ MenuModel(message_center::MessageView* message_view, |
+ const string16& display_source); |
virtual ~MenuModel(); |
// Overridden from ui::SimpleMenuModel::Delegate: |
@@ -57,24 +53,14 @@ class MenuModel : public ui::SimpleMenuModel, |
virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE; |
private: |
- message_center::MessageCenter* message_center_; // Weak reference. |
- message_center::MessageCenterTray* tray_; // Weak reference. |
- std::string notification_id_; |
- message_center::NotifierId notifier_id_; |
- |
+ message_center::MessageView* message_view_; // Weak, owns us. |
DISALLOW_COPY_AND_ASSIGN(MenuModel); |
}; |
-MenuModel::MenuModel(message_center::MessageCenter* message_center, |
- message_center::MessageCenterTray* tray, |
- const std::string& notification_id, |
- const string16& display_source, |
- const message_center::NotifierId& notifier_id) |
+MenuModel::MenuModel(message_center::MessageView* message_view, |
+ const string16& display_source) |
: ui::SimpleMenuModel(this), |
- message_center_(message_center), |
- tray_(tray), |
- notification_id_(notification_id), |
- notifier_id_(notifier_id) { |
+ message_view_(message_view) { |
// Add 'disable notifications' menu item. |
if (!display_source.empty()) { |
AddItem(kTogglePermissionCommand, |
@@ -109,12 +95,10 @@ bool MenuModel::GetAcceleratorForCommandId(int command_id, |
void MenuModel::ExecuteCommand(int command_id, int event_flags) { |
switch (command_id) { |
case kTogglePermissionCommand: |
- message_center_->DisableNotificationsByNotifier(notifier_id_); |
+ message_view_->DisableNotificationsFromThisSource(); |
break; |
case kShowSettingsCommand: |
- // |tray_| may be NULL in tests. |
- if (tray_) |
- tray_->ShowNotifierSettingsBubble(); |
+ message_view_->ShowNotifierSettingsBubble(); |
break; |
default: |
NOTREACHED(); |
@@ -127,10 +111,8 @@ namespace message_center { |
class MessageViewContextMenuController : public views::ContextMenuController { |
public: |
- MessageViewContextMenuController( |
- MessageCenter* message_center, |
- MessageCenterTray* tray, |
- const Notification& notification); |
+ MessageViewContextMenuController(MessageView* message_view, |
+ const string16& display_source); |
virtual ~MessageViewContextMenuController(); |
protected: |
@@ -139,22 +121,15 @@ class MessageViewContextMenuController : public views::ContextMenuController { |
const gfx::Point& point, |
ui::MenuSourceType source_type) OVERRIDE; |
- MessageCenter* message_center_; // Weak reference. |
- MessageCenterTray* tray_; // Weak reference. |
- std::string notification_id_; |
+ MessageView* message_view_; // Weak, owns us. |
string16 display_source_; |
- NotifierId notifier_id_; |
}; |
MessageViewContextMenuController::MessageViewContextMenuController( |
- MessageCenter* message_center, |
- MessageCenterTray* tray, |
- const Notification& notification) |
- : message_center_(message_center), |
- tray_(tray), |
- notification_id_(notification.id()), |
- display_source_(notification.display_source()), |
- notifier_id_(notification.notifier_id()) { |
+ MessageView* message_view, |
+ const string16& display_source) |
+ : message_view_(message_view), |
+ display_source_(display_source) { |
} |
MessageViewContextMenuController::~MessageViewContextMenuController() { |
@@ -164,8 +139,7 @@ void MessageViewContextMenuController::ShowContextMenuForView( |
views::View* source, |
const gfx::Point& point, |
ui::MenuSourceType source_type) { |
- MenuModel menu_model(message_center_, tray_, notification_id_, |
- display_source_, notifier_id_); |
+ MenuModel menu_model(message_view_, display_source_); |
if (menu_model.GetItemCount() == 0) |
return; |
@@ -180,13 +154,9 @@ void MessageViewContextMenuController::ShowContextMenuForView( |
views::MenuRunner::HAS_MNEMONICS)); |
} |
-MessageView::MessageView(const Notification& notification, |
- MessageCenter* message_center, |
- MessageCenterTray* tray) |
- : message_center_(message_center), |
- notification_id_(notification.id()), |
- context_menu_controller_(new MessageViewContextMenuController( |
- message_center, tray, notification)), |
+MessageView::MessageView(const string16& display_source) |
+ : context_menu_controller_( |
+ new MessageViewContextMenuController(this, display_source)), |
scroller_(NULL) { |
set_focusable(true); |
set_context_menu_controller(context_menu_controller_.get()); |
@@ -203,9 +173,6 @@ MessageView::MessageView(const Notification& notification, |
close_button_.reset(close); |
} |
-MessageView::MessageView() { |
-} |
- |
MessageView::~MessageView() { |
} |
@@ -239,11 +206,11 @@ void MessageView::GetAccessibleState(ui::AccessibleViewState* state) { |
} |
bool MessageView::OnMousePressed(const ui::MouseEvent& event) { |
- if (event.IsOnlyLeftMouseButton()) { |
- message_center_->ClickOnNotification(notification_id_); |
- return true; |
- } |
- return false; |
+ if (!event.IsOnlyLeftMouseButton()) |
+ return false; |
+ |
+ ClickOnNotification(); |
+ return true; |
} |
bool MessageView::OnKeyPressed(const ui::KeyEvent& event) { |
@@ -251,11 +218,11 @@ bool MessageView::OnKeyPressed(const ui::KeyEvent& event) { |
return false; |
if (event.key_code() == ui::VKEY_RETURN) { |
- message_center_->ClickOnNotification(notification_id_); |
+ ClickOnNotification(); |
return true; |
} else if ((event.key_code() == ui::VKEY_DELETE || |
event.key_code() == ui::VKEY_BACK)) { |
- message_center_->RemoveNotification(notification_id_, true); // By user. |
+ RemoveNotification(true); // By user. |
return true; |
} |
@@ -268,13 +235,13 @@ bool MessageView::OnKeyReleased(const ui::KeyEvent& event) { |
if (event.flags() != ui::EF_NONE || event.flags() != ui::VKEY_SPACE) |
return false; |
- message_center_->ClickOnNotification(notification_id_); |
+ ClickOnNotification(); |
return true; |
} |
void MessageView::OnGestureEvent(ui::GestureEvent* event) { |
if (event->type() == ui::ET_GESTURE_TAP) { |
- message_center_->ClickOnNotification(notification_id_); |
+ ClickOnNotification(); |
event->SetHandled(); |
return; |
} |
@@ -302,12 +269,12 @@ void MessageView::OnPaintFocusBorder(gfx::Canvas* canvas) { |
void MessageView::ButtonPressed(views::Button* sender, |
const ui::Event& event) { |
if (sender == close_button()) { |
- message_center_->RemoveNotification(notification_id_, true); // By user. |
+ RemoveNotification(true); // By user. |
} |
} |
void MessageView::OnSlideOut() { |
- message_center_->RemoveNotification(notification_id_, true); // By user. |
+ RemoveNotification(true); // By user. |
} |
} // namespace message_center |