diff options
author | derat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-27 22:28:44 +0000 |
---|---|---|
committer | derat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-27 22:28:44 +0000 |
commit | 76c9c1c32e9707d4d2732c5c6dc81b30591a7728 (patch) | |
tree | f67d89fb80cb592e3ccdcb43fea1169f7df4a70e /ash/system | |
parent | 23aad08f087d3a65acba3a177a45df8cd8be48f4 (diff) | |
download | chromium_src-76c9c1c32e9707d4d2732c5c6dc81b30591a7728.zip chromium_src-76c9c1c32e9707d4d2732c5c6dc81b30591a7728.tar.gz chromium_src-76c9c1c32e9707d4d2732c5c6dc81b30591a7728.tar.bz2 |
chromeos: Don't report video while screen is locked.
Avoid reporting video activity to powerd while the screen is
locked.
BUG=338392
Review URL: https://codereview.chromium.org/140973004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@247324 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/system')
-rw-r--r-- | ash/system/chromeos/power/video_activity_notifier.cc | 12 | ||||
-rw-r--r-- | ash/system/chromeos/power/video_activity_notifier.h | 9 |
2 files changed, 19 insertions, 2 deletions
diff --git a/ash/system/chromeos/power/video_activity_notifier.cc b/ash/system/chromeos/power/video_activity_notifier.cc index 0f9ec25..8a82fb3 100644 --- a/ash/system/chromeos/power/video_activity_notifier.cc +++ b/ash/system/chromeos/power/video_activity_notifier.cc @@ -19,15 +19,21 @@ const int kNotifyIntervalSec = 5; } // namespace VideoActivityNotifier::VideoActivityNotifier(VideoDetector* detector) - : detector_(detector) { + : detector_(detector), + screen_is_locked_(false) { detector_->AddObserver(this); + ash::Shell::GetInstance()->AddShellObserver(this); } VideoActivityNotifier::~VideoActivityNotifier() { + ash::Shell::GetInstance()->RemoveShellObserver(this); detector_->RemoveObserver(this); } void VideoActivityNotifier::OnVideoDetected(bool is_fullscreen) { + if (screen_is_locked_) + return; + base::TimeTicks now = base::TimeTicks::Now(); if (last_notify_time_.is_null() || (now - last_notify_time_).InSeconds() >= kNotifyIntervalSec) { @@ -37,5 +43,9 @@ void VideoActivityNotifier::OnVideoDetected(bool is_fullscreen) { } } +void VideoActivityNotifier::OnLockStateChanged(bool locked) { + screen_is_locked_ = locked; +} + } // namespace internal } // namespace ash diff --git a/ash/system/chromeos/power/video_activity_notifier.h b/ash/system/chromeos/power/video_activity_notifier.h index 66569c4..ae57d28 100644 --- a/ash/system/chromeos/power/video_activity_notifier.h +++ b/ash/system/chromeos/power/video_activity_notifier.h @@ -14,7 +14,8 @@ namespace ash { namespace internal { // Notifies the power manager when a video is playing. -class VideoActivityNotifier : public VideoDetectorObserver { +class VideoActivityNotifier : public VideoDetectorObserver, + public ShellObserver { public: explicit VideoActivityNotifier(VideoDetector* detector); virtual ~VideoActivityNotifier(); @@ -22,12 +23,18 @@ class VideoActivityNotifier : public VideoDetectorObserver { // VideoDetectorObserver implementation. virtual void OnVideoDetected(bool is_fullscreen) OVERRIDE; + // ShellObserver implementation. + virtual void OnLockStateChanged(bool locked) OVERRIDE; + private: VideoDetector* detector_; // not owned // Last time that the power manager was notified. base::TimeTicks last_notify_time_; + // True if the screen is currently locked. + bool screen_is_locked_; + DISALLOW_COPY_AND_ASSIGN(VideoActivityNotifier); }; |