Remove unused parameter.
[chromium-blink-merge.git] / ui / message_center / views / notification_view.h
blob38821ff7fb4d81f1f659311ddcaf36c81f38bbdd
1 // Copyright (c) 2012 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_NOTIFICATION_VIEW_H_
6 #define UI_MESSAGE_CENTER_VIEWS_NOTIFICATION_VIEW_H_
8 #include <vector>
10 #include "ui/message_center/message_center_export.h"
11 #include "ui/message_center/views/message_view.h"
12 #include "ui/views/view_targeter_delegate.h"
14 namespace views {
15 class ProgressBar;
18 namespace message_center {
20 class BoundedLabel;
21 class MessageCenter;
22 class MessageCenterController;
23 class NotificationButton;
24 class NotificationView;
25 class PaddedButton;
27 // View that displays all current types of notification (web, basic, image, and
28 // list). Future notification types may be handled by other classes, in which
29 // case instances of those classes would be returned by the Create() factory
30 // method below.
31 class MESSAGE_CENTER_EXPORT NotificationView
32 : public MessageView,
33 public views::ViewTargeterDelegate,
34 public MessageViewController {
35 public:
36 // Creates appropriate MessageViews for notifications. Those currently are
37 // always NotificationView instances but in the future
38 // may be instances of other classes, with the class depending on the
39 // notification type. A notification is top level if it needs to be rendered
40 // outside the browser window. No custom shadows are created for top level
41 // notifications on Linux with Aura.
42 // |controller| may be NULL, but has to be set before the view is shown.
43 static NotificationView* Create(MessageCenterController* controller,
44 const Notification& notification,
45 bool top_level);
46 ~NotificationView() override;
48 // Overridden from views::View:
49 gfx::Size GetPreferredSize() const override;
50 int GetHeightForWidth(int width) const override;
51 void Layout() override;
52 void OnFocus() override;
53 void ScrollRectToVisible(const gfx::Rect& rect) override;
54 gfx::NativeCursor GetCursor(const ui::MouseEvent& event) override;
56 // Overridden from MessageView:
57 void UpdateWithNotification(const Notification& notification) override;
58 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
60 // Overridden from MessageViewController:
61 void ClickOnNotification(const std::string& notification_id) override;
62 void RemoveNotification(const std::string& notification_id,
63 bool by_user) override;
65 void set_controller(MessageCenterController* controller) {
66 controller_ = controller;
69 protected:
70 NotificationView(MessageCenterController* controller,
71 const Notification& notification);
73 private:
74 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, CreateOrUpdateTest);
75 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, TestLineLimits);
76 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, UpdateButtonsStateTest);
77 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, UpdateButtonCountTest);
79 friend class NotificationViewTest;
81 // views::ViewTargeterDelegate:
82 views::View* TargetForRect(views::View* root, const gfx::Rect& rect) override;
84 void CreateOrUpdateViews(const Notification& notification);
85 void SetAccessibleName(const Notification& notification);
87 void CreateOrUpdateTitleView(const Notification& notification);
88 void CreateOrUpdateMessageView(const Notification& notification);
89 void CreateOrUpdateContextMessageView(const Notification& notification);
90 void CreateOrUpdateProgressBarView(const Notification& notification);
91 void CreateOrUpdateListItemViews(const Notification& notification);
92 void CreateOrUpdateIconView(const Notification& notification);
93 void CreateOrUpdateImageView(const Notification& notification);
94 void CreateOrUpdateActionButtonViews(const Notification& notification);
96 int GetMessageLineLimit(int title_lines, int width) const;
97 int GetMessageHeight(int width, int limit) const;
99 MessageCenterController* controller_; // Weak, lives longer then views.
101 // Describes whether the view should display a hand pointer or not.
102 bool clickable_;
104 // Weak references to NotificationView descendants owned by their parents.
105 views::View* top_view_;
106 BoundedLabel* title_view_;
107 BoundedLabel* message_view_;
108 BoundedLabel* context_message_view_;
109 std::vector<views::View*> item_views_;
110 views::View* icon_view_;
111 views::View* bottom_view_;
112 views::View* image_view_;
113 views::ProgressBar* progress_bar_view_;
114 std::vector<NotificationButton*> action_buttons_;
115 std::vector<views::View*> separators_;
117 DISALLOW_COPY_AND_ASSIGN(NotificationView);
120 } // namespace message_center
122 #endif // UI_MESSAGE_CENTER_VIEWS_NOTIFICATION_VIEW_H_