Chromium Code Reviews| Index: ui/message_center/views/notification_view.cc |
| diff --git a/ui/message_center/views/notification_view.cc b/ui/message_center/views/notification_view.cc |
| index 0531a0f26323d313c574ac76d7c05f686c769f9a..7730632a9a7805ec9c6a5be89b82fa01f1ef5adc 100644 |
| --- a/ui/message_center/views/notification_view.cc |
| +++ b/ui/message_center/views/notification_view.cc |
| @@ -28,9 +28,11 @@ |
| #include "ui/native_theme/native_theme.h" |
| #include "ui/views/background.h" |
| #include "ui/views/border.h" |
| +#include "ui/views/context_menu_controller.h" |
| #include "ui/views/controls/button/image_button.h" |
| #include "ui/views/controls/image_view.h" |
| #include "ui/views/controls/label.h" |
| +#include "ui/views/controls/menu/menu_runner.h" |
| #include "ui/views/controls/progress_bar.h" |
| #include "ui/views/layout/box_layout.h" |
| #include "ui/views/layout/fill_layout.h" |
| @@ -433,6 +435,53 @@ void NotificationButton::StateChanged() { |
| namespace message_center { |
|
stevenjb
2013/12/12 21:19:46
nit: Put in internal namespace, i.e. message_cente
Jun Mukai
2013/12/14 01:13:14
this code has been removed.
|
| +class NotificationViewContextMenuController |
| + : public views::ContextMenuController { |
| + public: |
| + NotificationViewContextMenuController(MessageCenterTray* tray); |
|
stevenjb
2013/12/12 21:19:46
explicit
|
| + virtual ~NotificationViewContextMenuController(); |
| + |
| + protected: |
| + // Overridden from views::ContextMenuController: |
| + virtual void ShowContextMenuForView(views::View* source, |
| + const gfx::Point& point, |
| + ui::MenuSourceType source_type) OVERRIDE; |
| + |
| + private: |
| + MessageCenterTray* tray_; |
|
stevenjb
2013/12/12 21:19:46
nit: WS
|
| + DISALLOW_COPY_AND_ASSIGN(NotificationViewContextMenuController); |
| +}; |
| + |
| +NotificationViewContextMenuController::NotificationViewContextMenuController( |
| + MessageCenterTray* tray) |
| + : tray_(tray) { |
| +} |
| + |
| +NotificationViewContextMenuController:: |
| +~NotificationViewContextMenuController() { |
| +} |
| + |
| +void NotificationViewContextMenuController::ShowContextMenuForView( |
| + views::View* source, |
| + const gfx::Point& point, |
| + ui::MenuSourceType source_type) { |
| + NotificationView* view = static_cast<NotificationView*>(source); |
| + scoped_ptr<ui::MenuModel> menu_model( |
| + tray_->CreateMenuModelForNotification(view->notification_id())); |
| + if (!menu_model.get() || menu_model->GetItemCount() == 0) |
| + return; |
| + |
| + views::MenuRunner menu_runner(menu_model.get()); |
| + |
| + ignore_result(menu_runner.RunMenuAt( |
| + source->GetWidget()->GetTopLevelWidget(), |
| + NULL, |
| + gfx::Rect(point, gfx::Size()), |
| + views::MenuItemView::TOPRIGHT, |
| + source_type, |
| + views::MenuRunner::HAS_MNEMONICS)); |
| +} |
| + |
| // NotificationView //////////////////////////////////////////////////////////// |
| // static |
| @@ -477,13 +526,15 @@ NotificationView::NotificationView(const Notification& notification, |
| MessageCenter* message_center, |
| MessageCenterTray* tray, |
| bool expanded) |
| - : MessageView(notification.display_source()), |
| - message_center_(message_center), |
| - tray_(tray), |
| + : message_center_(message_center), |
| notification_id_(notification.id()), |
| notifier_id_(notification.notifier_id()), |
| clickable_(notification.clickable()), |
| - is_expanded_(expanded) { |
| + is_expanded_(expanded), |
| + context_menu_controller_( |
| + new NotificationViewContextMenuController(tray)) { |
|
stevenjb
2013/12/12 21:19:46
context_menu_controller_ is a View member so it sh
|
| + set_context_menu_controller(context_menu_controller_.get()); |
|
stevenjb
2013/12/12 21:19:46
This should be:
set_context_menu_controller(new No
|
| + |
| std::vector<string16> accessible_lines; |
| // Create the opaque background that's above the view's shadow. |
| @@ -808,14 +859,6 @@ void NotificationView::RemoveNotification(bool by_user) { |
| message_center_->RemoveNotification(notification_id_, by_user); |
| } |
| -void NotificationView::DisableNotificationsFromThisSource() { |
| - message_center_->DisableNotificationsByNotifier(notifier_id_); |
| -} |
| - |
| -void NotificationView::ShowNotifierSettingsBubble() { |
| - tray_->ShowNotifierSettingsBubble(); |
| -} |
| - |
| bool NotificationView::IsExpansionNeeded(int width) { |
| return (!is_expanded_ && |
| (image_view_ || |