1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. Use of this 2 // source code is governed by a BSD-style license that can be found in the 3 // LICENSE file. 4 5 var history_log = []; 6 7 /** 8 * Stores a state every time an "active" event is sent, up to 20 items. 9 */ 10 chrome.idle.onStateChanged.addListener(function(newstate) { 11 var time = new Date(); 12 if (history_log.length >= 20) { 13 history_log.pop(); 14 } 15 history_log.unshift({'state':newstate, 'time':time}); 16 }); 17 18 /** 19 * Opens history.html when the browser action is clicked. 20 * Used window.open because I didn't want the tabs permission. 21 */ 22 chrome.browserAction.onClicked.addListener(function() { 23 window.open('history.html', 'testwindow', 'width=700,height=600'); 24 }); 25