| 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/strings/string16.h" | 8 #include "base/strings/string16.h" |
| 9 #include "ui/gfx/insets.h" | 9 #include "ui/gfx/insets.h" |
| 10 #include "ui/message_center/message_center_export.h" | 10 #include "ui/message_center/message_center_export.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 class MessageCenter; | 22 class MessageCenter; |
| 23 class MessageCenterTray; | 23 class MessageCenterTray; |
| 24 class MessageViewContextMenuController; | 24 class MessageViewContextMenuController; |
| 25 | 25 |
| 26 // Individual notifications constants. | 26 // Individual notifications constants. |
| 27 const int kPaddingBetweenItems = 10; | 27 const int kPaddingBetweenItems = 10; |
| 28 const int kPaddingHorizontal = 18; | 28 const int kPaddingHorizontal = 18; |
| 29 const int kWebNotificationButtonWidth = 32; | 29 const int kWebNotificationButtonWidth = 32; |
| 30 const int kWebNotificationIconSize = 40; | 30 const int kWebNotificationIconSize = 40; |
| 31 | 31 |
| 32 // Types of MessageViews. They correspond to the set of derived classes. |
| 33 enum MessageViewTypes { |
| 34 NOTIFICATION_VIEW, // Directly represents a single notification. |
| 35 GROUP_VIEW // A group of notifications from the same source. |
| 36 }; |
| 37 |
| 32 // An abstract class that forms the basis of a view for a notification entry. | 38 // An abstract class that forms the basis of a view for a notification entry. |
| 33 class MESSAGE_CENTER_EXPORT MessageView : public views::SlideOutView, | 39 class MESSAGE_CENTER_EXPORT MessageView : public views::SlideOutView, |
| 34 public views::ButtonListener { | 40 public views::ButtonListener { |
| 35 public: | 41 public: |
| 36 MessageView(const Notification& notification, | 42 MessageView(const string16& display_source); |
| 37 MessageCenter* message_center, | |
| 38 MessageCenterTray* tray); | |
| 39 virtual ~MessageView(); | 43 virtual ~MessageView(); |
| 40 | 44 |
| 45 // Overrided by derived classes. |
| 46 virtual MessageViewTypes GetType() = 0; |
| 47 virtual void ClickOnNotification() = 0; |
| 48 virtual void RemoveNotification(bool by_user) = 0; |
| 49 virtual void DisableNotificationsFromThisSource() = 0; |
| 50 virtual void ShowNotifierSettingsBubble() = 0; |
| 51 |
| 41 // Returns the insets for the shadow it will have for rich notification. | 52 // Returns the insets for the shadow it will have for rich notification. |
| 42 static gfx::Insets GetShadowInsets(); | 53 static gfx::Insets GetShadowInsets(); |
| 43 | 54 |
| 44 // Creates a shadow around the notification. | 55 // Creates a shadow around the notification. |
| 45 void CreateShadowBorder(); | 56 void CreateShadowBorder(); |
| 46 | 57 |
| 47 bool IsCloseButtonFocused(); | 58 bool IsCloseButtonFocused(); |
| 48 void RequestFocusOnCloseButton(); | 59 void RequestFocusOnCloseButton(); |
| 49 | 60 |
| 50 void set_accessible_name(const string16& name) { accessible_name_ = name; } | 61 void set_accessible_name(const string16& name) { accessible_name_ = name; } |
| 51 | 62 |
| 52 // Overridden from views::View: | 63 // Overridden from views::View: |
| 53 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; | 64 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; |
| 54 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; | 65 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; |
| 55 virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE; | 66 virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE; |
| 56 virtual bool OnKeyReleased(const ui::KeyEvent& event) OVERRIDE; | 67 virtual bool OnKeyReleased(const ui::KeyEvent& event) OVERRIDE; |
| 57 virtual void OnPaintFocusBorder(gfx::Canvas* canvas) OVERRIDE; | 68 virtual void OnPaintFocusBorder(gfx::Canvas* canvas) OVERRIDE; |
| 58 | 69 |
| 59 // Overridden from ui::EventHandler: | 70 // Overridden from ui::EventHandler: |
| 60 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; | 71 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; |
| 61 | 72 |
| 62 // Overridden from ButtonListener: | 73 // Overridden from ButtonListener: |
| 63 virtual void ButtonPressed(views::Button* sender, | 74 virtual void ButtonPressed(views::Button* sender, |
| 64 const ui::Event& event) OVERRIDE; | 75 const ui::Event& event) OVERRIDE; |
| 65 | 76 |
| 66 const std::string& notification_id() { return notification_id_; } | |
| 67 void set_scroller(views::ScrollView* scroller) { scroller_ = scroller; } | 77 void set_scroller(views::ScrollView* scroller) { scroller_ = scroller; } |
| 68 | 78 |
| 69 protected: | 79 protected: |
| 70 MessageView(); | |
| 71 | |
| 72 // Overridden from views::SlideOutView: | 80 // Overridden from views::SlideOutView: |
| 73 virtual void OnSlideOut() OVERRIDE; | 81 virtual void OnSlideOut() OVERRIDE; |
| 74 | 82 |
| 75 MessageCenter* message_center() { return message_center_; } | |
| 76 views::ImageButton* close_button() { return close_button_.get(); } | 83 views::ImageButton* close_button() { return close_button_.get(); } |
| 77 views::ScrollView* scroller() { return scroller_; } | 84 views::ScrollView* scroller() { return scroller_; } |
| 78 | 85 |
| 79 private: | 86 private: |
| 80 MessageCenter* message_center_; // Weak reference. | |
| 81 std::string notification_id_; | |
| 82 | |
| 83 scoped_ptr<MessageViewContextMenuController> context_menu_controller_; | 87 scoped_ptr<MessageViewContextMenuController> context_menu_controller_; |
| 84 scoped_ptr<views::ImageButton> close_button_; | 88 scoped_ptr<views::ImageButton> close_button_; |
| 85 views::ScrollView* scroller_; | 89 views::ScrollView* scroller_; |
| 86 | 90 |
| 87 string16 accessible_name_; | 91 string16 accessible_name_; |
| 88 | 92 |
| 89 DISALLOW_COPY_AND_ASSIGN(MessageView); | 93 DISALLOW_COPY_AND_ASSIGN(MessageView); |
| 90 }; | 94 }; |
| 91 | 95 |
| 92 } // namespace message_center | 96 } // namespace message_center |
| 93 | 97 |
| 94 #endif // UI_MESSAGE_CENTER_VIEWS_MESSAGE_VIEW_H_ | 98 #endif // UI_MESSAGE_CENTER_VIEWS_MESSAGE_VIEW_H_ |
| OLD | NEW |