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/controls/button/button.h"
16 #include "ui/views/view.h"
26 namespace message_center
{
29 class MessageCenterBubble
;
30 class NotificationCenterButton
;
31 class MessageCenterButtonBar
;
32 class MessageCenterTray
;
33 class MessageCenterView
;
35 class MessageViewContextMenuController
;
36 class MessageListView
;
37 class NotificationView
;
38 class NotifierSettingsView
;
40 // MessageCenterView ///////////////////////////////////////////////////////////
42 class MESSAGE_CENTER_EXPORT MessageCenterView
: public views::View
,
43 public MessageCenterObserver
,
44 public MessageCenterController
,
45 public gfx::AnimationDelegate
{
47 MessageCenterView(MessageCenter
* message_center
,
48 MessageCenterTray
* tray
,
50 bool initially_settings_visible
,
52 const base::string16
& title
);
53 ~MessageCenterView() override
;
55 void SetNotifications(const NotificationList::Notifications
& notifications
);
57 void ClearAllNotifications();
58 void OnAllNotificationsCleared();
60 size_t NumMessageViewsForTest() const;
62 void SetSettingsVisible(bool visible
);
63 void OnSettingsChanged();
64 bool settings_visible() const { return settings_visible_
; }
65 MessageCenterTray
* tray() { return tray_
; }
67 void SetIsClosing(bool is_closing
);
70 // Overridden from views::View:
71 void Layout() override
;
72 gfx::Size
GetPreferredSize() const override
;
73 int GetHeightForWidth(int width
) const override
;
74 bool OnMouseWheel(const ui::MouseWheelEvent
& event
) override
;
75 void OnMouseExited(const ui::MouseEvent
& event
) override
;
77 // Overridden from MessageCenterObserver:
78 void OnNotificationAdded(const std::string
& id
) override
;
79 void OnNotificationRemoved(const std::string
& id
, bool by_user
) override
;
80 void OnNotificationUpdated(const std::string
& id
) override
;
82 // Overridden from MessageCenterController:
83 void ClickOnNotification(const std::string
& notification_id
) override
;
84 void RemoveNotification(const std::string
& notification_id
,
85 bool by_user
) override
;
86 scoped_ptr
<ui::MenuModel
> CreateMenuModel(
87 const NotifierId
& notifier_id
,
88 const base::string16
& display_source
) override
;
89 bool HasClickedListener(const std::string
& notification_id
) override
;
90 void ClickOnNotificationButton(const std::string
& notification_id
,
91 int button_index
) override
;
93 // Overridden from gfx::AnimationDelegate:
94 void AnimationEnded(const gfx::Animation
* animation
) override
;
95 void AnimationProgressed(const gfx::Animation
* animation
) override
;
96 void AnimationCanceled(const gfx::Animation
* animation
) override
;
99 friend class MessageCenterViewTest
;
101 void AddNotificationAt(const Notification
& notification
, int index
);
102 void NotificationsChanged();
103 void SetNotificationViewForTest(MessageView
* view
);
105 MessageCenter
* message_center_
; // Weak reference.
106 MessageCenterTray
* tray_
; // Weak reference.
108 // Map notification_id->NotificationView*. It contains all NotificationViews
109 // currently displayed in MessageCenter.
110 typedef std::map
<std::string
, NotificationView
*> NotificationViewsMap
;
111 NotificationViewsMap notification_views_
; // Weak.
114 views::ScrollView
* scroller_
;
115 scoped_ptr
<MessageListView
> message_list_view_
;
116 scoped_ptr
<views::View
> empty_list_view_
;
117 NotifierSettingsView
* settings_view_
;
118 MessageCenterButtonBar
* button_bar_
;
121 // Data for transition animation between settings view and message list.
122 bool settings_visible_
;
124 // Animation managing transition between message center and settings (and vice
126 scoped_ptr
<gfx::MultiAnimation
> settings_transition_animation_
;
128 // Helper data to keep track of the transition between settings and
129 // message center views.
130 views::View
* source_view_
;
132 views::View
* target_view_
;
135 // True when the widget is closing so that further operations should be
139 scoped_ptr
<MessageViewContextMenuController
> context_menu_controller_
;
141 DISALLOW_COPY_AND_ASSIGN(MessageCenterView
);
144 } // namespace message_center
146 #endif // UI_MESSAGE_CENTER_VIEWS_MESSAGE_CENTER_VIEW_H_