| OLD | NEW |
| 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_LIFE_TRACKER_H_ | 5 #ifndef UI_AURA_WINDOW_LIFE_TRACKER_H_ |
| 6 #define UI_AURA_WINDOW_LIFE_TRACKER_H_ | 6 #define UI_AURA_WINDOW_LIFE_TRACKER_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "ui/aura/aura_export.h" | 12 #include "ui/aura/aura_export.h" |
| 13 #include "ui/aura/window_observer.h" | 13 #include "ui/aura/window_observer.h" |
| 14 | 14 |
| 15 namespace aura { | 15 namespace aura { |
| 16 | 16 |
| 17 // This class keeps track of a set of windows. A Window is removed either | 17 // 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. | 18 // explicitly by Remove(), or implicitly when the window is destroyed. |
| 19 class AURA_EXPORT WindowTracker : public WindowObserver { | 19 class AURA_EXPORT WindowTracker : public WindowObserver { |
| 20 public: | 20 public: |
| 21 typedef std::set<Window*> Windows; |
| 22 |
| 21 WindowTracker(); | 23 WindowTracker(); |
| 22 virtual ~WindowTracker(); | 24 virtual ~WindowTracker(); |
| 23 | 25 |
| 26 // Returns the set of windows being observed. |
| 27 const std::set<Window*>& windows() const { return windows_; } |
| 28 |
| 24 // Adds |window| to the set of Windows being tracked. | 29 // Adds |window| to the set of Windows being tracked. |
| 25 void Add(Window* window); | 30 void Add(Window* window); |
| 26 | 31 |
| 27 // Removes |window| from the set of windows being tracked. | 32 // Removes |window| from the set of windows being tracked. |
| 28 void Remove(Window* window); | 33 void Remove(Window* window); |
| 29 | 34 |
| 30 // Returns true if |window| was previously added and has not been removed or | 35 // Returns true if |window| was previously added and has not been removed or |
| 31 // deleted. | 36 // deleted. |
| 32 bool Contains(Window* window); | 37 bool Contains(Window* window); |
| 33 | 38 |
| 34 // WindowObserver overrides: | 39 // WindowObserver overrides: |
| 35 virtual void OnWindowDestroying(Window* window) OVERRIDE; | 40 virtual void OnWindowDestroying(Window* window) OVERRIDE; |
| 36 | 41 |
| 37 private: | 42 private: |
| 38 typedef std::set<Window*> Windows; | |
| 39 | |
| 40 Windows windows_; | 43 Windows windows_; |
| 41 | 44 |
| 42 DISALLOW_COPY_AND_ASSIGN(WindowTracker); | 45 DISALLOW_COPY_AND_ASSIGN(WindowTracker); |
| 43 }; | 46 }; |
| 44 | 47 |
| 45 } // namespace aura | 48 } // namespace aura |
| 46 | 49 |
| 47 #endif // UI_AURA_WINDOW_LIFE_TRACKER_H_ | 50 #endif // UI_AURA_WINDOW_LIFE_TRACKER_H_ |
| OLD | NEW |