| 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 28 matching lines...) Expand all Loading... |
| 39 const int kPaddingHorizontal = 18; | 39 const int kPaddingHorizontal = 18; |
| 40 const int kWebNotificationButtonWidth = 32; | 40 const int kWebNotificationButtonWidth = 32; |
| 41 const int kWebNotificationIconSize = 40; | 41 const int kWebNotificationIconSize = 40; |
| 42 | 42 |
| 43 // An base class for a notification entry. Contains background and other | 43 // An base class for a notification entry. Contains background and other |
| 44 // elements shared by derived notification views. | 44 // elements shared by derived notification views. |
| 45 class MESSAGE_CENTER_EXPORT MessageView : public views::SlideOutView, | 45 class MESSAGE_CENTER_EXPORT MessageView : public views::SlideOutView, |
| 46 public views::ButtonListener { | 46 public views::ButtonListener { |
| 47 public: | 47 public: |
| 48 MessageView(MessageCenterController* controller, | 48 MessageView(MessageCenterController* controller, |
| 49 const std::string& notification_id, | 49 const Notification& notification); |
| 50 const NotifierId& notifier_id, | |
| 51 const gfx::ImageSkia& small_image, | |
| 52 const base::string16& display_source); | |
| 53 ~MessageView() override; | 50 ~MessageView() override; |
| 54 | 51 |
| 55 // Updates this view with the new data contained in the notification. | 52 // Updates this view with the new data contained in the notification. |
| 56 virtual void UpdateWithNotification(const Notification& notification); | 53 virtual void UpdateWithNotification(const Notification& notification); |
| 57 | 54 |
| 58 // Returns the insets for the shadow it will have for rich notification. | 55 // Returns the insets for the shadow it will have for rich notification. |
| 59 static gfx::Insets GetShadowInsets(); | 56 static gfx::Insets GetShadowInsets(); |
| 60 | 57 |
| 61 // Creates a shadow around the notification. | 58 // Creates a shadow around the notification. |
| 62 void CreateShadowBorder(); | 59 void CreateShadowBorder(); |
| 63 | 60 |
| 64 virtual bool IsCloseButtonFocused(); | 61 bool IsCloseButtonFocused(); |
| 65 virtual void RequestFocusOnCloseButton(); | 62 void RequestFocusOnCloseButton(); |
| 66 virtual bool IsPinned(); | 63 bool IsPinned(); |
| 67 | 64 |
| 68 void set_accessible_name(const base::string16& accessible_name) { | 65 void set_accessible_name(const base::string16& accessible_name) { |
| 69 accessible_name_ = accessible_name; | 66 accessible_name_ = accessible_name; |
| 70 } | 67 } |
| 71 | 68 |
| 72 // Overridden from views::View: | 69 // Overridden from views::View: |
| 73 void GetAccessibleState(ui::AXViewState* state) override; | 70 void GetAccessibleState(ui::AXViewState* state) override; |
| 74 bool OnMousePressed(const ui::MouseEvent& event) override; | 71 bool OnMousePressed(const ui::MouseEvent& event) override; |
| 75 bool OnKeyPressed(const ui::KeyEvent& event) override; | 72 bool OnKeyPressed(const ui::KeyEvent& event) override; |
| 76 bool OnKeyReleased(const ui::KeyEvent& event) override; | 73 bool OnKeyReleased(const ui::KeyEvent& event) override; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 91 const base::string16& display_source() const { return display_source_; } | 88 const base::string16& display_source() const { return display_source_; } |
| 92 | 89 |
| 93 void set_controller(MessageCenterController* controller) { | 90 void set_controller(MessageCenterController* controller) { |
| 94 controller_ = controller; | 91 controller_ = controller; |
| 95 } | 92 } |
| 96 | 93 |
| 97 protected: | 94 protected: |
| 98 // Overridden from views::SlideOutView: | 95 // Overridden from views::SlideOutView: |
| 99 void OnSlideOut() override; | 96 void OnSlideOut() override; |
| 100 | 97 |
| 98 // Creates and add close button to view hierarchy when necessary. Derived |
| 99 // classes should call this after its view hierarchy is populated to ensure |
| 100 // it is on top of other views. |
| 101 void CreateOrUpdateCloseButtonView(const Notification& notification); |
| 102 |
| 101 views::ImageView* small_image() { return small_image_view_.get(); } | 103 views::ImageView* small_image() { return small_image_view_.get(); } |
| 104 views::ImageButton* close_button() { return close_button_.get(); } |
| 102 views::ScrollView* scroller() { return scroller_; } | 105 views::ScrollView* scroller() { return scroller_; } |
| 103 MessageCenterController* controller() { return controller_; } | 106 MessageCenterController* controller() { return controller_; } |
| 104 | 107 |
| 105 private: | 108 private: |
| 109 // Changes the background color being used by |background_view_| and schedules |
| 110 // a paint. |
| 111 void SetDrawBackgroundAsActive(bool active); |
| 112 |
| 106 MessageCenterController* controller_; // Weak, lives longer then views. | 113 MessageCenterController* controller_; // Weak, lives longer then views. |
| 107 std::string notification_id_; | 114 std::string notification_id_; |
| 108 NotifierId notifier_id_; | 115 NotifierId notifier_id_; |
| 109 views::View* background_view_; // Owned by views hierarchy. | 116 views::View* background_view_ = nullptr; // Owned by views hierarchy. |
| 110 std::unique_ptr<views::ImageView> small_image_view_; | 117 std::unique_ptr<views::ImageView> small_image_view_; |
| 111 views::ScrollView* scroller_; | 118 std::unique_ptr<views::ImageButton> close_button_; |
| 119 views::ScrollView* scroller_ = nullptr; |
| 112 | 120 |
| 113 base::string16 accessible_name_; | 121 base::string16 accessible_name_; |
| 114 | 122 |
| 115 base::string16 display_source_; | 123 base::string16 display_source_; |
| 116 | 124 |
| 117 std::unique_ptr<views::Painter> focus_painter_; | 125 std::unique_ptr<views::Painter> focus_painter_; |
| 118 | 126 |
| 119 // Changes the background color being used by |background_view_| and schedules | |
| 120 // a paint. | |
| 121 void SetDrawBackgroundAsActive(bool active); | |
| 122 | |
| 123 DISALLOW_COPY_AND_ASSIGN(MessageView); | 127 DISALLOW_COPY_AND_ASSIGN(MessageView); |
| 124 }; | 128 }; |
| 125 | 129 |
| 126 } // namespace message_center | 130 } // namespace message_center |
| 127 | 131 |
| 128 #endif // UI_MESSAGE_CENTER_VIEWS_MESSAGE_VIEW_H_ | 132 #endif // UI_MESSAGE_CENTER_VIEWS_MESSAGE_VIEW_H_ |
| OLD | NEW |