1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ash/system/chromeos/power/video_activity_notifier.h"
8 #include "chromeos/dbus/dbus_thread_manager.h"
9 #include "chromeos/dbus/power_manager_client.h"
14 // Minimum number of seconds between notifications.
15 const int kNotifyIntervalSec
= 5;
19 VideoActivityNotifier::VideoActivityNotifier(VideoDetector
* detector
)
20 : detector_(detector
),
21 screen_is_locked_(false) {
22 detector_
->AddObserver(this);
23 ash::Shell::GetInstance()->AddShellObserver(this);
26 VideoActivityNotifier::~VideoActivityNotifier() {
27 ash::Shell::GetInstance()->RemoveShellObserver(this);
28 detector_
->RemoveObserver(this);
31 void VideoActivityNotifier::OnVideoDetected(bool is_fullscreen
) {
32 if (screen_is_locked_
)
35 base::TimeTicks now
= base::TimeTicks::Now();
36 if (last_notify_time_
.is_null() ||
37 (now
- last_notify_time_
).InSeconds() >= kNotifyIntervalSec
) {
38 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
39 NotifyVideoActivity(is_fullscreen
);
40 last_notify_time_
= now
;
44 void VideoActivityNotifier::OnLockStateChanged(bool locked
) {
45 screen_is_locked_
= locked
;