Chromium Code Reviews| Index: chrome/browser/chromeos/kiosk_mode/kiosk_mode_screensaver.cc |
| diff --git a/chrome/browser/chromeos/kiosk_mode/kiosk_mode_screensaver.cc b/chrome/browser/chromeos/kiosk_mode/kiosk_mode_screensaver.cc |
| index bd943f42ca425cc3cf8787394efd2955eb66e1aa..eb4d2642e25186fb8e1e3acffa601b28dea25b7c 100644 |
| --- a/chrome/browser/chromeos/kiosk_mode/kiosk_mode_screensaver.cc |
| +++ b/chrome/browser/chromeos/kiosk_mode/kiosk_mode_screensaver.cc |
| @@ -4,25 +4,37 @@ |
| #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_screensaver.h" |
| +#include "base/bind.h" |
| #include "base/lazy_instance.h" |
| #include "base/logging.h" |
| #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" |
| +#include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_helper.h" |
| #include "chrome/browser/chromeos/login/user_manager.h" |
| #include "chrome/browser/chromeos/ui/screensaver_extension_dialog.h" |
| #include "chrome/common/chrome_notification_types.h" |
| #include "content/public/browser/notification_service.h" |
| -namespace { |
| +namespace chromeos { |
| -// This (along with screensaver location) will change once we have the |
| -// retail mode enterprise policy set up. |
| -const int64 kScreensaverIdleTimeout = 60; |
| +KioskModeScreensaver::KioskModeScreensaver() { |
| + if (chromeos::KioskModeHelper::Get()->is_initialized()) |
| + Init(); |
|
xiyuan
2012/02/29 18:01:12
nit: Could we have a better name? On first look, "
rkc
2012/02/29 20:57:48
Done.
|
| + else |
| + chromeos::KioskModeHelper::Get()->Initialize( |
|
xiyuan
2012/02/29 18:01:12
nit: suggest to enclose this with {} since it's mo
rkc
2012/02/29 20:57:48
Done.
|
| + base::Bind(&KioskModeScreensaver::Init, |
| + base::Unretained(this))); |
| -} // namespace |
| +} |
| -namespace chromeos { |
| +KioskModeScreensaver::~KioskModeScreensaver() { |
| + chromeos::PowerManagerClient* power_manager = |
| + chromeos::DBusThreadManager::Get()->GetPowerManagerClient(); |
| + if (power_manager->HasObserver(this)) |
| + power_manager->RemoveObserver(this); |
| +} |
| + |
| +void KioskModeScreensaver::Init() { |
| -KioskModeScreensaver::KioskModeScreensaver() { |
| // We should NOT be created if already logged in. |
| CHECK(!chromeos::UserManager::Get()->user_is_logged_in()); |
| @@ -36,15 +48,9 @@ KioskModeScreensaver::KioskModeScreensaver() { |
| power_manager->AddObserver(this); |
| // Register for the next Idle for kScreensaverIdleTimeout event. |
| - chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> |
| - RequestIdleNotification(kScreensaverIdleTimeout * 1000); |
| -} |
| - |
| -KioskModeScreensaver::~KioskModeScreensaver() { |
| - chromeos::PowerManagerClient* power_manager = |
| - chromeos::DBusThreadManager::Get()->GetPowerManagerClient(); |
| - if (power_manager->HasObserver(this)) |
| - power_manager->RemoveObserver(this); |
| + chromeos::DBusThreadManager::Get()-> |
|
Nikita (slow)
2012/02/29 12:21:55
I've realized that you would also need a patch for
rkc
2012/02/29 20:57:48
That is correct. I need to speak to Benson about t
|
| + GetPowerManagerClient()->RequestIdleNotification( |
| + chromeos::KioskModeHelper::Get()->GetScreensaverTimeout() * 1000); |
| } |
| // NotificationObserver overrides: |
| @@ -65,8 +71,8 @@ void KioskModeScreensaver::Observe( |
| void KioskModeScreensaver::IdleNotify(int64 threshold) { |
| // We're idle, next time we go active, we need to know so we can remove |
| // the logout dialog if it's still up. |
|
Nikita (slow)
2012/02/29 12:21:55
nit: logout dialog?
rkc
2012/02/29 20:57:48
Done.
|
| - chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> |
| - RequestActiveNotification(); |
| + chromeos::DBusThreadManager::Get()-> |
| + GetPowerManagerClient()->RequestActiveNotification(); |
| browser::ShowScreensaverDialog(); |
| } |
| @@ -77,9 +83,9 @@ void KioskModeScreensaver::ActiveNotify() { |
| // Now that we're active, register a request for notification for |
| // the next time we go idle for kScreensaverIdleTimeout seconds. |
| - chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> |
| - RequestIdleNotification(kScreensaverIdleTimeout * 1000); |
| -} |
| + chromeos::DBusThreadManager::Get()-> |
| + GetPowerManagerClient()->RequestIdleNotification( |
| + chromeos::KioskModeHelper::Get()->GetScreensaverTimeout() * 1000);} |
| static KioskModeScreensaver* g_kiosk_mode_screensaver = NULL; |
| @@ -93,7 +99,7 @@ void InitializeKioskModeScreensaver() { |
| } |
| void ShutdownKioskModeScreensaver() { |
| - if (g_kiosk_mode_screensaver) { |
| + if (!g_kiosk_mode_screensaver) { |
|
Nikita (slow)
2012/02/29 12:21:55
On the second thought delete of a NULL pointer is
rkc
2012/02/29 20:57:48
This actually really helped me with debugging alre
|
| LOG(WARNING) << "Screensaver shutdown called when uninitialized."; |
| return; |
| } |