Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(282)

Side by Side Diff: content/browser/web_contents/web_contents_impl.cc

Issue 946643002: Use PowerSaveBlocker for audio and video on Chrome OS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: apply nits Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/browser/power_save_blocker_x11.cc ('k') | content/public/browser/power_save_blocker.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "content/browser/web_contents/web_contents_impl.h" 5 #include "content/browser/web_contents/web_contents_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 3143 matching lines...) Expand 10 before | Expand all | Expand 10 after
3154 image_download_map_.erase(id); 3154 image_download_map_.erase(id);
3155 } 3155 }
3156 3156
3157 void WebContentsImpl::OnUpdateFaviconURL( 3157 void WebContentsImpl::OnUpdateFaviconURL(
3158 const std::vector<FaviconURL>& candidates) { 3158 const std::vector<FaviconURL>& candidates) {
3159 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 3159 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
3160 DidUpdateFaviconURL(candidates)); 3160 DidUpdateFaviconURL(candidates));
3161 } 3161 }
3162 3162
3163 void WebContentsImpl::CreateAudioPowerSaveBlocker() { 3163 void WebContentsImpl::CreateAudioPowerSaveBlocker() {
3164 // ChromeOS has its own way of handling power save blocks for media.
3165 #if !defined(OS_CHROMEOS)
3166 DCHECK(!audio_power_save_blocker_); 3164 DCHECK(!audio_power_save_blocker_);
3167 audio_power_save_blocker_ = PowerSaveBlocker::Create( 3165 audio_power_save_blocker_ = PowerSaveBlocker::Create(
3168 PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension, "Playing Audio"); 3166 PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension,
3169 #endif 3167 PowerSaveBlocker::kReasonAudioPlayback, "Playing audio");
3170 } 3168 }
3171 3169
3172 void WebContentsImpl::CreateVideoPowerSaveBlocker() { 3170 void WebContentsImpl::CreateVideoPowerSaveBlocker() {
3173 // ChromeOS has its own way of handling power save blocks for media.
3174 #if !defined(OS_CHROMEOS)
3175 DCHECK(!video_power_save_blocker_); 3171 DCHECK(!video_power_save_blocker_);
3176 DCHECK(!active_video_players_.empty()); 3172 DCHECK(!active_video_players_.empty());
3177 video_power_save_blocker_ = PowerSaveBlocker::Create( 3173 video_power_save_blocker_ = PowerSaveBlocker::Create(
3178 PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep, "Playing Video"); 3174 PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep,
3175 PowerSaveBlocker::kReasonVideoPlayback, "Playing video");
3179 #if defined(OS_ANDROID) 3176 #if defined(OS_ANDROID)
3180 static_cast<PowerSaveBlockerImpl*>(video_power_save_blocker_.get()) 3177 static_cast<PowerSaveBlockerImpl*>(video_power_save_blocker_.get())
3181 ->InitDisplaySleepBlocker(GetView()->GetNativeView()); 3178 ->InitDisplaySleepBlocker(GetView()->GetNativeView());
3182 #endif 3179 #endif
3183 #endif
3184 } 3180 }
3185 3181
3186 void WebContentsImpl::MaybeReleasePowerSaveBlockers() { 3182 void WebContentsImpl::MaybeReleasePowerSaveBlockers() {
3187 // If there are no more audio players and we don't have audio stream 3183 // If there are no more audio players and we don't have audio stream
3188 // monitoring, release the audio power save blocker here instead of during 3184 // monitoring, release the audio power save blocker here instead of during
3189 // NotifyNavigationStateChanged(). 3185 // NotifyNavigationStateChanged().
3190 if (active_audio_players_.empty() && 3186 if (active_audio_players_.empty() &&
3191 !AudioStreamMonitor::monitoring_available()) { 3187 !AudioStreamMonitor::monitoring_available()) {
3192 audio_power_save_blocker_.reset(); 3188 audio_power_save_blocker_.reset();
3193 } 3189 }
(...skipping 1319 matching lines...) Expand 10 before | Expand all | Expand 10 after
4513 node->render_manager()->ResumeResponseDeferredAtStart(); 4509 node->render_manager()->ResumeResponseDeferredAtStart();
4514 } 4510 }
4515 4511
4516 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { 4512 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) {
4517 force_disable_overscroll_content_ = force_disable; 4513 force_disable_overscroll_content_ = force_disable;
4518 if (view_) 4514 if (view_)
4519 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); 4515 view_->SetOverscrollControllerEnabled(CanOverscrollContent());
4520 } 4516 }
4521 4517
4522 } // namespace content 4518 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/power_save_blocker_x11.cc ('k') | content/public/browser/power_save_blocker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698