| 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_VIEWS_MESSAGE_VIEW_H_ | 5 #ifndef UI_MESSAGE_CENTER_VIEWS_MESSAGE_VIEW_H_ |
| 6 #define UI_MESSAGE_CENTER_VIEWS_MESSAGE_VIEW_H_ | 6 #define UI_MESSAGE_CENTER_VIEWS_MESSAGE_VIEW_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 namespace views { | 26 namespace views { |
| 27 class ImageButton; | 27 class ImageButton; |
| 28 class ImageView; | 28 class ImageView; |
| 29 class Painter; | 29 class Painter; |
| 30 class ScrollView; | 30 class ScrollView; |
| 31 } | 31 } |
| 32 | 32 |
| 33 namespace message_center { | 33 namespace message_center { |
| 34 | 34 |
| 35 // Interface that MessageView uses to report clicks and other user actions. | 35 class MessageCenterController; |
| 36 // Provided by creator of MessageView. | |
| 37 class MessageViewController { | |
| 38 public: | |
| 39 virtual void ClickOnNotification(const std::string& notification_id) = 0; | |
| 40 virtual void RemoveNotification(const std::string& notification_id, | |
| 41 bool by_user) = 0; | |
| 42 }; | |
| 43 | 36 |
| 44 // Individual notifications constants. | 37 // Individual notifications constants. |
| 45 const int kPaddingBetweenItems = 10; | 38 const int kPaddingBetweenItems = 10; |
| 46 const int kPaddingHorizontal = 18; | 39 const int kPaddingHorizontal = 18; |
| 47 const int kWebNotificationButtonWidth = 32; | 40 const int kWebNotificationButtonWidth = 32; |
| 48 const int kWebNotificationIconSize = 40; | 41 const int kWebNotificationIconSize = 40; |
| 49 | 42 |
| 50 // An base class for a notification entry. Contains background and other | 43 // An base class for a notification entry. Contains background and other |
| 51 // elements shared by derived notification views. | 44 // elements shared by derived notification views. |
| 52 class MESSAGE_CENTER_EXPORT MessageView : public views::SlideOutView, | 45 class MESSAGE_CENTER_EXPORT MessageView : public views::SlideOutView, |
| 53 public views::ButtonListener { | 46 public views::ButtonListener { |
| 54 public: | 47 public: |
| 55 MessageView(MessageViewController* controller, | 48 MessageView(MessageCenterController* controller, |
| 56 const std::string& notification_id, | 49 const std::string& notification_id, |
| 57 const NotifierId& notifier_id, | 50 const NotifierId& notifier_id, |
| 58 const gfx::ImageSkia& small_image, | 51 const gfx::ImageSkia& small_image, |
| 59 const base::string16& display_source); | 52 const base::string16& display_source); |
| 60 ~MessageView() override; | 53 ~MessageView() override; |
| 61 | 54 |
| 62 // Updates this view with the new data contained in the notification. | 55 // Updates this view with the new data contained in the notification. |
| 63 virtual void UpdateWithNotification(const Notification& notification); | 56 virtual void UpdateWithNotification(const Notification& notification); |
| 64 | 57 |
| 65 // Returns the insets for the shadow it will have for rich notification. | 58 // Returns the insets for the shadow it will have for rich notification. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 90 void OnGestureEvent(ui::GestureEvent* event) override; | 83 void OnGestureEvent(ui::GestureEvent* event) override; |
| 91 | 84 |
| 92 // Overridden from ButtonListener: | 85 // Overridden from ButtonListener: |
| 93 void ButtonPressed(views::Button* sender, const ui::Event& event) override; | 86 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
| 94 | 87 |
| 95 void set_scroller(views::ScrollView* scroller) { scroller_ = scroller; } | 88 void set_scroller(views::ScrollView* scroller) { scroller_ = scroller; } |
| 96 std::string notification_id() { return notification_id_; } | 89 std::string notification_id() { return notification_id_; } |
| 97 NotifierId notifier_id() { return notifier_id_; } | 90 NotifierId notifier_id() { return notifier_id_; } |
| 98 const base::string16& display_source() const { return display_source_; } | 91 const base::string16& display_source() const { return display_source_; } |
| 99 | 92 |
| 93 void set_controller(MessageCenterController* controller) { |
| 94 controller_ = controller; |
| 95 } |
| 96 |
| 100 protected: | 97 protected: |
| 101 // Overridden from views::SlideOutView: | 98 // Overridden from views::SlideOutView: |
| 102 void OnSlideOut() override; | 99 void OnSlideOut() override; |
| 103 | 100 |
| 104 views::ImageView* small_image() { return small_image_view_.get(); } | 101 views::ImageView* small_image() { return small_image_view_.get(); } |
| 105 views::ScrollView* scroller() { return scroller_; } | 102 views::ScrollView* scroller() { return scroller_; } |
| 103 MessageCenterController* controller() { return controller_; } |
| 106 | 104 |
| 107 private: | 105 private: |
| 108 MessageViewController* controller_; | 106 MessageCenterController* controller_; // Weak, lives longer then views. |
| 109 std::string notification_id_; | 107 std::string notification_id_; |
| 110 NotifierId notifier_id_; | 108 NotifierId notifier_id_; |
| 111 views::View* background_view_; // Owned by views hierarchy. | 109 views::View* background_view_; // Owned by views hierarchy. |
| 112 std::unique_ptr<views::ImageView> small_image_view_; | 110 std::unique_ptr<views::ImageView> small_image_view_; |
| 113 views::ScrollView* scroller_; | 111 views::ScrollView* scroller_; |
| 114 | 112 |
| 115 base::string16 accessible_name_; | 113 base::string16 accessible_name_; |
| 116 | 114 |
| 117 base::string16 display_source_; | 115 base::string16 display_source_; |
| 118 | 116 |
| 119 std::unique_ptr<views::Painter> focus_painter_; | 117 std::unique_ptr<views::Painter> focus_painter_; |
| 120 | 118 |
| 121 // Changes the background color being used by |background_view_| and schedules | 119 // Changes the background color being used by |background_view_| and schedules |
| 122 // a paint. | 120 // a paint. |
| 123 void SetDrawBackgroundAsActive(bool active); | 121 void SetDrawBackgroundAsActive(bool active); |
| 124 | 122 |
| 125 DISALLOW_COPY_AND_ASSIGN(MessageView); | 123 DISALLOW_COPY_AND_ASSIGN(MessageView); |
| 126 }; | 124 }; |
| 127 | 125 |
| 128 } // namespace message_center | 126 } // namespace message_center |
| 129 | 127 |
| 130 #endif // UI_MESSAGE_CENTER_VIEWS_MESSAGE_VIEW_H_ | 128 #endif // UI_MESSAGE_CENTER_VIEWS_MESSAGE_VIEW_H_ |
| OLD | NEW |