Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(300)

Unified Diff: chrome/browser/resources/chromeos/idle_logout_dialog.js

Issue 9568038: Implement the auto-logout on idle feature for Kiosk mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..bdbb91cac93aa4c48d784c874161e9b38ac577a0
--- /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();
arv (Not doing code reviews) 2012/03/02 21:01:21 Date.now() Maybe you should add a test to ensure
rkc 2012/03/02 21:47:09 Fixed and tested manually. I've dedicated all of
+ 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);
arv (Not doing code reviews) 2012/03/02 21:01:21 useless parentheses
rkc 2012/03/02 21:47:09 Done.
+ $('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);
« no previous file with comments | « chrome/browser/resources/chromeos/idle_logout_dialog.html ('k') | chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698