1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef UI_MESSAGE_CENTER_VIEWS_MESSAGE_CENTER_VIEW_H_
6 #define UI_MESSAGE_CENTER_VIEWS_MESSAGE_CENTER_VIEW_H_
9 #include "ui/gfx/animation/animation_delegate.h"
10 #include "ui/message_center/message_center_export.h"
11 #include "ui/message_center/message_center_observer.h"
12 #include "ui/message_center/notification_list.h"
13 #include "ui/message_center/views/message_center_controller.h"
14 #include "ui/message_center/views/message_view.h"
15 #include "ui/views/view.h"
21 namespace message_center
{
24 class MessageCenterButtonBar
;
25 class MessageCenterTray
;
27 class MessageViewContextMenuController
;
28 class MessageListView
;
29 class NotificationView
;
30 class NotifierSettingsView
;
32 // Container for all the top-level views in the notification center, such as the
33 // button bar, settings view, scrol view, and message list view. Acts as a
34 // controller for the message list view, passing data back and forth to message
36 class MESSAGE_CENTER_EXPORT MessageCenterView
: public views::View
,
37 public MessageCenterObserver
,
38 public MessageCenterController
,
39 public gfx::AnimationDelegate
{
41 MessageCenterView(MessageCenter
* message_center
,
42 MessageCenterTray
* tray
,
44 bool initially_settings_visible
,
46 const base::string16
& title
);
47 ~MessageCenterView() override
;
49 void SetNotifications(const NotificationList::Notifications
& notifications
);
51 void ClearAllNotifications();
52 void OnAllNotificationsCleared();
54 size_t NumMessageViewsForTest() const;
56 void SetSettingsVisible(bool visible
);
57 void OnSettingsChanged();
58 bool settings_visible() const { return settings_visible_
; }
59 MessageCenterTray
* tray() { return tray_
; }
61 void SetIsClosing(bool is_closing
);
64 // Overridden from views::View:
65 void Layout() override
;
66 gfx::Size
GetPreferredSize() const override
;
67 int GetHeightForWidth(int width
) const override
;
68 bool OnMouseWheel(const ui::MouseWheelEvent
& event
) override
;
69 void OnMouseExited(const ui::MouseEvent
& event
) override
;
71 // Overridden from MessageCenterObserver:
72 void OnNotificationAdded(const std::string
& id
) override
;
73 void OnNotificationRemoved(const std::string
& id
, bool by_user
) override
;
74 void OnNotificationUpdated(const std::string
& id
) override
;
76 // Overridden from MessageCenterController:
77 void ClickOnNotification(const std::string
& notification_id
) override
;
78 void RemoveNotification(const std::string
& notification_id
,
79 bool by_user
) override
;
80 scoped_ptr
<ui::MenuModel
> CreateMenuModel(
81 const NotifierId
& notifier_id
,
82 const base::string16
& display_source
) override
;
83 bool HasClickedListener(const std::string
& notification_id
) override
;
84 void ClickOnNotificationButton(const std::string
& notification_id
,
85 int button_index
) override
;
87 // Overridden from gfx::AnimationDelegate:
88 void AnimationEnded(const gfx::Animation
* animation
) override
;
89 void AnimationProgressed(const gfx::Animation
* animation
) override
;
90 void AnimationCanceled(const gfx::Animation
* animation
) override
;
93 friend class MessageCenterViewTest
;
95 void AddNotificationAt(const Notification
& notification
, int index
);
96 void NotificationsChanged();
97 void SetNotificationViewForTest(MessageView
* view
);
99 MessageCenter
* message_center_
; // Weak reference.
100 MessageCenterTray
* tray_
; // Weak reference.
102 // Map notification_id->NotificationView*. It contains all NotificationViews
103 // currently displayed in MessageCenter.
104 typedef std::map
<std::string
, NotificationView
*> NotificationViewsMap
;
105 NotificationViewsMap notification_views_
; // Weak.
108 views::ScrollView
* scroller_
;
109 scoped_ptr
<MessageListView
> message_list_view_
;
110 scoped_ptr
<views::View
> empty_list_view_
;
111 NotifierSettingsView
* settings_view_
;
112 MessageCenterButtonBar
* button_bar_
;
115 // Data for transition animation between settings view and message list.
116 bool settings_visible_
;
118 // Animation managing transition between message center and settings (and vice
120 scoped_ptr
<gfx::MultiAnimation
> settings_transition_animation_
;
122 // Helper data to keep track of the transition between settings and
123 // message center views.
124 views::View
* source_view_
;
126 views::View
* target_view_
;
129 // True when the widget is closing so that further operations should be
133 scoped_ptr
<MessageViewContextMenuController
> context_menu_controller_
;
135 DISALLOW_COPY_AND_ASSIGN(MessageCenterView
);
138 } // namespace message_center
140 #endif // UI_MESSAGE_CENTER_VIEWS_MESSAGE_CENTER_VIEW_H_