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

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

Issue 75133006: Move knowledge about MessageCenter out of MessageView. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more fix Created 7 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 | Annotate | Revision Log
« 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 "ui/message_center/message_center_export.h" 10 #include "ui/message_center/message_center_export.h"
11 #include "ui/message_center/views/message_view.h" 11 #include "ui/message_center/views/message_view.h"
12 12
13 namespace views { 13 namespace views {
14 class ProgressBar; 14 class ProgressBar;
15 } 15 }
16 16
17 namespace message_center { 17 namespace message_center {
18 18
19 class BoundedLabel; 19 class BoundedLabel;
20 class MessageCenter; 20 class MessageCenter;
21 class NotificationView;
21 class PaddedButton; 22 class PaddedButton;
22 23
23 // View that displays all current types of notification (web, basic, image, and 24 // View that displays all current types of notification (web, basic, image, and
24 // list). Future notification types may be handled by other classes, in which 25 // list). Future notification types may be handled by other classes, in which
25 // case instances of those classes would be returned by the Create() factory 26 // case instances of those classes would be returned by the Create() factory
26 // method below. 27 // method below.
27 class MESSAGE_CENTER_EXPORT NotificationView : public MessageView { 28 class MESSAGE_CENTER_EXPORT NotificationView : public MessageView {
28 public: 29 public:
29 // Creates appropriate MessageViews for notifications. Those currently are 30 // Creates appropriate MessageViews for notifications. Those currently are
30 // always NotificationView instances but in the future 31 // always NotificationView instances but in the future
31 // may be instances of other classes, with the class depending on the 32 // may be instances of other classes, with the class depending on the
32 // notification type. A notification is top level if it needs to be rendered 33 // notification type. A notification is top level if it needs to be rendered
33 // outside the browser window. No custom shadows are created for top level 34 // outside the browser window. No custom shadows are created for top level
34 // notifications on Linux with Aura. 35 // notifications on Linux with Aura.
35 static MessageView* Create(const Notification& notification, 36 static NotificationView* Create(const Notification& notification,
36 MessageCenter* message_center, 37 MessageCenter* message_center,
37 MessageCenterTray* tray, 38 MessageCenterTray* tray,
38 bool expanded, 39 bool expanded,
39 bool top_level); 40 bool top_level);
40 41
41 virtual ~NotificationView(); 42 virtual ~NotificationView();
42 43
43 // Overridden from views::View: 44 // Overridden from views::View:
44 virtual gfx::Size GetPreferredSize() OVERRIDE; 45 virtual gfx::Size GetPreferredSize() OVERRIDE;
45 virtual int GetHeightForWidth(int width) OVERRIDE; 46 virtual int GetHeightForWidth(int width) OVERRIDE;
46 virtual void Layout() OVERRIDE; 47 virtual void Layout() OVERRIDE;
47 virtual void OnFocus() OVERRIDE; 48 virtual void OnFocus() OVERRIDE;
48 virtual void ScrollRectToVisible(const gfx::Rect& rect) OVERRIDE; 49 virtual void ScrollRectToVisible(const gfx::Rect& rect) OVERRIDE;
49 virtual views::View* GetEventHandlerForRect(const gfx::Rect& rect) OVERRIDE; 50 virtual views::View* GetEventHandlerForRect(const gfx::Rect& rect) OVERRIDE;
50 virtual gfx::NativeCursor GetCursor(const ui::MouseEvent& event) OVERRIDE; 51 virtual gfx::NativeCursor GetCursor(const ui::MouseEvent& event) OVERRIDE;
51 52
52 // Overridden from MessageView: 53 // Overridden from MessageView:
53 virtual void ButtonPressed(views::Button* sender, 54 virtual void ButtonPressed(views::Button* sender,
54 const ui::Event& event) OVERRIDE; 55 const ui::Event& event) OVERRIDE;
55 56
57 std::string notification_id() { return notification_id_; }
58
56 protected: 59 protected:
57 NotificationView(const Notification& notification, 60 NotificationView(const Notification& notification,
58 MessageCenter* message_center, 61 MessageCenter* message_center,
59 MessageCenterTray* tray, 62 MessageCenterTray* tray,
60 bool expanded); 63 bool expanded);
61 64
65 // Overrides from base class MessageView:
66 virtual void ClickOnNotification() OVERRIDE;
67 virtual void RemoveNotification(bool by_user) OVERRIDE;
68 virtual void DisableNotificationsFromThisSource() OVERRIDE;
69 virtual void ShowNotifierSettingsBubble() OVERRIDE;
70
62 private: 71 private:
63 bool IsExpansionNeeded(int width); 72 bool IsExpansionNeeded(int width);
64 bool IsMessageExpansionNeeded(int width); 73 bool IsMessageExpansionNeeded(int width);
65 int GetMessageLineLimit(int width); 74 int GetMessageLineLimit(int width);
66 int GetMessageLines(int width, int limit); 75 int GetMessageLines(int width, int limit);
67 int GetMessageHeight(int width, int limit); 76 int GetMessageHeight(int width, int limit);
68 77
78 MessageCenter* message_center_; // Weak.
79 MessageCenterTray* tray_; // Weak.
80 std::string notification_id_;
81 message_center::NotifierId notifier_id_;
82
69 // Describes whether the view should display a hand pointer or not. 83 // Describes whether the view should display a hand pointer or not.
70 bool clickable_; 84 bool clickable_;
71 bool is_expanded_; 85 bool is_expanded_;
72 86
73 // Weak references to NotificationView descendants owned by their parents. 87 // Weak references to NotificationView descendants owned by their parents.
74 views::View* background_view_; 88 views::View* background_view_;
75 views::View* top_view_; 89 views::View* top_view_;
76 BoundedLabel* title_view_; 90 BoundedLabel* title_view_;
77 BoundedLabel* message_view_; 91 BoundedLabel* message_view_;
78 BoundedLabel* context_message_view_; 92 BoundedLabel* context_message_view_;
79 std::vector<views::View*> item_views_; 93 std::vector<views::View*> item_views_;
80 views::View* icon_view_; 94 views::View* icon_view_;
81 views::View* bottom_view_; 95 views::View* bottom_view_;
82 views::View* image_view_; 96 views::View* image_view_;
83 views::ProgressBar* progress_bar_view_; 97 views::ProgressBar* progress_bar_view_;
84 std::vector<views::View*> action_buttons_; 98 std::vector<views::View*> action_buttons_;
85 PaddedButton* expand_button_; 99 PaddedButton* expand_button_;
86 100
87 DISALLOW_COPY_AND_ASSIGN(NotificationView); 101 DISALLOW_COPY_AND_ASSIGN(NotificationView);
88 }; 102 };
89 103
90 } // namespace message_center 104 } // namespace message_center
91 105
92 #endif // UI_MESSAGE_CENTER_VIEWS_NOTIFICATION_VIEW_H_ 106 #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