| 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 "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
| 10 #include "ui/gfx/insets.h" | 10 #include "ui/gfx/insets.h" |
| 11 #include "ui/message_center/message_center_export.h" | 11 #include "ui/message_center/message_center_export.h" |
| 12 #include "ui/message_center/notification.h" | 12 #include "ui/message_center/notification.h" |
| 13 #include "ui/views/controls/button/button.h" | 13 #include "ui/views/controls/button/button.h" |
| 14 #include "ui/views/controls/slide_out_view.h" | 14 #include "ui/views/controls/slide_out_view.h" |
| 15 | 15 |
| 16 namespace ui { | 16 namespace ui { |
| 17 class MenuModel; | 17 class MenuModel; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace views { | 20 namespace views { |
| 21 class ImageButton; | 21 class ImageButton; |
| 22 class ImageView; |
| 22 class Painter; | 23 class Painter; |
| 23 class ScrollView; | 24 class ScrollView; |
| 24 } | 25 } |
| 25 | 26 |
| 26 namespace message_center { | 27 namespace message_center { |
| 27 | 28 |
| 28 // Interface that MessageView uses to report clicks and other user actions. | 29 // Interface that MessageView uses to report clicks and other user actions. |
| 29 // Provided by creator of MessageView. | 30 // Provided by creator of MessageView. |
| 30 class MessageViewController { | 31 class MessageViewController { |
| 31 public: | 32 public: |
| 32 virtual void ClickOnNotification(const std::string& notification_id) = 0; | 33 virtual void ClickOnNotification(const std::string& notification_id) = 0; |
| 33 virtual void RemoveNotification(const std::string& notification_id, | 34 virtual void RemoveNotification(const std::string& notification_id, |
| 34 bool by_user) = 0; | 35 bool by_user) = 0; |
| 35 }; | 36 }; |
| 36 | 37 |
| 37 // Individual notifications constants. | 38 // Individual notifications constants. |
| 38 const int kPaddingBetweenItems = 10; | 39 const int kPaddingBetweenItems = 10; |
| 39 const int kPaddingHorizontal = 18; | 40 const int kPaddingHorizontal = 18; |
| 40 const int kWebNotificationButtonWidth = 32; | 41 const int kWebNotificationButtonWidth = 32; |
| 41 const int kWebNotificationIconSize = 40; | 42 const int kWebNotificationIconSize = 40; |
| 42 | 43 |
| 43 // An base class for a notification entry. Contains background, close button | 44 // An base class for a notification entry. Contains background, close button |
| 44 // and other elements shared by derived notification views. | 45 // and other elements shared by derived notification views. |
| 45 class MESSAGE_CENTER_EXPORT MessageView : public views::SlideOutView, | 46 class MESSAGE_CENTER_EXPORT MessageView : public views::SlideOutView, |
| 46 public views::ButtonListener { | 47 public views::ButtonListener { |
| 47 public: | 48 public: |
| 48 MessageView(MessageViewController* controller, | 49 MessageView(MessageViewController* controller, |
| 49 const std::string& notification_id, | 50 const std::string& notification_id, |
| 50 const NotifierId& notifier_id, | 51 const NotifierId& notifier_id, |
| 52 const gfx::ImageSkia& small_image, |
| 51 const base::string16& display_source); | 53 const base::string16& display_source); |
| 52 virtual ~MessageView(); | 54 virtual ~MessageView(); |
| 53 | 55 |
| 54 // Returns the insets for the shadow it will have for rich notification. | 56 // Returns the insets for the shadow it will have for rich notification. |
| 55 static gfx::Insets GetShadowInsets(); | 57 static gfx::Insets GetShadowInsets(); |
| 56 | 58 |
| 57 // Creates a shadow around the notification. | 59 // Creates a shadow around the notification. |
| 58 void CreateShadowBorder(); | 60 void CreateShadowBorder(); |
| 59 | 61 |
| 60 bool IsCloseButtonFocused(); | 62 bool IsCloseButtonFocused(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 83 | 85 |
| 84 void set_scroller(views::ScrollView* scroller) { scroller_ = scroller; } | 86 void set_scroller(views::ScrollView* scroller) { scroller_ = scroller; } |
| 85 std::string notification_id() { return notification_id_; } | 87 std::string notification_id() { return notification_id_; } |
| 86 NotifierId notifier_id() { return notifier_id_; } | 88 NotifierId notifier_id() { return notifier_id_; } |
| 87 const base::string16& display_source() const { return display_source_; } | 89 const base::string16& display_source() const { return display_source_; } |
| 88 | 90 |
| 89 protected: | 91 protected: |
| 90 // Overridden from views::SlideOutView: | 92 // Overridden from views::SlideOutView: |
| 91 virtual void OnSlideOut() OVERRIDE; | 93 virtual void OnSlideOut() OVERRIDE; |
| 92 | 94 |
| 95 views::ImageView* small_image() { return small_image_view_.get(); } |
| 93 views::ImageButton* close_button() { return close_button_.get(); } | 96 views::ImageButton* close_button() { return close_button_.get(); } |
| 94 views::ScrollView* scroller() { return scroller_; } | 97 views::ScrollView* scroller() { return scroller_; } |
| 95 | 98 |
| 96 private: | 99 private: |
| 97 MessageViewController* controller_; | 100 MessageViewController* controller_; |
| 98 std::string notification_id_; | 101 std::string notification_id_; |
| 99 NotifierId notifier_id_; | 102 NotifierId notifier_id_; |
| 100 views::View* background_view_; // Owned by views hierarchy. | 103 views::View* background_view_; // Owned by views hierarchy. |
| 101 scoped_ptr<views::ImageButton> close_button_; | 104 scoped_ptr<views::ImageButton> close_button_; |
| 105 scoped_ptr<views::ImageView> small_image_view_; |
| 102 views::ScrollView* scroller_; | 106 views::ScrollView* scroller_; |
| 103 | 107 |
| 104 base::string16 accessible_name_; | 108 base::string16 accessible_name_; |
| 105 | 109 |
| 106 base::string16 display_source_; | 110 base::string16 display_source_; |
| 107 | 111 |
| 108 scoped_ptr<views::Painter> focus_painter_; | 112 scoped_ptr<views::Painter> focus_painter_; |
| 109 | 113 |
| 110 DISALLOW_COPY_AND_ASSIGN(MessageView); | 114 DISALLOW_COPY_AND_ASSIGN(MessageView); |
| 111 }; | 115 }; |
| 112 | 116 |
| 113 } // namespace message_center | 117 } // namespace message_center |
| 114 | 118 |
| 115 #endif // UI_MESSAGE_CENTER_VIEWS_MESSAGE_VIEW_H_ | 119 #endif // UI_MESSAGE_CENTER_VIEWS_MESSAGE_VIEW_H_ |
| OLD | NEW |