| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_TOAST_CONTENTS_VIEW_H_ | 5 #ifndef UI_MESSAGE_CENTER_VIEWS_TOAST_CONTENTS_VIEW_H_ |
| 6 #define UI_MESSAGE_CENTER_VIEWS_TOAST_CONTENTS_VIEW_H_ | 6 #define UI_MESSAGE_CENTER_VIEWS_TOAST_CONTENTS_VIEW_H_ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 11 #include "ui/gfx/animation/animation_delegate.h" | 11 #include "ui/gfx/animation/animation_delegate.h" |
| 12 #include "ui/gfx/geometry/point.h" | 12 #include "ui/gfx/geometry/point.h" |
| 13 #include "ui/gfx/geometry/rect.h" | 13 #include "ui/gfx/geometry/rect.h" |
| 14 #include "ui/gfx/geometry/size.h" | 14 #include "ui/gfx/geometry/size.h" |
| 15 #include "ui/message_center/message_center_export.h" |
| 15 #include "ui/message_center/views/message_center_controller.h" | 16 #include "ui/message_center/views/message_center_controller.h" |
| 16 #include "ui/views/widget/widget_delegate.h" | 17 #include "ui/views/widget/widget_delegate.h" |
| 17 | 18 |
| 18 namespace gfx { | 19 namespace gfx { |
| 19 class Animation; | 20 class Animation; |
| 20 class SlideAnimation; | 21 class SlideAnimation; |
| 21 } | 22 } |
| 22 | 23 |
| 23 namespace views { | 24 namespace views { |
| 24 class View; | 25 class View; |
| 25 } | 26 } |
| 26 | 27 |
| 27 namespace message_center { | 28 namespace message_center { |
| 28 | 29 |
| 29 namespace test { | 30 namespace test { |
| 30 class MessagePopupCollectionTest; | 31 class MessagePopupCollectionTest; |
| 31 } | 32 } |
| 32 | 33 |
| 33 class MessagePopupCollection; | 34 class MessagePopupCollection; |
| 34 class MessageView; | 35 class MessageView; |
| 35 class Notification; | 36 class Notification; |
| 36 class PopupAlignmentDelegate; | 37 class PopupAlignmentDelegate; |
| 37 | 38 |
| 38 // The widget host for a popup. Also implements MessageCenterController | 39 // The widget host for a popup. Also implements MessageCenterController |
| 39 // which delegates over to MessagePopupCollection, but takes care about | 40 // which delegates over to MessagePopupCollection, but takes care about |
| 40 // checking the weakref since MessagePopupCollection may disappear before | 41 // checking the weakref since MessagePopupCollection may disappear before |
| 41 // widget/views are closed/destructed. | 42 // widget/views are closed/destructed. |
| 42 class ToastContentsView : public views::WidgetDelegateView, | 43 class MESSAGE_CENTER_EXPORT ToastContentsView |
| 43 public MessageCenterController, | 44 : public views::WidgetDelegateView, |
| 44 public gfx::AnimationDelegate { | 45 public MessageCenterController, |
| 46 public gfx::AnimationDelegate { |
| 45 public: | 47 public: |
| 48 static const char kViewClassName[]; |
| 49 |
| 46 // Computes the size of a toast assuming it will host the given view. | 50 // Computes the size of a toast assuming it will host the given view. |
| 47 static gfx::Size GetToastSizeForView(const views::View* view); | 51 static gfx::Size GetToastSizeForView(const views::View* view); |
| 48 | 52 |
| 49 ToastContentsView(const std::string& notification_id, | 53 ToastContentsView(const std::string& notification_id, |
| 50 PopupAlignmentDelegate* alignment_delegate, | 54 PopupAlignmentDelegate* alignment_delegate, |
| 51 base::WeakPtr<MessagePopupCollection> collection); | 55 base::WeakPtr<MessagePopupCollection> collection); |
| 52 ~ToastContentsView() override; | 56 ~ToastContentsView() override; |
| 53 | 57 |
| 54 // Sets the inner view of the toast. If it has contents already, | 58 // Sets the inner view of the toast. If it has contents already, |
| 55 // |a11y_feedback_for_updates| causes the view to notify that the | 59 // |a11y_feedback_for_updates| causes the view to notify that the |
| 56 // accessibility message should be read after this update. | 60 // accessibility message should be read after this update. |
| 57 void SetContents(MessageView* view, bool a11y_feedback_for_updates); | 61 void SetContents(MessageView* view, bool a11y_feedback_for_updates); |
| 58 | 62 |
| 59 void UpdateContents(const Notification& notification, | 63 void UpdateContents(const Notification& notification, |
| 60 bool a11y_feedback_for_updates); | 64 bool a11y_feedback_for_updates); |
| 61 | 65 |
| 62 // Shows the new toast for the first time, animated. | 66 // Shows the new toast for the first time, animated. |
| 63 // |origin| is the right-bottom corner of the toast. | 67 // |origin| is the right-bottom corner of the toast. |
| 64 void RevealWithAnimation(gfx::Point origin); | 68 void RevealWithAnimation(gfx::Point origin); |
| 65 | 69 |
| 66 // Disconnectes the toast from the rest of the system immediately and start | 70 // Disconnectes the toast from the rest of the system immediately and start |
| 67 // an animation. Once animation finishes, closes the widget. | 71 // an animation. Once animation finishes, closes the widget. |
| 68 void CloseWithAnimation(); | 72 void CloseWithAnimation(); |
| 69 | 73 |
| 70 void SetBoundsWithAnimation(gfx::Rect new_bounds); | 74 void SetBoundsWithAnimation(gfx::Rect new_bounds); |
| 71 | 75 |
| 76 // Makes the toast activatable, then activate. |
| 77 void ActivateToast(); |
| 78 |
| 72 // Origin and bounds are not 'instant', but rather 'current stable values', | 79 // Origin and bounds are not 'instant', but rather 'current stable values', |
| 73 // there could be animation in progress that targets these values. | 80 // there could be animation in progress that targets these values. |
| 74 gfx::Point origin() { return origin_; } | 81 gfx::Point origin() { return origin_; } |
| 75 gfx::Rect bounds() { return gfx::Rect(origin_, preferred_size_); } | 82 gfx::Rect bounds() { return gfx::Rect(origin_, preferred_size_); } |
| 76 | 83 |
| 77 const std::string& id() const { return id_; } | 84 const std::string& id() const { return id_; } |
| 78 | 85 |
| 79 // Overridden from views::View: | 86 // Overridden from views::View: |
| 80 void OnMouseEntered(const ui::MouseEvent& event) override; | 87 void OnMouseEntered(const ui::MouseEvent& event) override; |
| 81 void OnMouseExited(const ui::MouseEvent& event) override; | 88 void OnMouseExited(const ui::MouseEvent& event) override; |
| 82 void Layout() override; | 89 void Layout() override; |
| 83 gfx::Size GetPreferredSize() const override; | 90 gfx::Size GetPreferredSize() const override; |
| 84 void GetAccessibleNodeData(ui::AXNodeData* node_data) override; | 91 void GetAccessibleNodeData(ui::AXNodeData* node_data) override; |
| 92 const char* GetClassName() const override; |
| 85 | 93 |
| 86 private: | 94 private: |
| 87 friend class test::MessagePopupCollectionTest; | 95 friend class test::MessagePopupCollectionTest; |
| 88 | 96 |
| 89 // Overridden from MessageCenterController: | 97 // Overridden from MessageCenterController: |
| 90 void ClickOnNotification(const std::string& notification_id) override; | 98 void ClickOnNotification(const std::string& notification_id) override; |
| 91 void RemoveNotification(const std::string& notification_id, | 99 void RemoveNotification(const std::string& notification_id, |
| 92 bool by_user) override; | 100 bool by_user) override; |
| 93 std::unique_ptr<ui::MenuModel> CreateMenuModel( | 101 std::unique_ptr<ui::MenuModel> CreateMenuModel( |
| 94 const NotifierId& notifier_id, | 102 const NotifierId& notifier_id, |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 | 153 |
| 146 gfx::Point origin_; | 154 gfx::Point origin_; |
| 147 gfx::Size preferred_size_; | 155 gfx::Size preferred_size_; |
| 148 | 156 |
| 149 DISALLOW_COPY_AND_ASSIGN(ToastContentsView); | 157 DISALLOW_COPY_AND_ASSIGN(ToastContentsView); |
| 150 }; | 158 }; |
| 151 | 159 |
| 152 } // namespace message_center | 160 } // namespace message_center |
| 153 | 161 |
| 154 #endif // UI_MESSAGE_CENTER_VIEWS_TOAST_CONTENTS_VIEW_H_ | 162 #endif // UI_MESSAGE_CENTER_VIEWS_TOAST_CONTENTS_VIEW_H_ |
| OLD | NEW |