OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_idle_logout.h" | 5 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_idle_logout.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
56 const content::NotificationSource& source, | 56 const content::NotificationSource& source, |
57 const content::NotificationDetails& details) { | 57 const content::NotificationDetails& details) { |
58 if (type == chrome::NOTIFICATION_LOGIN_USER_CHANGED) { | 58 if (type == chrome::NOTIFICATION_LOGIN_USER_CHANGED) { |
59 // Register our observers only when a user logs on. | 59 // Register our observers only when a user logs on. |
60 chromeos::PowerManagerClient* power_manager = | 60 chromeos::PowerManagerClient* power_manager = |
61 chromeos::DBusThreadManager::Get()->GetPowerManagerClient(); | 61 chromeos::DBusThreadManager::Get()->GetPowerManagerClient(); |
62 if (!power_manager->HasObserver(this)) | 62 if (!power_manager->HasObserver(this)) |
63 power_manager->AddObserver(this); | 63 power_manager->AddObserver(this); |
64 | 64 |
65 // Register for the next Idle for kLoginIdleTimeout event. | 65 // Register for the next Idle for kLoginIdleTimeout event. |
66 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> | 66 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> |
Mattias Nissler (ping if slow)
2012/03/16 09:56:46
use |power_manager| instead of the singleton acces
rkc
2012/03/19 23:59:48
Done.
| |
67 RequestIdleNotification( | 67 RequestIdleNotification(chromeos::KioskModeHelper::Get()-> |
68 chromeos::KioskModeHelper::Get()->GetIdleLogoutTimeout() * 1000); | 68 GetIdleLogoutTimeout().InMilliseconds()); |
Mattias Nissler (ping if slow)
2012/03/16 09:56:46
nit: +4 spaces indentation
rkc
2012/03/19 23:59:48
Done.
| |
69 } | 69 } |
70 } | 70 } |
71 | 71 |
72 void KioskModeIdleLogout::IdleNotify(int64 threshold) { | 72 void KioskModeIdleLogout::IdleNotify(int64 threshold) { |
73 // We're idle, next time we go active, we need to know so we can remove | 73 // We're idle, next time we go active, we need to know so we can remove |
74 // the logout dialog if it's still up. | 74 // the logout dialog if it's still up. |
75 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> | 75 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> |
76 RequestActiveNotification(); | 76 RequestActiveNotification(); |
77 | 77 |
78 browser::ShowIdleLogoutDialog(); | 78 browser::ShowIdleLogoutDialog(); |
79 } | 79 } |
80 | 80 |
81 void KioskModeIdleLogout::ActiveNotify() { | 81 void KioskModeIdleLogout::ActiveNotify() { |
82 // Before anything else, close the logout dialog to prevent restart | 82 // Before anything else, close the logout dialog to prevent restart |
83 browser::CloseIdleLogoutDialog(); | 83 browser::CloseIdleLogoutDialog(); |
84 | 84 |
85 // Now that we're active, register a request for notification for | 85 // Now that we're active, register a request for notification for |
86 // the next time we go idle for kLoginIdleTimeout seconds. | 86 // the next time we go idle for kLoginIdleTimeout seconds. |
87 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> | 87 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> |
88 RequestIdleNotification( | 88 RequestIdleNotification(chromeos::KioskModeHelper::Get()-> |
89 chromeos::KioskModeHelper::Get()->GetIdleLogoutTimeout() * 1000); | 89 GetIdleLogoutTimeout().InMilliseconds()); |
Mattias Nissler (ping if slow)
2012/03/16 09:56:46
nit: indentation
rkc
2012/03/19 23:59:48
Done.
| |
90 } | 90 } |
91 | 91 |
92 static base::LazyInstance<KioskModeIdleLogout> | 92 static base::LazyInstance<KioskModeIdleLogout> |
93 g_kiosk_mode_idle_logout = LAZY_INSTANCE_INITIALIZER; | 93 g_kiosk_mode_idle_logout = LAZY_INSTANCE_INITIALIZER; |
94 | 94 |
95 void InitializeKioskModeIdleLogout() { | 95 void InitializeKioskModeIdleLogout() { |
96 g_kiosk_mode_idle_logout.Get(); | 96 g_kiosk_mode_idle_logout.Get(); |
97 } | 97 } |
98 | 98 |
99 } // namespace chromeos | 99 } // namespace chromeos |
OLD | NEW |