OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/browser/media/media_web_contents_observer.h" | 5 #include "content/browser/media/media_web_contents_observer.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 #include "content/browser/media/audible_metrics.h" | 10 #include "content/browser/media/audible_metrics.h" |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension, | 147 PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension, |
148 PowerSaveBlocker::kReasonAudioPlayback, "Playing audio"); | 148 PowerSaveBlocker::kReasonAudioPlayback, "Playing audio"); |
149 } | 149 } |
150 | 150 |
151 void MediaWebContentsObserver::CreateVideoPowerSaveBlocker() { | 151 void MediaWebContentsObserver::CreateVideoPowerSaveBlocker() { |
152 DCHECK(!video_power_save_blocker_); | 152 DCHECK(!video_power_save_blocker_); |
153 DCHECK(!active_video_players_.empty()); | 153 DCHECK(!active_video_players_.empty()); |
154 video_power_save_blocker_ = PowerSaveBlocker::Create( | 154 video_power_save_blocker_ = PowerSaveBlocker::Create( |
155 PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep, | 155 PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep, |
156 PowerSaveBlocker::kReasonVideoPlayback, "Playing video"); | 156 PowerSaveBlocker::kReasonVideoPlayback, "Playing video"); |
157 // TODO(mfomitchev): Support PowerSaveBlocker on Aura - crbug.com/546718. | 157 #if defined(OS_ANDROID) |
158 #if defined(OS_ANDROID) && !defined(USE_AURA) | |
159 static_cast<PowerSaveBlockerImpl*>(video_power_save_blocker_.get()) | 158 static_cast<PowerSaveBlockerImpl*>(video_power_save_blocker_.get()) |
160 ->InitDisplaySleepBlocker(web_contents()); | 159 ->InitDisplaySleepBlocker(web_contents()); |
161 #endif | 160 #endif |
162 } | 161 } |
163 | 162 |
164 void MediaWebContentsObserver::WasShown() { | 163 void MediaWebContentsObserver::WasShown() { |
165 // Restore power save blocker if there are active video players running. | 164 // Restore power save blocker if there are active video players running. |
166 if (!active_video_players_.empty() && !video_power_save_blocker_) | 165 if (!active_video_players_.empty() && !video_power_save_blocker_) |
167 CreateVideoPowerSaveBlocker(); | 166 CreateVideoPowerSaveBlocker(); |
168 } | 167 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 if (it == player_map->end()) | 225 if (it == player_map->end()) |
227 return; | 226 return; |
228 | 227 |
229 for (int64_t player_cookie : it->second) | 228 for (int64_t player_cookie : it->second) |
230 removed_players->insert(MediaPlayerId(render_frame_host, player_cookie)); | 229 removed_players->insert(MediaPlayerId(render_frame_host, player_cookie)); |
231 | 230 |
232 player_map->erase(it); | 231 player_map->erase(it); |
233 } | 232 } |
234 | 233 |
235 } // namespace content | 234 } // namespace content |
OLD | NEW |