blob: 591816ba202660f98f68da4579941f7a1fc1241c [file] [log] [blame]
[email protected]1d030242012-06-28 18:34:081// 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
3// found in the LICENSE file.
4
[email protected]42341772013-11-13 06:01:595#ifndef UI_AURA_WINDOW_TRACKER_H_
6#define UI_AURA_WINDOW_TRACKER_H_
[email protected]1d030242012-06-28 18:34:087
oshimacabad392015-12-03 17:38:218#include <vector>
[email protected]1d030242012-06-28 18:34:089
avi4ca294112015-12-24 08:04:0910#include "base/macros.h"
Scott Violetefbcd062019-04-26 16:52:2011#include "ui/aura/aura_export.h"
[email protected]1d030242012-06-28 18:34:0812#include "ui/aura/window_observer.h"
13
14namespace aura {
15
Scott Violetefbcd062019-04-26 16:52:2016// This class is used to track an ordered list of Windows. When a Window is
17// destroyed it is removed from the list of Windows.
18class AURA_EXPORT WindowTracker : public WindowObserver {
19 public:
20 // A vector is used for tracking the windows (instead of a set) as some places
21 // care about ordering.
22 using WindowList = std::vector<Window*>;
23
24 explicit WindowTracker(const WindowList& windows);
25 WindowTracker();
26 ~WindowTracker() override;
27
28 // Returns the set of windows being observed.
29 const WindowList& windows() const { return windows_; }
30
31 // Adds |window| to the set of Windows being tracked.
32 void Add(Window* window);
33
34 void RemoveAll();
35
36 // Removes |window| from the set of windows being tracked.
37 void Remove(Window* window);
38
39 Window* Pop();
40
41 // Returns true if |window| was previously added and has not been removed or
42 // deleted.
43 bool Contains(Window* window) const;
44
45 // WindowObserver overrides:
46 void OnWindowDestroying(Window* window) override;
47
48 private:
49 WindowList windows_;
50
51 DISALLOW_COPY_AND_ASSIGN(WindowTracker);
52};
[email protected]1d030242012-06-28 18:34:0853
54} // namespace aura
55
[email protected]42341772013-11-13 06:01:5956#endif // UI_AURA_WINDOW_TRACKER_H_