| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ui/aura/window_tracker.h" | |
| 6 | |
| 7 #include "ui/aura/window.h" | |
| 8 | |
| 9 namespace aura { | |
| 10 | |
| 11 WindowTracker::WindowTracker() { | |
| 12 } | |
| 13 | |
| 14 WindowTracker::~WindowTracker() { | |
| 15 for (Windows::iterator i = windows_.begin(); i != windows_.end(); ++i) | |
| 16 (*i)->RemoveObserver(this); | |
| 17 } | |
| 18 | |
| 19 void WindowTracker::Add(Window* window) { | |
| 20 if (windows_.count(window)) | |
| 21 return; | |
| 22 | |
| 23 window->AddObserver(this); | |
| 24 windows_.insert(window); | |
| 25 } | |
| 26 | |
| 27 void WindowTracker::Remove(Window* window) { | |
| 28 if (windows_.count(window)) { | |
| 29 windows_.erase(window); | |
| 30 window->RemoveObserver(this); | |
| 31 } | |
| 32 } | |
| 33 | |
| 34 bool WindowTracker::Contains(Window* window) { | |
| 35 return windows_.count(window) > 0; | |
| 36 } | |
| 37 | |
| 38 void WindowTracker::OnWindowDestroying(Window* window) { | |
| 39 DCHECK_GT(windows_.count(window), 0u); | |
| 40 Remove(window); | |
| 41 } | |
| 42 | |
| 43 } // namespace aura | |
| OLD | NEW |