gecko-dev/toolkit/components/extensions/ext-idle.js
Bob Silverberg 55812c7f73 Bug 1299846 - Complete the implementation of chrome.idle.queryState, r=kmag
MozReview-Commit-ID: jYsePeTluZ

--HG--
extra : rebase_source : 56da3e22cdd1d3f28a8f56ae969be63af4995432
2016-09-01 09:28:56 -04:00

18 lines
535 B
JavaScript

"use strict";
XPCOMUtils.defineLazyServiceGetter(this, "idleService",
"@mozilla.org/widget/idleservice;1",
"nsIIdleService");
extensions.registerSchemaAPI("idle", "addon_parent", context => {
return {
idle: {
queryState: function(detectionIntervalInSeconds) {
if (idleService.idleTime < detectionIntervalInSeconds * 1000) {
return Promise.resolve("active");
}
return Promise.resolve("idle");
},
},
};
});