Add test for the TermsOfServiceURL policy
[chromium-blink-merge.git] / chrome / browser / chromeos / power / video_activity_notifier.cc
bloba92dcac2aa7ee4f070f90c123b0650a61b8848af
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
3 // found in the LICENSE file.
5 #include "chrome/browser/chromeos/power/video_activity_notifier.h"
7 #include "ash/shell.h"
8 #include "chromeos/dbus/dbus_thread_manager.h"
9 #include "chromeos/dbus/power_manager_client.h"
11 namespace {
13 // Minimum number of seconds between notifications.
14 const int kNotifyIntervalSec = 5;
16 } // namespace
18 namespace chromeos {
20 VideoActivityNotifier::VideoActivityNotifier() {
21 ash::Shell::GetInstance()->video_detector()->AddObserver(this);
24 VideoActivityNotifier::~VideoActivityNotifier() {
25 ash::Shell::GetInstance()->video_detector()->RemoveObserver(this);
28 void VideoActivityNotifier::OnVideoDetected(bool is_fullscreen) {
29 base::TimeTicks now = base::TimeTicks::Now();
30 if (last_notify_time_.is_null() ||
31 (now - last_notify_time_).InSeconds() >= kNotifyIntervalSec) {
32 DBusThreadManager::Get()->GetPowerManagerClient()->
33 NotifyVideoActivity(now, is_fullscreen);
34 last_notify_time_ = now;
38 } // namespace chromeos