Index: chrome/browser/resources/chromeos/idle_logout_dialog.js |
diff --git a/chrome/browser/resources/chromeos/idle_logout_dialog.js b/chrome/browser/resources/chromeos/idle_logout_dialog.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..bdcef0144aba23990e7dc1de91a406a0889fc002 |
--- /dev/null |
+++ b/chrome/browser/resources/chromeos/idle_logout_dialog.js |
@@ -0,0 +1,47 @@ |
+// 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. |
+ |
+var localStrings; |
+ |
+// Timer that will check and update the countdown every second. |
+var countdownTimer; |
+// Time at which we should logout the user unless we've been closed. |
+var logoutTime; // ms |
+ |
+/** |
+ * Decrements the countdown timer and updates the display on the dialog. |
+ */ |
+function decrementTimer() { |
+ var currentTime = Date.now(); |
+ if (logoutTime > currentTime) { |
+ secondsToRestart = Math.round((logoutTime - currentTime) / 1000); |
+ $('warning').innerHTML = localStrings.getStringF('warning', |
+ secondsToRestart); |
+ } else { |
+ clearInterval(countdownTimer); |
+ chrome.send('requestLogout'); |
+ } |
+} |
+ |
+/** |
+ * Starts the countdown to logout. |
+ */ |
+function startCountdown(seconds) { |
+ logoutTime = Date.now() + seconds * 1000; |
+ $('warning').innerHTML = localStrings.getStringF('warning', |
+ seconds); |
+ countdownTimer = setInterval(decrementTimer, 1000); |
+} |
+ |
+/** |
+ * Inserts translated strings on loading. |
+ */ |
+function initialize() { |
+ localStrings = new LocalStrings(); |
+ |
+ i18nTemplate.process(document, templateData); |
+ chrome.send('requestCountdown'); |
+} |
+ |
+document.addEventListener('DOMContentLoaded', initialize); |