| 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_NOTIFICATION_VIEW_H_ | 5 #ifndef UI_MESSAGE_CENTER_VIEWS_NOTIFICATION_VIEW_H_ |
| 6 #define UI_MESSAGE_CENTER_VIEWS_NOTIFICATION_VIEW_H_ | 6 #define UI_MESSAGE_CENTER_VIEWS_NOTIFICATION_VIEW_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "ui/message_center/message_center_export.h" | 10 #include "ui/message_center/message_center_export.h" |
| 11 #include "ui/message_center/views/message_view.h" | 11 #include "ui/message_center/views/message_view.h" |
| 12 #include "ui/views/view_targeter_delegate.h" |
| 12 | 13 |
| 13 namespace views { | 14 namespace views { |
| 14 class ProgressBar; | 15 class ProgressBar; |
| 15 } | 16 } |
| 16 | 17 |
| 17 namespace message_center { | 18 namespace message_center { |
| 18 | 19 |
| 19 class BoundedLabel; | 20 class BoundedLabel; |
| 20 class MessageCenter; | 21 class MessageCenter; |
| 21 class MessageCenterController; | 22 class MessageCenterController; |
| 22 class NotificationButton; | 23 class NotificationButton; |
| 23 class NotificationView; | 24 class NotificationView; |
| 24 class PaddedButton; | 25 class PaddedButton; |
| 25 | 26 |
| 26 // View that displays all current types of notification (web, basic, image, and | 27 // View that displays all current types of notification (web, basic, image, and |
| 27 // list). Future notification types may be handled by other classes, in which | 28 // list). Future notification types may be handled by other classes, in which |
| 28 // case instances of those classes would be returned by the Create() factory | 29 // case instances of those classes would be returned by the Create() factory |
| 29 // method below. | 30 // method below. |
| 30 class MESSAGE_CENTER_EXPORT NotificationView : public MessageView, | 31 class MESSAGE_CENTER_EXPORT NotificationView |
| 31 public MessageViewController { | 32 : public MessageView, |
| 33 public views::ViewTargeterDelegate, |
| 34 public MessageViewController { |
| 32 public: | 35 public: |
| 33 // Creates appropriate MessageViews for notifications. Those currently are | 36 // Creates appropriate MessageViews for notifications. Those currently are |
| 34 // always NotificationView instances but in the future | 37 // always NotificationView instances but in the future |
| 35 // may be instances of other classes, with the class depending on the | 38 // may be instances of other classes, with the class depending on the |
| 36 // notification type. A notification is top level if it needs to be rendered | 39 // notification type. A notification is top level if it needs to be rendered |
| 37 // outside the browser window. No custom shadows are created for top level | 40 // outside the browser window. No custom shadows are created for top level |
| 38 // notifications on Linux with Aura. | 41 // notifications on Linux with Aura. |
| 39 // |controller| may be NULL, but has to be set before the view is shown. | 42 // |controller| may be NULL, but has to be set before the view is shown. |
| 40 static NotificationView* Create(MessageCenterController* controller, | 43 static NotificationView* Create(MessageCenterController* controller, |
| 41 const Notification& notification, | 44 const Notification& notification, |
| 42 bool top_level); | 45 bool top_level); |
| 43 virtual ~NotificationView(); | 46 virtual ~NotificationView(); |
| 44 | 47 |
| 45 // Overridden from views::View: | 48 // Overridden from views::View: |
| 46 virtual gfx::Size GetPreferredSize() const OVERRIDE; | 49 virtual gfx::Size GetPreferredSize() const OVERRIDE; |
| 47 virtual int GetHeightForWidth(int width) const OVERRIDE; | 50 virtual int GetHeightForWidth(int width) const OVERRIDE; |
| 48 virtual void Layout() OVERRIDE; | 51 virtual void Layout() OVERRIDE; |
| 49 virtual void OnFocus() OVERRIDE; | 52 virtual void OnFocus() OVERRIDE; |
| 50 virtual void ScrollRectToVisible(const gfx::Rect& rect) OVERRIDE; | 53 virtual void ScrollRectToVisible(const gfx::Rect& rect) OVERRIDE; |
| 51 virtual views::View* GetEventHandlerForRect(const gfx::Rect& rect) OVERRIDE; | |
| 52 virtual gfx::NativeCursor GetCursor(const ui::MouseEvent& event) OVERRIDE; | 54 virtual gfx::NativeCursor GetCursor(const ui::MouseEvent& event) OVERRIDE; |
| 53 | 55 |
| 54 // Overridden from MessageView: | 56 // Overridden from MessageView: |
| 55 virtual void UpdateWithNotification( | 57 virtual void UpdateWithNotification( |
| 56 const Notification& notification) OVERRIDE; | 58 const Notification& notification) OVERRIDE; |
| 57 virtual void ButtonPressed(views::Button* sender, | 59 virtual void ButtonPressed(views::Button* sender, |
| 58 const ui::Event& event) OVERRIDE; | 60 const ui::Event& event) OVERRIDE; |
| 59 | 61 |
| 60 // Overridden from MessageViewController: | 62 // Overridden from MessageViewController: |
| 61 virtual void ClickOnNotification(const std::string& notification_id) OVERRIDE; | 63 virtual void ClickOnNotification(const std::string& notification_id) OVERRIDE; |
| 62 virtual void RemoveNotification(const std::string& notification_id, | 64 virtual void RemoveNotification(const std::string& notification_id, |
| 63 bool by_user) OVERRIDE; | 65 bool by_user) OVERRIDE; |
| 64 | 66 |
| 65 void set_controller(MessageCenterController* controller) { | 67 void set_controller(MessageCenterController* controller) { |
| 66 controller_ = controller; | 68 controller_ = controller; |
| 67 } | 69 } |
| 68 | 70 |
| 69 protected: | 71 protected: |
| 70 NotificationView(MessageCenterController* controller, | 72 NotificationView(MessageCenterController* controller, |
| 71 const Notification& notification); | 73 const Notification& notification); |
| 72 | 74 |
| 73 private: | 75 private: |
| 74 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, CreateOrUpdateTest); | 76 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, CreateOrUpdateTest); |
| 75 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, TestLineLimits); | 77 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, TestLineLimits); |
| 76 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, UpdateButtonsStateTest); | 78 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, UpdateButtonsStateTest); |
| 77 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, UpdateButtonCountTest); | 79 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, UpdateButtonCountTest); |
| 78 | 80 |
| 79 friend class NotificationViewTest; | 81 friend class NotificationViewTest; |
| 80 | 82 |
| 83 // views::ViewTargeterDelegate: |
| 84 virtual views::View* TargetForRect(views::View* root, |
| 85 const gfx::Rect& rect) OVERRIDE; |
| 86 |
| 81 void CreateOrUpdateViews(const Notification& notification); | 87 void CreateOrUpdateViews(const Notification& notification); |
| 82 void SetAccessibleName(const Notification& notification); | 88 void SetAccessibleName(const Notification& notification); |
| 83 | 89 |
| 84 void CreateOrUpdateTitleView(const Notification& notification); | 90 void CreateOrUpdateTitleView(const Notification& notification); |
| 85 void CreateOrUpdateMessageView(const Notification& notification); | 91 void CreateOrUpdateMessageView(const Notification& notification); |
| 86 void CreateOrUpdateContextMessageView(const Notification& notification); | 92 void CreateOrUpdateContextMessageView(const Notification& notification); |
| 87 void CreateOrUpdateProgressBarView(const Notification& notification); | 93 void CreateOrUpdateProgressBarView(const Notification& notification); |
| 88 void CreateOrUpdateListItemViews(const Notification& notification); | 94 void CreateOrUpdateListItemViews(const Notification& notification); |
| 89 void CreateOrUpdateIconView(const Notification& notification); | 95 void CreateOrUpdateIconView(const Notification& notification); |
| 90 void CreateOrUpdateImageView(const Notification& notification); | 96 void CreateOrUpdateImageView(const Notification& notification); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 110 views::ProgressBar* progress_bar_view_; | 116 views::ProgressBar* progress_bar_view_; |
| 111 std::vector<NotificationButton*> action_buttons_; | 117 std::vector<NotificationButton*> action_buttons_; |
| 112 std::vector<views::View*> separators_; | 118 std::vector<views::View*> separators_; |
| 113 | 119 |
| 114 DISALLOW_COPY_AND_ASSIGN(NotificationView); | 120 DISALLOW_COPY_AND_ASSIGN(NotificationView); |
| 115 }; | 121 }; |
| 116 | 122 |
| 117 } // namespace message_center | 123 } // namespace message_center |
| 118 | 124 |
| 119 #endif // UI_MESSAGE_CENTER_VIEWS_NOTIFICATION_VIEW_H_ | 125 #endif // UI_MESSAGE_CENTER_VIEWS_NOTIFICATION_VIEW_H_ |
| OLD | NEW |