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 #include "ash/wm/video_detector.h" | 5 #include "ash/wm/video_detector.h" |
6 | 6 |
7 #include "ash/public/cpp/shell_window_ids.h" | 7 #include "ash/public/cpp/shell_window_ids.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "ash/wm/window_state.h" | 9 #include "ash/wm/window_state.h" |
10 #include "ash/wm_window.h" | 10 #include "ash/wm_window.h" |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 window_observer_manager_.Remove(window); | 140 window_observer_manager_.Remove(window); |
141 } | 141 } |
142 | 142 |
143 void VideoDetector::OnChromeTerminating() { | 143 void VideoDetector::OnChromeTerminating() { |
144 // Stop checking video activity once the shutdown | 144 // Stop checking video activity once the shutdown |
145 // process starts. crbug.com/231696. | 145 // process starts. crbug.com/231696. |
146 is_shutting_down_ = true; | 146 is_shutting_down_ = true; |
147 } | 147 } |
148 | 148 |
149 void VideoDetector::OnFullscreenStateChanged(bool is_fullscreen, | 149 void VideoDetector::OnFullscreenStateChanged(bool is_fullscreen, |
150 WmWindow* root_window) { | 150 aura::Window* root_window) { |
151 aura::Window* aura_window = root_window->aura_window(); | 151 if (is_fullscreen && !fullscreen_root_windows_.count(root_window)) { |
152 if (is_fullscreen && !fullscreen_root_windows_.count(aura_window)) { | 152 fullscreen_root_windows_.insert(root_window); |
153 fullscreen_root_windows_.insert(aura_window); | 153 if (!window_observer_manager_.IsObserving(root_window)) |
154 if (!window_observer_manager_.IsObserving(aura_window)) | 154 window_observer_manager_.Add(root_window); |
155 window_observer_manager_.Add(aura_window); | |
156 UpdateState(); | 155 UpdateState(); |
157 } else if (!is_fullscreen && fullscreen_root_windows_.count(aura_window)) { | 156 } else if (!is_fullscreen && fullscreen_root_windows_.count(root_window)) { |
158 fullscreen_root_windows_.erase(aura_window); | 157 fullscreen_root_windows_.erase(root_window); |
159 window_observer_manager_.Remove(aura_window); | 158 window_observer_manager_.Remove(root_window); |
160 UpdateState(); | 159 UpdateState(); |
161 } | 160 } |
162 } | 161 } |
163 | 162 |
164 void VideoDetector::HandleVideoActivity(aura::Window* window, | 163 void VideoDetector::HandleVideoActivity(aura::Window* window, |
165 base::TimeTicks now) { | 164 base::TimeTicks now) { |
166 if (!window->IsVisible()) | 165 if (!window->IsVisible()) |
167 return; | 166 return; |
168 | 167 |
169 gfx::Rect root_bounds = window->GetRootWindow()->bounds(); | 168 gfx::Rect root_bounds = window->GetRootWindow()->bounds(); |
(...skipping 20 matching lines...) Expand all Loading... |
190 } | 189 } |
191 | 190 |
192 if (state_ != new_state) { | 191 if (state_ != new_state) { |
193 state_ = new_state; | 192 state_ = new_state; |
194 for (auto& observer : observers_) | 193 for (auto& observer : observers_) |
195 observer.OnVideoStateChanged(state_); | 194 observer.OnVideoStateChanged(state_); |
196 } | 195 } |
197 } | 196 } |
198 | 197 |
199 } // namespace ash | 198 } // namespace ash |
OLD | NEW |