| 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 "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "ui/message_center/message_center_export.h" | 12 #include "ui/message_center/message_center_export.h" |
| 13 #include "ui/message_center/views/message_view.h" | 13 #include "ui/message_center/views/message_view.h" |
| 14 #include "ui/views/view_targeter_delegate.h" | 14 #include "ui/views/view_targeter_delegate.h" |
| 15 | 15 |
| 16 class GURL; | 16 class GURL; |
| 17 | 17 |
| 18 namespace views { | 18 namespace views { |
| 19 class ProgressBar; | 19 class ProgressBar; |
| 20 } | 20 } |
| 21 | 21 |
| 22 namespace message_center { | 22 namespace message_center { |
| 23 | 23 |
| 24 class BoundedLabel; | 24 class BoundedLabel; |
| 25 class MessageCenter; | 25 class MessageCenter; |
| 26 class NotificationButton; | 26 class NotificationButton; |
| 27 class NotificationProgressBarBase; | 27 class NotificationProgressBarBase; |
| 28 class NotificationView; | |
| 29 class PaddedButton; | 28 class PaddedButton; |
| 30 class ProportionalImageView; | 29 class ProportionalImageView; |
| 31 | 30 |
| 32 // View that displays all current types of notification (web, basic, image, and | 31 // View that displays all current types of notification (web, basic, image, and |
| 33 // list). Future notification types may be handled by other classes, in which | 32 // list) except the custom notification. Future notification types may be |
| 34 // case instances of those classes would be returned by the Create() factory | 33 // handled by other classes, in which case instances of those classes would be |
| 35 // method below. | 34 // returned by the Create() factory method below. |
| 36 class MESSAGE_CENTER_EXPORT NotificationView | 35 class MESSAGE_CENTER_EXPORT NotificationView |
| 37 : public MessageView, | 36 : public MessageView, |
| 38 public views::ViewTargeterDelegate { | 37 public views::ViewTargeterDelegate { |
| 39 public: | 38 public: |
| 40 // Creates appropriate MessageViews for notifications. Those currently are | 39 NotificationView(MessageCenterController* controller, |
| 41 // always NotificationView instances but in the future | 40 const Notification& notification); |
| 42 // may be instances of other classes, with the class depending on the | |
| 43 // notification type. A notification is top level if it needs to be rendered | |
| 44 // outside the browser window. No custom shadows are created for top level | |
| 45 // notifications on Linux with Aura. | |
| 46 // |controller| may be NULL, but has to be set before the view is shown. | |
| 47 static MessageView* Create(MessageCenterController* controller, | |
| 48 const Notification& notification, | |
| 49 bool top_level); | |
| 50 ~NotificationView() override; | 41 ~NotificationView() override; |
| 51 | 42 |
| 52 // Overridden from views::View: | 43 // Overridden from views::View: |
| 53 gfx::Size GetPreferredSize() const override; | 44 gfx::Size GetPreferredSize() const override; |
| 54 int GetHeightForWidth(int width) const override; | 45 int GetHeightForWidth(int width) const override; |
| 55 void Layout() override; | 46 void Layout() override; |
| 56 void OnFocus() override; | 47 void OnFocus() override; |
| 57 void ScrollRectToVisible(const gfx::Rect& rect) override; | 48 void ScrollRectToVisible(const gfx::Rect& rect) override; |
| 58 gfx::NativeCursor GetCursor(const ui::MouseEvent& event) override; | 49 gfx::NativeCursor GetCursor(const ui::MouseEvent& event) override; |
| 59 | 50 |
| 60 // Overridden from MessageView: | 51 // Overridden from MessageView: |
| 61 void UpdateWithNotification(const Notification& notification) override; | 52 void UpdateWithNotification(const Notification& notification) override; |
| 62 void ButtonPressed(views::Button* sender, const ui::Event& event) override; | 53 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
| 63 | 54 |
| 64 protected: | |
| 65 NotificationView(MessageCenterController* controller, | |
| 66 const Notification& notification); | |
| 67 | |
| 68 private: | 55 private: |
| 69 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, CreateOrUpdateTest); | 56 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, CreateOrUpdateTest); |
| 70 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, | 57 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, |
| 71 CreateOrUpdateTestSettingsButton); | 58 CreateOrUpdateTestSettingsButton); |
| 72 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, FormatContextMessageTest); | 59 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, FormatContextMessageTest); |
| 73 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, SettingsButtonTest); | 60 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, SettingsButtonTest); |
| 74 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, TestLineLimits); | 61 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, TestLineLimits); |
| 75 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, TestIconSizing); | 62 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, TestIconSizing); |
| 76 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, TestImageSizing); | 63 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, TestImageSizing); |
| 77 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, UpdateButtonsStateTest); | 64 FRIEND_TEST_ALL_PREFIXES(NotificationViewTest, UpdateButtonsStateTest); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 NotificationProgressBarBase* progress_bar_view_ = nullptr; | 108 NotificationProgressBarBase* progress_bar_view_ = nullptr; |
| 122 std::vector<NotificationButton*> action_buttons_; | 109 std::vector<NotificationButton*> action_buttons_; |
| 123 std::vector<views::View*> separators_; | 110 std::vector<views::View*> separators_; |
| 124 | 111 |
| 125 DISALLOW_COPY_AND_ASSIGN(NotificationView); | 112 DISALLOW_COPY_AND_ASSIGN(NotificationView); |
| 126 }; | 113 }; |
| 127 | 114 |
| 128 } // namespace message_center | 115 } // namespace message_center |
| 129 | 116 |
| 130 #endif // UI_MESSAGE_CENTER_VIEWS_NOTIFICATION_VIEW_H_ | 117 #endif // UI_MESSAGE_CENTER_VIEWS_NOTIFICATION_VIEW_H_ |
| OLD | NEW |