Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(252)

Side by Side Diff: ui/message_center/views/notification_view.h

Issue 2547433002: Transfer responsibility for providing a close button for a notification to each implementation of M… (Closed)
Patch Set: WrapUnique -> MakeUnique Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/message_center/views/message_view.cc ('k') | ui/message_center/views/notification_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_MESSAGE_CENTER_VIEWS_NOTIFICATION_VIEW_H_ 5 #ifndef UI_MESSAGE_CENTER_VIEWS_NOTIFICATION_VIEW_H_
6 #define UI_MESSAGE_CENTER_VIEWS_NOTIFICATION_VIEW_H_ 6 #define UI_MESSAGE_CENTER_VIEWS_NOTIFICATION_VIEW_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/gtest_prod_util.h" 10 #include "base/gtest_prod_util.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "ui/message_center/message_center_export.h" 12 #include "ui/message_center/message_center_export.h"
13 #include "ui/message_center/views/message_view.h" 13 #include "ui/message_center/views/message_view.h"
14 #include "ui/views/controls/button/button.h"
15 #include "ui/views/controls/button/image_button.h"
14 #include "ui/views/view_targeter_delegate.h" 16 #include "ui/views/view_targeter_delegate.h"
15 17
16 namespace views { 18 namespace views {
17 class ProgressBar; 19 class ProgressBar;
18 } 20 }
19 21
20 namespace message_center { 22 namespace message_center {
21 23
22 class BoundedLabel; 24 class BoundedLabel;
23 class NotificationButton; 25 class NotificationButton;
24 class ProportionalImageView; 26 class ProportionalImageView;
25 27
26 // View that displays all current types of notification (web, basic, image, and 28 // View that displays all current types of notification (web, basic, image, and
27 // list) except the custom notification. Future notification types may be 29 // list) except the custom notification. Future notification types may be
28 // handled by other classes, in which case instances of those classes would be 30 // handled by other classes, in which case instances of those classes would be
29 // returned by the Create() factory method below. 31 // returned by the Create() factory method below.
30 class MESSAGE_CENTER_EXPORT NotificationView 32 class MESSAGE_CENTER_EXPORT NotificationView
31 : public MessageView, 33 : public MessageView,
34 public views::ButtonListener,
32 public views::ViewTargeterDelegate { 35 public views::ViewTargeterDelegate {
33 public: 36 public:
34 NotificationView(MessageCenterController* controller, 37 NotificationView(MessageCenterController* controller,
35 const Notification& notification); 38 const Notification& notification);
36 ~NotificationView() override; 39 ~NotificationView() override;
37 40
38 // Overridden from views::View: 41 // Overridden from views::View:
39 gfx::Size GetPreferredSize() const override; 42 gfx::Size GetPreferredSize() const override;
40 int GetHeightForWidth(int width) const override; 43 int GetHeightForWidth(int width) const override;
41 void Layout() override; 44 void Layout() override;
42 void OnFocus() override; 45 void OnFocus() override;
43 void ScrollRectToVisible(const gfx::Rect& rect) override; 46 void ScrollRectToVisible(const gfx::Rect& rect) override;
44 gfx::NativeCursor GetCursor(const ui::MouseEvent& event) override; 47 gfx::NativeCursor GetCursor(const ui::MouseEvent& event) override;
45 48
46 // Overridden from MessageView: 49 // Overridden from MessageView:
47 void UpdateWithNotification(const Notification& notification) override; 50 void UpdateWithNotification(const Notification& notification) override;
48 void ButtonPressed(views::Button* sender, const ui::Event& event) override; 51 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
52 bool IsCloseButtonFocused() const override;
53 void RequestFocusOnCloseButton() override;
54 bool IsPinned() const override;
55
56 protected:
57 views::ImageButton* close_button() { return close_button_.get(); }
49 58
50 private: 59 private:
51 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, CreateOrUpdateTest); 60 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, CreateOrUpdateTest);
52 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, 61 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest,
53 CreateOrUpdateTestSettingsButton); 62 CreateOrUpdateTestSettingsButton);
54 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, FormatContextMessageTest); 63 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, FormatContextMessageTest);
55 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, SettingsButtonTest); 64 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, SettingsButtonTest);
56 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, TestLineLimits); 65 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, TestLineLimits);
57 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, TestIconSizing); 66 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, TestIconSizing);
58 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, TestImageSizing); 67 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, TestImageSizing);
59 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, UpdateButtonsStateTest); 68 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, UpdateButtonsStateTest);
60 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, UpdateButtonCountTest); 69 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, UpdateButtonCountTest);
61 70
62 friend class NotificationViewTest; 71 friend class NotificationViewTest;
63 72
64 // views::ViewTargeterDelegate: 73 // views::ViewTargeterDelegate:
65 views::View* TargetForRect(views::View* root, const gfx::Rect& rect) override; 74 views::View* TargetForRect(views::View* root, const gfx::Rect& rect) override;
66 75
67 void CreateOrUpdateViews(const Notification& notification); 76 void CreateOrUpdateViews(const Notification& notification);
68 77
69 void CreateOrUpdateTitleView(const Notification& notification); 78 void CreateOrUpdateTitleView(const Notification& notification);
70 void CreateOrUpdateMessageView(const Notification& notification); 79 void CreateOrUpdateMessageView(const Notification& notification);
71 void CreateOrUpdateContextMessageView(const Notification& notification); 80 void CreateOrUpdateContextMessageView(const Notification& notification);
72 void CreateOrUpdateSettingsButtonView(const Notification& notification); 81 void CreateOrUpdateSettingsButtonView(const Notification& notification);
73 void CreateOrUpdateProgressBarView(const Notification& notification); 82 void CreateOrUpdateProgressBarView(const Notification& notification);
74 void CreateOrUpdateListItemViews(const Notification& notification); 83 void CreateOrUpdateListItemViews(const Notification& notification);
75 void CreateOrUpdateIconView(const Notification& notification); 84 void CreateOrUpdateIconView(const Notification& notification);
76 void CreateOrUpdateImageView(const Notification& notification); 85 void CreateOrUpdateImageView(const Notification& notification);
77 void CreateOrUpdateActionButtonViews(const Notification& notification); 86 void CreateOrUpdateActionButtonViews(const Notification& notification);
87 void CreateOrUpdateCloseButtonView(const Notification& notification);
78 88
79 int GetMessageLineLimit(int title_lines, int width) const; 89 int GetMessageLineLimit(int title_lines, int width) const;
80 int GetMessageHeight(int width, int limit) const; 90 int GetMessageHeight(int width, int limit) const;
81 91
82 // Formats the context message to be displayed based on |context| 92 // Formats the context message to be displayed based on |context|
83 // so it shows as much information as possible 93 // so it shows as much information as possible
84 // given the space available in the ContextMessage section of the 94 // given the space available in the ContextMessage section of the
85 // notification. 95 // notification.
86 base::string16 FormatContextMessage(const Notification& notification) const; 96 base::string16 FormatContextMessage(const Notification& notification) const;
87 97
88 // Describes whether the view should display a hand pointer or not. 98 // Describes whether the view should display a hand pointer or not.
89 bool clickable_; 99 bool clickable_;
90 100
91 // Weak references to NotificationView descendants owned by their parents. 101 // Weak references to NotificationView descendants owned by their parents.
92 views::View* top_view_ = nullptr; 102 views::View* top_view_ = nullptr;
93 BoundedLabel* title_view_ = nullptr; 103 BoundedLabel* title_view_ = nullptr;
94 BoundedLabel* message_view_ = nullptr; 104 BoundedLabel* message_view_ = nullptr;
95 BoundedLabel* context_message_view_ = nullptr; 105 BoundedLabel* context_message_view_ = nullptr;
96 views::ImageButton* settings_button_view_ = nullptr; 106 views::ImageButton* settings_button_view_ = nullptr;
97 std::vector<views::View*> item_views_; 107 std::vector<views::View*> item_views_;
98 ProportionalImageView* icon_view_ = nullptr; 108 ProportionalImageView* icon_view_ = nullptr;
99 views::View* bottom_view_ = nullptr; 109 views::View* bottom_view_ = nullptr;
100 views::View* image_container_ = nullptr; 110 views::View* image_container_ = nullptr;
101 ProportionalImageView* image_view_ = nullptr; 111 ProportionalImageView* image_view_ = nullptr;
102 views::ProgressBar* progress_bar_view_ = nullptr; 112 views::ProgressBar* progress_bar_view_ = nullptr;
103 std::vector<NotificationButton*> action_buttons_; 113 std::vector<NotificationButton*> action_buttons_;
104 std::vector<views::View*> separators_; 114 std::vector<views::View*> separators_;
115 std::unique_ptr<views::ImageButton> close_button_ = nullptr;
105 116
106 DISALLOW_COPY_AND_ASSIGN(NotificationView); 117 DISALLOW_COPY_AND_ASSIGN(NotificationView);
107 }; 118 };
108 119
109 } // namespace message_center 120 } // namespace message_center
110 121
111 #endif // UI_MESSAGE_CENTER_VIEWS_NOTIFICATION_VIEW_H_ 122 #endif // UI_MESSAGE_CENTER_VIEWS_NOTIFICATION_VIEW_H_
OLDNEW
« no previous file with comments | « ui/message_center/views/message_view.cc ('k') | ui/message_center/views/notification_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698