summaryrefslogtreecommitdiff
path: root/chromium/ui/base/idle/idle_chromeos.cc
blob: 0a382849b79f4d8fbf79d3b44d365d889593cc54 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ui/base/idle/idle.h"

#include "base/time/time.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/session_manager_client.h"
#include "ui/base/user_activity/user_activity_detector.h"

namespace ui {

void CalculateIdleTime(IdleTimeCallback notify) {
  base::TimeDelta idle_time = base::TimeTicks::Now() -
      ui::UserActivityDetector::Get()->last_activity_time();
  notify.Run(static_cast<int>(idle_time.InSeconds()));
}

bool CheckIdleStateIsLocked() {
  return chromeos::DBusThreadManager::Get()->GetSessionManagerClient()->
      IsScreenLocked();
}

}  // namespace ui