| 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 #include "ui/views/view_targeter_delegate.h" |
| 13 | 13 |
| 14 class GURL; |
| 15 |
| 14 namespace views { | 16 namespace views { |
| 15 class ProgressBar; | 17 class ProgressBar; |
| 16 } | 18 } |
| 17 | 19 |
| 18 namespace message_center { | 20 namespace message_center { |
| 19 | 21 |
| 20 class BoundedLabel; | 22 class BoundedLabel; |
| 21 class MessageCenter; | 23 class MessageCenter; |
| 22 class MessageCenterController; | 24 class MessageCenterController; |
| 23 class NotificationButton; | 25 class NotificationButton; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 void set_controller(MessageCenterController* controller) { | 68 void set_controller(MessageCenterController* controller) { |
| 67 controller_ = controller; | 69 controller_ = controller; |
| 68 } | 70 } |
| 69 | 71 |
| 70 protected: | 72 protected: |
| 71 NotificationView(MessageCenterController* controller, | 73 NotificationView(MessageCenterController* controller, |
| 72 const Notification& notification); | 74 const Notification& notification); |
| 73 | 75 |
| 74 private: | 76 private: |
| 75 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, CreateOrUpdateTest); | 77 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, CreateOrUpdateTest); |
| 78 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, FormatContextMessageTest); |
| 76 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, TestLineLimits); | 79 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, TestLineLimits); |
| 77 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, TestIconSizing); | 80 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, TestIconSizing); |
| 78 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, TestImageSizing); | 81 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, TestImageSizing); |
| 79 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, UpdateButtonsStateTest); | 82 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, UpdateButtonsStateTest); |
| 80 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, UpdateButtonCountTest); | 83 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, UpdateButtonCountTest); |
| 81 | 84 |
| 82 friend class NotificationViewTest; | 85 friend class NotificationViewTest; |
| 83 | 86 |
| 84 // views::ViewTargeterDelegate: | 87 // views::ViewTargeterDelegate: |
| 85 views::View* TargetForRect(views::View* root, const gfx::Rect& rect) override; | 88 views::View* TargetForRect(views::View* root, const gfx::Rect& rect) override; |
| 86 | 89 |
| 87 void CreateOrUpdateViews(const Notification& notification); | 90 void CreateOrUpdateViews(const Notification& notification); |
| 88 void SetAccessibleName(const Notification& notification); | 91 void SetAccessibleName(const Notification& notification); |
| 89 | 92 |
| 90 void CreateOrUpdateTitleView(const Notification& notification); | 93 void CreateOrUpdateTitleView(const Notification& notification); |
| 91 void CreateOrUpdateMessageView(const Notification& notification); | 94 void CreateOrUpdateMessageView(const Notification& notification); |
| 92 void CreateOrUpdateContextMessageView(const Notification& notification); | 95 void CreateOrUpdateContextMessageView(const Notification& notification); |
| 93 void CreateOrUpdateProgressBarView(const Notification& notification); | 96 void CreateOrUpdateProgressBarView(const Notification& notification); |
| 94 void CreateOrUpdateListItemViews(const Notification& notification); | 97 void CreateOrUpdateListItemViews(const Notification& notification); |
| 95 void CreateOrUpdateIconView(const Notification& notification); | 98 void CreateOrUpdateIconView(const Notification& notification); |
| 96 void CreateOrUpdateImageView(const Notification& notification); | 99 void CreateOrUpdateImageView(const Notification& notification); |
| 97 void CreateOrUpdateActionButtonViews(const Notification& notification); | 100 void CreateOrUpdateActionButtonViews(const Notification& notification); |
| 98 | 101 |
| 99 int GetMessageLineLimit(int title_lines, int width) const; | 102 int GetMessageLineLimit(int title_lines, int width) const; |
| 100 int GetMessageHeight(int width, int limit) const; | 103 int GetMessageHeight(int width, int limit) const; |
| 101 | 104 |
| 105 // Decides if the notification origin should be used as a context message |
| 106 bool UseOriginAsContextMesssage(const Notification& notification) const; |
| 107 |
| 108 // Formats the context message to be displayed based on |context| |
| 109 // so it shows as much information as possible |
| 110 // given the space available in the ContextMessage section of the |
| 111 // notification. |
| 112 base::string16 FormatContextMessage(const Notification& notification) const; |
| 113 |
| 102 MessageCenterController* controller_; // Weak, lives longer then views. | 114 MessageCenterController* controller_; // Weak, lives longer then views. |
| 103 | 115 |
| 104 // Describes whether the view should display a hand pointer or not. | 116 // Describes whether the view should display a hand pointer or not. |
| 105 bool clickable_; | 117 bool clickable_; |
| 106 | 118 |
| 107 // Weak references to NotificationView descendants owned by their parents. | 119 // Weak references to NotificationView descendants owned by their parents. |
| 108 views::View* top_view_; | 120 views::View* top_view_; |
| 109 BoundedLabel* title_view_; | 121 BoundedLabel* title_view_; |
| 110 BoundedLabel* message_view_; | 122 BoundedLabel* message_view_; |
| 111 BoundedLabel* context_message_view_; | 123 BoundedLabel* context_message_view_; |
| 112 std::vector<views::View*> item_views_; | 124 std::vector<views::View*> item_views_; |
| 113 ProportionalImageView* icon_view_; | 125 ProportionalImageView* icon_view_; |
| 114 views::View* bottom_view_; | 126 views::View* bottom_view_; |
| 115 views::View* image_container_; | 127 views::View* image_container_; |
| 116 ProportionalImageView* image_view_; | 128 ProportionalImageView* image_view_; |
| 117 views::ProgressBar* progress_bar_view_; | 129 views::ProgressBar* progress_bar_view_; |
| 118 std::vector<NotificationButton*> action_buttons_; | 130 std::vector<NotificationButton*> action_buttons_; |
| 119 std::vector<views::View*> separators_; | 131 std::vector<views::View*> separators_; |
| 120 | 132 |
| 121 DISALLOW_COPY_AND_ASSIGN(NotificationView); | 133 DISALLOW_COPY_AND_ASSIGN(NotificationView); |
| 122 }; | 134 }; |
| 123 | 135 |
| 124 } // namespace message_center | 136 } // namespace message_center |
| 125 | 137 |
| 126 #endif // UI_MESSAGE_CENTER_VIEWS_NOTIFICATION_VIEW_H_ | 138 #endif // UI_MESSAGE_CENTER_VIEWS_NOTIFICATION_VIEW_H_ |
| OLD | NEW |