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

Side by Side Diff: ui/aura/window_tracker.h

Issue 1489843003: [WIP: Not for review] Simplify and unify widget/window show logic Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // 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 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_AURA_WINDOW_TRACKER_H_ 5 #ifndef UI_AURA_WINDOW_TRACKER_H_
6 #define UI_AURA_WINDOW_TRACKER_H_ 6 #define UI_AURA_WINDOW_TRACKER_H_
7 7
8 #include <set> 8 #include <set>
9 #include <vector>
9 10
10 #include "base/basictypes.h" 11 #include "base/basictypes.h"
11 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
12 #include "ui/aura/aura_export.h" 13 #include "ui/aura/aura_export.h"
13 #include "ui/aura/window_observer.h" 14 #include "ui/aura/window_observer.h"
14 15
15 namespace aura { 16 namespace aura {
16 17
17 // This class keeps track of a set of windows. A Window is removed either 18 // This class keeps track of a set of windows. A Window is removed either
18 // explicitly by Remove(), or implicitly when the window is destroyed. 19 // explicitly by Remove() or Pop(), or implicitly when the window is destroyed.
19 class AURA_EXPORT WindowTracker : public WindowObserver { 20 class AURA_EXPORT WindowTracker : public WindowObserver {
20 public: 21 public:
21 typedef std::set<Window*> Windows; 22 typedef std::set<Window*> Windows;
23 using WindowList = std::vector<Window*>;
22 24
23 WindowTracker(); 25 WindowTracker();
26 explicit WindowTracker(const WindowList& windows);
24 ~WindowTracker() override; 27 ~WindowTracker() override;
25 28
29 bool has_windows() const { return !windows_.empty(); }
30
26 // Returns the set of windows being observed. 31 // Returns the set of windows being observed.
27 const std::set<Window*>& windows() const { return windows_; } 32 const std::set<Window*>& windows() const { return windows_; }
28 33
29 // Adds |window| to the set of Windows being tracked. 34 // Adds |window| to the set of Windows being tracked.
30 void Add(Window* window); 35 void Add(Window* window);
31 36
32 // Removes |window| from the set of windows being tracked. 37 // Removes |window| from the set of windows being tracked.
33 void Remove(Window* window); 38 void Remove(Window* window);
34 39
35 // Returns true if |window| was previously added and has not been removed or 40 // Returns true if |window| was previously added and has not been removed or
36 // deleted. 41 // deleted.
37 bool Contains(Window* window); 42 bool Contains(Window* window);
38 43
44 // Removes and returns the window object from the tracking windows.
45 aura::Window* Pop();
46
39 // WindowObserver overrides: 47 // WindowObserver overrides:
40 void OnWindowDestroying(Window* window) override; 48 void OnWindowDestroying(Window* window) override;
41 49
42 private: 50 private:
43 Windows windows_; 51 Windows windows_;
44 52
45 DISALLOW_COPY_AND_ASSIGN(WindowTracker); 53 DISALLOW_COPY_AND_ASSIGN(WindowTracker);
46 }; 54 };
47 55
48 } // namespace aura 56 } // namespace aura
49 57
50 #endif // UI_AURA_WINDOW_TRACKER_H_ 58 #endif // UI_AURA_WINDOW_TRACKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698