Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(374)

Unified Diff: ash/system/toast/toast_manager.h

Issue 1782793002: Ash: Implement Toasts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add comment Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ash/system/toast/toast_manager.h
diff --git a/ash/system/toast/toast_manager.h b/ash/system/toast/toast_manager.h
new file mode 100644
index 0000000000000000000000000000000000000000..c12feb7c25fd8cd0b8bc2b605c752706d2216d39
--- /dev/null
+++ b/ash/system/toast/toast_manager.h
@@ -0,0 +1,53 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef ASH_SYSTEM_TOAST_TOAST_MANAGER_H_
+#define ASH_SYSTEM_TOAST_TOAST_MANAGER_H_
+
+#include <queue>
+#include <string>
+
+#include "ash/ash_export.h"
+#include "ash/shell_observer.h"
+#include "ash/system/toast/toast_overlay.h"
+#include "base/memory/singleton.h"
+#include "base/threading/thread_checker.h"
+
+namespace ash {
+
+// Class managing toast requests.
+class ASH_EXPORT ToastManager : public ToastOverlay::Delegate {
+ public:
+ ToastManager();
+ ~ToastManager() override;
+
+ // Show a toast. If there are queued toasts, succeeding toasts are queued as
+ // well, and are shown one by one.
+ void Show(const std::string& text, uint64_t duration_ms);
+
+ // ToastOverlay::Delegate overrides:
+ void OnClosed() override;
+
+ private:
+ friend class ToastManagerTest;
+
+ void ShowLatest();
+ void OnDurationPassed(int toast_id);
+
+ int toast_id_for_testing() const { return toast_id_; }
+ ToastOverlay* GetCurrentOverlayForTesting() const { return overlay_.get(); }
oshima 2016/03/15 09:07:32 nit: remove const
yoshiki 2016/03/15 15:04:22 Done.
+ void ResetToastIdForTesting() { toast_id_ = 0; }
+
+ int toast_id_ = 0;
+ std::queue<std::pair<std::string, uint64_t>> queue_;
+ scoped_ptr<ToastOverlay> overlay_;
+
+ base::ThreadChecker thread_checker_;
+
+ DISALLOW_COPY_AND_ASSIGN(ToastManager);
+};
+
+} // namespace ash
+
+#endif // ASH_SYSTEM_TOAST_TOAST_MANAGER_H_

Powered by Google App Engine
This is Rietveld 408576698