summaryrefslogtreecommitdiffstats
path: root/ash/wm/video_detector.cc
diff options
context:
space:
mode:
Diffstat (limited to 'ash/wm/video_detector.cc')
-rw-r--r--ash/wm/video_detector.cc11
1 files changed, 4 insertions, 7 deletions
diff --git a/ash/wm/video_detector.cc b/ash/wm/video_detector.cc
index 07cd4f7..e24a5958 100644
--- a/ash/wm/video_detector.cc
+++ b/ash/wm/video_detector.cc
@@ -51,17 +51,13 @@ class VideoDetector::WindowInfo {
DISALLOW_COPY_AND_ASSIGN(WindowInfo);
};
-VideoDetector::VideoDetector() {
+VideoDetector::VideoDetector()
+ : ALLOW_THIS_IN_INITIALIZER_LIST(observer_manager_(this)) {
aura::Env::GetInstance()->AddObserver(this);
}
VideoDetector::~VideoDetector() {
aura::Env::GetInstance()->RemoveObserver(this);
- for (WindowInfoMap::const_iterator it = window_infos_.begin();
- it != window_infos_.end(); ++it) {
- aura::Window* window = it->first;
- window->RemoveObserver(this);
- }
}
void VideoDetector::AddObserver(VideoDetectorObserver* observer) {
@@ -73,7 +69,7 @@ void VideoDetector::RemoveObserver(VideoDetectorObserver* observer) {
}
void VideoDetector::OnWindowInitialized(aura::Window* window) {
- window->AddObserver(this);
+ observer_manager_.Add(window);
}
void VideoDetector::OnWindowPaintScheduled(aura::Window* window,
@@ -90,6 +86,7 @@ void VideoDetector::OnWindowPaintScheduled(aura::Window* window,
void VideoDetector::OnWindowDestroyed(aura::Window* window) {
window_infos_.erase(window);
+ observer_manager_.Remove(window);
}
void VideoDetector::MaybeNotifyObservers(aura::Window* window,