Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / ui / message_center / views / message_center_view.h
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.
4
5 #ifndef UI_MESSAGE_CENTER_VIEWS_MESSAGE_CENTER_VIEW_H_
6 #define UI_MESSAGE_CENTER_VIEWS_MESSAGE_CENTER_VIEW_H_
7
8
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"
17
18 namespace gfx {
19 class MultiAnimation;
20 }  // namespace gfx
21
22 namespace views {
23 class Button;
24 }  // namespace views
25
26 namespace message_center {
27
28 class MessageCenter;
29 class MessageCenterBubble;
30 class NotificationCenterButton;
31 class MessageCenterButtonBar;
32 class MessageCenterTray;
33 class MessageCenterView;
34 class MessageView;
35 class MessageViewContextMenuController;
36 class MessageListView;
37 class NotificationView;
38 class NotifierSettingsView;
39
40 // MessageCenterView ///////////////////////////////////////////////////////////
41
42 class MESSAGE_CENTER_EXPORT MessageCenterView : public views::View,
43                                                 public MessageCenterObserver,
44                                                 public MessageCenterController,
45                                                 public gfx::AnimationDelegate {
46  public:
47   MessageCenterView(MessageCenter* message_center,
48                     MessageCenterTray* tray,
49                     int max_height,
50                     bool initially_settings_visible,
51                     bool top_down);
52   virtual ~MessageCenterView();
53
54   void SetNotifications(const NotificationList::Notifications& notifications);
55
56   void ClearAllNotifications();
57   void OnAllNotificationsCleared();
58
59   size_t NumMessageViewsForTest() const;
60
61   void SetSettingsVisible(bool visible);
62   void OnSettingsChanged();
63   bool settings_visible() const { return settings_visible_; }
64
65   void SetIsClosing(bool is_closing);
66
67  protected:
68   // Overridden from views::View:
69   virtual void Layout() OVERRIDE;
70   virtual gfx::Size GetPreferredSize() OVERRIDE;
71   virtual int GetHeightForWidth(int width) OVERRIDE;
72   virtual bool OnMouseWheel(const ui::MouseWheelEvent& event) OVERRIDE;
73   virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE;
74
75   // Overridden from MessageCenterObserver:
76   virtual void OnNotificationAdded(const std::string& id) OVERRIDE;
77   virtual void OnNotificationRemoved(const std::string& id,
78                                      bool by_user) OVERRIDE;
79   virtual void OnNotificationUpdated(const std::string& id) OVERRIDE;
80
81   // Overridden from MessageCenterController:
82   virtual void ClickOnNotification(const std::string& notification_id) OVERRIDE;
83   virtual void RemoveNotification(const std::string& notification_id,
84                                   bool by_user) OVERRIDE;
85   virtual scoped_ptr<ui::MenuModel> CreateMenuModel(
86       const NotifierId& notifier_id,
87       const base::string16& display_source) OVERRIDE;
88   virtual bool HasClickedListener(const std::string& notification_id) OVERRIDE;
89   virtual void ClickOnNotificationButton(const std::string& notification_id,
90                                          int button_index) OVERRIDE;
91
92   // Overridden from gfx::AnimationDelegate:
93   virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE;
94   virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE;
95   virtual void AnimationCanceled(const gfx::Animation* animation) OVERRIDE;
96
97  private:
98   friend class MessageCenterViewTest;
99
100   void AddNotificationAt(const Notification& notification, int index);
101   void NotificationsChanged();
102   void SetNotificationViewForTest(MessageView* view);
103
104   MessageCenter* message_center_;  // Weak reference.
105   MessageCenterTray* tray_;  // Weak reference.
106
107   // Map notification_id->NotificationView*. It contains all NotificaitonViews
108   // currently displayed in MessageCenter.
109   typedef std::map<std::string, NotificationView*> NotificationViewsMap;
110   NotificationViewsMap notification_views_;  // Weak.
111
112   // Child views.
113   views::ScrollView* scroller_;
114   scoped_ptr<MessageListView> message_list_view_;
115   scoped_ptr<views::View> empty_list_view_;
116   NotifierSettingsView* settings_view_;
117   MessageCenterButtonBar* button_bar_;
118   bool top_down_;
119
120   // Data for transition animation between settings view and message list.
121   bool settings_visible_;
122
123   // Animation managing transition between message center and settings (and vice
124   // versa).
125   scoped_ptr<gfx::MultiAnimation> settings_transition_animation_;
126
127   // Helper data to keep track of the transition between settings and
128   // message center views.
129   views::View* source_view_;
130   int source_height_;
131   views::View* target_view_;
132   int target_height_;
133
134   // True when the widget is closing so that further operations should be
135   // ignored.
136   bool is_closing_;
137
138   scoped_ptr<MessageViewContextMenuController> context_menu_controller_;
139
140   DISALLOW_COPY_AND_ASSIGN(MessageCenterView);
141 };
142
143 }  // namespace message_center
144
145 #endif  // UI_MESSAGE_CENTER_VIEWS_MESSAGE_CENTER_VIEW_H_