| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 ASH_COMMON_SYSTEM_TOAST_TOAST_OVERLAY_H_ | 5 #ifndef ASH_COMMON_SYSTEM_TOAST_TOAST_OVERLAY_H_ |
| 6 #define ASH_COMMON_SYSTEM_TOAST_TOAST_OVERLAY_H_ | 6 #define ASH_COMMON_SYSTEM_TOAST_TOAST_OVERLAY_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "ash/ash_export.h" | 10 #include "ash/ash_export.h" |
| 11 #include "base/optional.h" |
| 11 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
| 12 #include "ui/compositor/layer_animation_observer.h" | 13 #include "ui/compositor/layer_animation_observer.h" |
| 13 #include "ui/events/event.h" | 14 #include "ui/events/event.h" |
| 14 #include "ui/events/event_constants.h" | 15 #include "ui/events/event_constants.h" |
| 15 #include "ui/gfx/geometry/size.h" | 16 #include "ui/gfx/geometry/size.h" |
| 16 | 17 |
| 17 namespace gfx { | 18 namespace gfx { |
| 18 class Rect; | 19 class Rect; |
| 19 } | 20 } |
| 20 | 21 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 31 class ASH_EXPORT ToastOverlay : public ui::ImplicitAnimationObserver { | 32 class ASH_EXPORT ToastOverlay : public ui::ImplicitAnimationObserver { |
| 32 public: | 33 public: |
| 33 class ASH_EXPORT Delegate { | 34 class ASH_EXPORT Delegate { |
| 34 public: | 35 public: |
| 35 virtual ~Delegate() {} | 36 virtual ~Delegate() {} |
| 36 virtual void OnClosed() = 0; | 37 virtual void OnClosed() = 0; |
| 37 }; | 38 }; |
| 38 | 39 |
| 39 // Creates the Toast overlay UI. |text| is the message to be shown, and | 40 // Creates the Toast overlay UI. |text| is the message to be shown, and |
| 40 // |dismiss_text| is the message for the button to dismiss the toast message. | 41 // |dismiss_text| is the message for the button to dismiss the toast message. |
| 41 // |dismiss_text| is optional. If empty, the default text is used. | 42 // If |dismiss_text| is null, no dismiss button will be shown. If |
| 43 // |dismiss_text| has a value but the string is empty, the default text is |
| 44 // used. |
| 42 ToastOverlay(Delegate* delegate, | 45 ToastOverlay(Delegate* delegate, |
| 43 const base::string16& text, | 46 const base::string16& text, |
| 44 const base::string16& dismiss_text); | 47 base::Optional<base::string16> dismiss_text); |
| 45 ~ToastOverlay() override; | 48 ~ToastOverlay() override; |
| 46 | 49 |
| 47 // Shows or hides the overlay. | 50 // Shows or hides the overlay. |
| 48 void Show(bool visible); | 51 void Show(bool visible); |
| 49 | 52 |
| 50 private: | 53 private: |
| 51 friend class ToastManagerTest; | 54 friend class ToastManagerTest; |
| 52 | 55 |
| 53 // Returns the current bounds of the overlay, which is based on visibility. | 56 // Returns the current bounds of the overlay, which is based on visibility. |
| 54 gfx::Rect CalculateOverlayBounds(); | 57 gfx::Rect CalculateOverlayBounds(); |
| 55 | 58 |
| 56 // ui::ImplicitAnimationObserver: | 59 // ui::ImplicitAnimationObserver: |
| 57 void OnImplicitAnimationsScheduled() override; | 60 void OnImplicitAnimationsScheduled() override; |
| 58 void OnImplicitAnimationsCompleted() override; | 61 void OnImplicitAnimationsCompleted() override; |
| 59 | 62 |
| 60 views::Widget* widget_for_testing(); | 63 views::Widget* widget_for_testing(); |
| 64 ToastOverlayButton* dismiss_button_for_testing(); |
| 61 void ClickDismissButtonForTesting(const ui::Event& event); | 65 void ClickDismissButtonForTesting(const ui::Event& event); |
| 62 | 66 |
| 63 Delegate* const delegate_; | 67 Delegate* const delegate_; |
| 64 const base::string16 text_; | 68 const base::string16 text_; |
| 65 const base::string16 dismiss_text_; | 69 const base::Optional<base::string16> dismiss_text_; |
| 66 std::unique_ptr<views::Widget> overlay_widget_; | 70 std::unique_ptr<views::Widget> overlay_widget_; |
| 67 std::unique_ptr<ToastOverlayView> overlay_view_; | 71 std::unique_ptr<ToastOverlayView> overlay_view_; |
| 68 gfx::Size widget_size_; | 72 gfx::Size widget_size_; |
| 69 | 73 |
| 70 DISALLOW_COPY_AND_ASSIGN(ToastOverlay); | 74 DISALLOW_COPY_AND_ASSIGN(ToastOverlay); |
| 71 }; | 75 }; |
| 72 | 76 |
| 73 } // namespace ash | 77 } // namespace ash |
| 74 | 78 |
| 75 #endif // ASH_COMMON_SYSTEM_TOAST_TOAST_OVERLAY_H_ | 79 #endif // ASH_COMMON_SYSTEM_TOAST_TOAST_OVERLAY_H_ |
| OLD | NEW |