OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef ASH_SYSTEM_TOAST_TOAST_MANAGER_H_ | |
6 #define ASH_SYSTEM_TOAST_TOAST_MANAGER_H_ | |
7 | |
8 #include <deque> | |
9 #include <memory> | |
10 #include <string> | |
11 | |
12 #include "ash/ash_export.h" | |
13 #include "ash/common/shell_observer.h" | |
14 #include "ash/system/toast/toast_data.h" | |
15 #include "ash/system/toast/toast_overlay.h" | |
16 #include "base/memory/weak_ptr.h" | |
17 #include "base/threading/thread_checker.h" | |
18 | |
19 namespace ash { | |
20 | |
21 // Class managing toast requests. | |
22 class ASH_EXPORT ToastManager : public ToastOverlay::Delegate { | |
23 public: | |
24 ToastManager(); | |
25 ~ToastManager() override; | |
26 | |
27 // Show a toast. If there are queued toasts, succeeding toasts are queued as | |
28 // well, and are shown one by one. | |
29 void Show(const ToastData& data); | |
30 | |
31 void Cancel(const std::string& id); | |
32 | |
33 // ToastOverlay::Delegate overrides: | |
34 void OnClosed() override; | |
35 | |
36 private: | |
37 friend class ToastManagerTest; | |
38 | |
39 void ShowLatest(); | |
40 void OnDurationPassed(int toast_number); | |
41 | |
42 ToastOverlay* GetCurrentOverlayForTesting() { return overlay_.get(); } | |
43 int serial_for_testing() const { return serial_; } | |
44 void ResetSerialForTesting() { serial_ = 0; } | |
45 | |
46 // ID of the toast which is currently shown. Empty if no toast is visible. | |
47 std::string current_toast_id_; | |
48 | |
49 int serial_ = 0; | |
50 std::deque<ToastData> queue_; | |
51 std::unique_ptr<ToastOverlay> overlay_; | |
52 | |
53 base::WeakPtrFactory<ToastManager> weak_ptr_factory_; | |
54 | |
55 DISALLOW_COPY_AND_ASSIGN(ToastManager); | |
56 }; | |
57 | |
58 } // namespace ash | |
59 | |
60 #endif // ASH_SYSTEM_TOAST_TOAST_MANAGER_H_ | |
OLD | NEW |