Home | History | Annotate | Download | only in browser
      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.
      4 
      5 #ifndef CHROME_BROWSER_IDLE_H_
      6 #define CHROME_BROWSER_IDLE_H_
      7 
      8 #include "base/callback.h"
      9 
     10 enum IdleState {
     11   IDLE_STATE_ACTIVE = 0,
     12   IDLE_STATE_IDLE = 1,    // No activity within threshold.
     13   IDLE_STATE_LOCKED = 2,  // Only available on supported systems.
     14   IDLE_STATE_UNKNOWN = 3  // Used when waiting for the Idle state or in error
     15                           // conditions
     16 };
     17 
     18 // For MacOSX, InitIdleMonitor needs to be called first to setup the monitor.
     19 #if defined(OS_MACOSX)
     20 void InitIdleMonitor();
     21 #endif
     22 
     23 typedef base::Callback<void(IdleState)> IdleCallback;
     24 typedef base::Callback<void(int)> IdleTimeCallback;
     25 
     26 // Calculate the Idle state and notify the callback. |idle_threshold| is the
     27 // amount of time (in seconds) before considered idle. |notify| is
     28 // asynchronously called on some platforms.
     29 void CalculateIdleState(int idle_threshold, IdleCallback notify);
     30 
     31 // Calculate Idle time in seconds and notify the callback
     32 void CalculateIdleTime(IdleTimeCallback notify);
     33 
     34 // Checks synchronously if Idle state is IDLE_STATE_LOCKED.
     35 bool CheckIdleStateIsLocked();
     36 
     37 #endif  // CHROME_BROWSER_IDLE_H_
     38