Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / ui / aura / window_tracker.cc
blob9653e5fcf9ea57dc2b147e0e2f34b6d041cdef9b
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.
5 #include "ui/aura/window_tracker.h"
7 #include "ui/aura/window.h"
9 namespace aura {
11 WindowTracker::WindowTracker() {
14 WindowTracker::~WindowTracker() {
15 for (Windows::iterator i = windows_.begin(); i != windows_.end(); ++i)
16 (*i)->RemoveObserver(this);
19 void WindowTracker::Add(Window* window) {
20 if (windows_.count(window))
21 return;
23 window->AddObserver(this);
24 windows_.insert(window);
27 void WindowTracker::Remove(Window* window) {
28 if (windows_.count(window)) {
29 windows_.erase(window);
30 window->RemoveObserver(this);
34 bool WindowTracker::Contains(Window* window) {
35 return windows_.count(window) > 0;
38 void WindowTracker::OnWindowDestroying(Window* window) {
39 DCHECK_GT(windows_.count(window), 0u);
40 Remove(window);
43 } // namespace aura