Google Chrome Extensions

chrome.idle

Manifest

You must declare the "idle" permission in your extension's manifest to use the idle API. For example:

{
  "name": "My extension",
  ...
  "permissions": [
    "idle"
  ],
  ...
}

API Reference: chrome.idle

Methods

queryState

chrome.idle.queryState(integer thresholdSeconds)

Returns the current state of the browser.

Parameters

thresholdSeconds ( integer )
Threshold, in seconds, used to determine when a machine is in the idle state.

Callback function

The callback parameter should specify a function that looks like this:

function(enumerated string ["active""idle""locked"] newState) {...};
newState ( enumerated string ["active""idle""locked"] )

Events

onStateChanged

chrome.idle.onStateChanged.addListener(function(enumerated string ["active"] newState) {...});

Fired when the browser changes to an active state. Currently only reports the transition from idle to active.

Listener Parameters

newState ( enumerated string ["active"] )

Sample Extensions that use chrome.idle

  • Idle - Simple Example – Demonstrates the Idle API