Chromium Code Reviews| OLD | NEW |
|---|---|
| 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_MESSAGE_VIEW_H_ | 5 #ifndef UI_MESSAGE_CENTER_MESSAGE_VIEW_H_ |
| 6 #define UI_MESSAGE_CENTER_MESSAGE_VIEW_H_ | 6 #define UI_MESSAGE_CENTER_MESSAGE_VIEW_H_ |
| 7 | 7 |
| 8 #include "ui/message_center/notification.h" | 8 #include "ui/message_center/notification.h" |
| 9 #include "ui/message_center/notification_list.h" | 9 #include "ui/message_center/notification_list.h" |
| 10 #include "ui/views/controls/button/button.h" | 10 #include "ui/views/controls/button/button.h" |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 const int kPaddingBetweenItems = 10; | 22 const int kPaddingBetweenItems = 10; |
| 23 const int kPaddingHorizontal = 18; | 23 const int kPaddingHorizontal = 18; |
| 24 const int kWebNotificationButtonWidth = 32; | 24 const int kWebNotificationButtonWidth = 32; |
| 25 const int kWebNotificationIconSize = 40; | 25 const int kWebNotificationIconSize = 40; |
| 26 const int kWebNotificationWidth = 300; | 26 const int kWebNotificationWidth = 300; |
| 27 | 27 |
| 28 // An abstract class that forms the basis of a view for a notification entry. | 28 // An abstract class that forms the basis of a view for a notification entry. |
| 29 class MessageView : public views::SlideOutView, | 29 class MessageView : public views::SlideOutView, |
| 30 public views::ButtonListener { | 30 public views::ButtonListener { |
| 31 public: | 31 public: |
| 32 MessageView(NotificationList::Delegate* list_delegate, | 32 MessageView(NotificationList::Delegate* list_delegate); |
| 33 const Notification& notification); | |
| 34 | 33 |
| 35 virtual ~MessageView(); | 34 virtual ~MessageView(); |
| 36 | 35 |
| 37 // Creates the elements that make up the view layout. Must be called | 36 // Creates the elements that make up the view layout. Must be called |
| 38 // immediately after construction. | 37 // immediately after construction. Derived classes must call the base |
| 39 virtual void SetUpView() = 0; | 38 // class' implementation first. |
| 39 // The view should not cache a reference to notification, since Notification | |
| 40 // may be destroyed before the view. | |
| 41 virtual void SetUpView(const Notification& notification); | |
|
stevenjb
2013/02/25 23:55:56
message_view.cc does not appear to have uploaded c
Dmitry Titov
2013/02/26 01:01:51
Done. Removed this virtual completely, moved some
| |
| 40 | 42 |
| 41 void set_scroller(views::ScrollView* scroller) { scroller_ = scroller; } | 43 void set_scroller(views::ScrollView* scroller) { scroller_ = scroller; } |
| 42 | 44 |
| 43 // Overridden from views::View. | 45 // Overridden from views::View. |
| 44 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; | 46 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; |
| 45 | 47 |
| 46 // Overridden from ui::EventHandler. | 48 // Overridden from ui::EventHandler. |
| 47 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; | 49 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; |
| 48 | 50 |
| 49 // Overridden from ButtonListener. | 51 // Overridden from ButtonListener. |
| 50 virtual void ButtonPressed(views::Button* sender, | 52 virtual void ButtonPressed(views::Button* sender, |
| 51 const ui::Event& event) OVERRIDE; | 53 const ui::Event& event) OVERRIDE; |
| 52 | 54 |
| 53 protected: | 55 protected: |
| 54 MessageView(); | 56 MessageView(); |
| 55 | 57 |
| 56 // Shows the menu for the notification. | 58 // Shows the menu for the notification. |
| 57 void ShowMenu(gfx::Point screen_location); | 59 void ShowMenu(gfx::Point screen_location); |
| 58 | 60 |
| 59 // Overridden from views::SlideOutView. | 61 // Overridden from views::SlideOutView. |
| 60 virtual void OnSlideOut() OVERRIDE; | 62 virtual void OnSlideOut() OVERRIDE; |
| 61 | 63 |
| 62 NotificationList::Delegate* list_delegate() { return list_delegate_; } | 64 NotificationList::Delegate* list_delegate() { return list_delegate_; } |
| 63 Notification& notification() { return notification_; } | 65 const std::string& notification_id() { return notification_id_; } |
| 66 const string16& display_source() const { return display_source_; } | |
| 67 const std::string& extension_id() const { return extension_id_; } | |
| 64 views::ImageButton* close_button() { return close_button_.get(); } | 68 views::ImageButton* close_button() { return close_button_.get(); } |
| 65 views::ScrollView* scroller() { return scroller_; } | 69 views::ScrollView* scroller() { return scroller_; } |
| 66 | 70 |
| 67 private: | 71 private: |
| 68 NotificationList::Delegate* list_delegate_; | 72 NotificationList::Delegate* list_delegate_; // Weak, global (MessageCenter). |
| 69 Notification notification_; | 73 std::string notification_id_; |
| 74 string16 display_source_; | |
| 75 std::string extension_id_; | |
| 76 | |
| 70 scoped_ptr<views::ImageButton> close_button_; | 77 scoped_ptr<views::ImageButton> close_button_; |
| 71 | 78 |
| 72 views::ScrollView* scroller_; | 79 views::ScrollView* scroller_; |
| 73 | 80 |
| 74 DISALLOW_COPY_AND_ASSIGN(MessageView); | 81 DISALLOW_COPY_AND_ASSIGN(MessageView); |
| 75 }; | 82 }; |
| 76 | 83 |
| 77 } // namespace message_center | 84 } // namespace message_center |
| 78 | 85 |
| 79 #endif // UI_MESSAGE_CENTER_MESSAGE_VIEW_H_ | 86 #endif // UI_MESSAGE_CENTER_MESSAGE_VIEW_H_ |
| OLD | NEW |