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

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

Issue 2966063003: Reland of Use shared NotificationControlButtonsView for non-arc notification buttons (Closed)
Patch Set: Created 3 years, 5 months 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
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" 14 #include "ui/views/controls/button/button.h"
15 #include "ui/views/controls/button/image_button.h" 15 #include "ui/views/controls/button/image_button.h"
16 #include "ui/views/view_targeter_delegate.h" 16 #include "ui/views/view_targeter_delegate.h"
17 17
18 namespace views { 18 namespace views {
19 class ImageView; 19 class ImageView;
20 class ProgressBar; 20 class ProgressBar;
21 } 21 }
22 22
23 namespace message_center { 23 namespace message_center {
24 24
25 class BoundedLabel; 25 class BoundedLabel;
26 class NotificationButton; 26 class NotificationButton;
27 class NotificationControlButtonsView;
27 class ProportionalImageView; 28 class ProportionalImageView;
28 29
29 // View that displays all current types of notification (web, basic, image, and 30 // View that displays all current types of notification (web, basic, image, and
30 // list) except the custom notification. Future notification types may be 31 // list) except the custom notification. Future notification types may be
31 // handled by other classes, in which case instances of those classes would be 32 // handled by other classes, in which case instances of those classes would be
32 // returned by the Create() factory method below. 33 // returned by the Create() factory method below.
33 class MESSAGE_CENTER_EXPORT NotificationView 34 class MESSAGE_CENTER_EXPORT NotificationView
34 : public MessageView, 35 : public MessageView,
35 public views::ButtonListener, 36 public views::ButtonListener,
36 public views::ViewTargeterDelegate { 37 public views::ViewTargeterDelegate {
(...skipping 13 matching lines...) Expand all
50 void OnMouseEntered(const ui::MouseEvent& event) override; 51 void OnMouseEntered(const ui::MouseEvent& event) override;
51 void OnMouseExited(const ui::MouseEvent& event) override; 52 void OnMouseExited(const ui::MouseEvent& event) override;
52 53
53 // Overridden from MessageView: 54 // Overridden from MessageView:
54 void UpdateWithNotification(const Notification& notification) override; 55 void UpdateWithNotification(const Notification& notification) override;
55 void ButtonPressed(views::Button* sender, const ui::Event& event) override; 56 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
56 bool IsCloseButtonFocused() const override; 57 bool IsCloseButtonFocused() const override;
57 void RequestFocusOnCloseButton() override; 58 void RequestFocusOnCloseButton() override;
58 void UpdateControlButtonsVisibility() override; 59 void UpdateControlButtonsVisibility() override;
59 60
60 protected:
61 views::ImageButton* close_button() { return close_button_.get(); }
62
63 private: 61 private:
64 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, CreateOrUpdateTest); 62 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, CreateOrUpdateTest);
65 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, 63 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest,
66 CreateOrUpdateTestSettingsButton); 64 CreateOrUpdateTestSettingsButton);
67 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, FormatContextMessageTest); 65 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, FormatContextMessageTest);
68 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, SettingsButtonTest); 66 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, SettingsButtonTest);
69 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, TestLineLimits); 67 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, TestLineLimits);
70 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, TestIconSizing); 68 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, TestIconSizing);
71 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, TestImageSizing); 69 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, TestImageSizing);
72 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, UpdateButtonsStateTest); 70 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, UpdateButtonsStateTest);
73 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, UpdateButtonCountTest); 71 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, UpdateButtonCountTest);
74 72
75 friend class NotificationViewTest; 73 friend class NotificationViewTest;
76 74
77 // views::ViewTargeterDelegate:
78 views::View* TargetForRect(views::View* root, const gfx::Rect& rect) override;
79
80 void CreateOrUpdateViews(const Notification& notification); 75 void CreateOrUpdateViews(const Notification& notification);
81 76
82 void CreateOrUpdateTitleView(const Notification& notification); 77 void CreateOrUpdateTitleView(const Notification& notification);
83 void CreateOrUpdateMessageView(const Notification& notification); 78 void CreateOrUpdateMessageView(const Notification& notification);
84 void CreateOrUpdateContextMessageView(const Notification& notification); 79 void CreateOrUpdateContextMessageView(const Notification& notification);
85 void CreateOrUpdateSettingsButtonView(const Notification& notification);
86 void CreateOrUpdateProgressBarView(const Notification& notification); 80 void CreateOrUpdateProgressBarView(const Notification& notification);
87 void CreateOrUpdateListItemViews(const Notification& notification); 81 void CreateOrUpdateListItemViews(const Notification& notification);
88 void CreateOrUpdateIconView(const Notification& notification); 82 void CreateOrUpdateIconView(const Notification& notification);
89 void CreateOrUpdateSmallIconView(const Notification& notification); 83 void CreateOrUpdateSmallIconView(const Notification& notification);
90 void CreateOrUpdateImageView(const Notification& notification); 84 void CreateOrUpdateImageView(const Notification& notification);
91 void CreateOrUpdateActionButtonViews(const Notification& notification); 85 void CreateOrUpdateActionButtonViews(const Notification& notification);
92 void CreateOrUpdateCloseButtonView(const Notification& notification); 86 void UpdateControlButtonsVisibilityWithNotification(
87 const Notification& notification);
93 88
94 int GetMessageLineLimit(int title_lines, int width) const; 89 int GetMessageLineLimit(int title_lines, int width) const;
95 int GetMessageHeight(int width, int limit) const; 90 int GetMessageHeight(int width, int limit) const;
96 91
97 // Formats the context message to be displayed based on |context| 92 // Formats the context message to be displayed based on |context|
98 // so it shows as much information as possible 93 // so it shows as much information as possible
99 // given the space available in the ContextMessage section of the 94 // given the space available in the ContextMessage section of the
100 // notification. 95 // notification.
101 base::string16 FormatContextMessage(const Notification& notification) const; 96 base::string16 FormatContextMessage(const Notification& notification) const;
102 97
103 // Describes whether the view should display a hand pointer or not. 98 // Describes whether the view should display a hand pointer or not.
104 bool clickable_; 99 bool clickable_;
105 100
106 // Weak references to NotificationView descendants owned by their parents. 101 // Weak references to NotificationView descendants owned by their parents.
107 views::View* top_view_ = nullptr; 102 views::View* top_view_ = nullptr;
108 BoundedLabel* title_view_ = nullptr; 103 BoundedLabel* title_view_ = nullptr;
109 BoundedLabel* message_view_ = nullptr; 104 BoundedLabel* message_view_ = nullptr;
110 BoundedLabel* context_message_view_ = nullptr; 105 BoundedLabel* context_message_view_ = nullptr;
111 views::ImageButton* settings_button_view_ = nullptr;
112 std::vector<views::View*> item_views_; 106 std::vector<views::View*> item_views_;
113 ProportionalImageView* icon_view_ = nullptr; 107 ProportionalImageView* icon_view_ = nullptr;
114 views::View* bottom_view_ = nullptr; 108 views::View* bottom_view_ = nullptr;
115 views::View* image_container_ = nullptr; 109 views::View* image_container_ = nullptr;
116 ProportionalImageView* image_view_ = nullptr; 110 ProportionalImageView* image_view_ = nullptr;
117 views::ProgressBar* progress_bar_view_ = nullptr; 111 views::ProgressBar* progress_bar_view_ = nullptr;
118 std::vector<NotificationButton*> action_buttons_; 112 std::vector<NotificationButton*> action_buttons_;
119 std::vector<views::View*> separators_; 113 std::vector<views::View*> separators_;
120 std::unique_ptr<views::ImageButton> close_button_ = nullptr;
121 std::unique_ptr<views::ImageView> small_image_view_; 114 std::unique_ptr<views::ImageView> small_image_view_;
115 NotificationControlButtonsView* control_buttons_view_;
122 116
123 DISALLOW_COPY_AND_ASSIGN(NotificationView); 117 DISALLOW_COPY_AND_ASSIGN(NotificationView);
124 }; 118 };
125 119
126 } // namespace message_center 120 } // namespace message_center
127 121
128 #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/notification_control_buttons_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