Chromium Code Reviews| 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); |