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

Side by Side Diff: chrome/browser/chromeos/kiosk_mode/kiosk_mode_screen_locker.cc

Issue 9265026: Implement restart on Idle for Kiosk Mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_screen_locker.h"
6
7 #include "base/bind.h"
8 #include "base/lazy_instance.h"
9 #include "base/logging.h"
10 #include "base/message_loop.h"
11 #include "chrome/browser/ui/browser_dialogs.h"
flackr 2012/01/20 16:16:58 nit: sort.
rkc 2012/01/26 03:37:23 Done.
12 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h"
13 #include "chrome/browser/chromeos/dbus/power_manager_client.h"
14 #include "chrome/common/chrome_notification_types.h"
15 #include "content/public/browser/notification_observer.h"
16 #include "content/public/browser/notification_registrar.h"
17 #include "content/public/browser/notification_service.h"
18
19
20 namespace {
xiyuan 2012/01/20 18:23:44 nit: blank line before and after code block in nam
rkc 2012/01/26 03:37:23 Done.
21 const int64 kLoginIdleTimeout = 100; // seconds
xiyuan 2012/01/20 18:23:44 nit: This is not 2m. :)
rkc 2012/01/26 03:37:23 This is intended; this is meant to be idle time -
22 } // namespace
23
24 namespace chromeos {
25
26 class KioskModeLoginObserver : public PowerManagerClient::Observer,
27 public content::NotificationObserver {
28 public:
29 KioskModeLoginObserver() {
30 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_CHANGED,
31 content::NotificationService::AllSources());
32 }
33
34 // NotificationObserver overrides:
35 virtual void Observe(int type,
36 const content::NotificationSource& source,
37 const content::NotificationDetails& details) OVERRIDE {
38 if (type == chrome::NOTIFICATION_LOGIN_USER_CHANGED) {
39 // Register our observers only when a user logs on.
40 chromeos::PowerManagerClient* power_manager =
41 chromeos::DBusThreadManager::Get()->GetPowerManagerClient();
42 if (!power_manager->HasObserver(this))
43 power_manager->AddObserver(this);
44
45 // Register for the next Idle for kLoginIdleTimeout event.
46 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
47 RequestIdleNotification(kLoginIdleTimeout * 1000);
48 }
49 }
50
51 virtual void IdleNotify(int64 threshold) OVERRIDE {
52 // We're idle, next time we go active, we need to know so we can remove
53 // the logout dialog if it's still up.
54 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
55 RequestActiveNotification();
56
57 browser::ShowKioskModeLogoutDialog();
58 }
59
60 virtual void ActiveNotify() OVERRIDE {
61 // Before anything else, close the logout dialog to prevent restart
62 browser::CloseKioskModeLogoutDialog();
63
64 // Now that we're active, register a request for notification for
65 // the next time we go idle for kLoginIdleTimeout seconds.
66 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
67 RequestIdleNotification(kLoginIdleTimeout * 1000);
68 }
69
70 private:
71 content::NotificationRegistrar registrar_;
72
73 DISALLOW_COPY_AND_ASSIGN(KioskModeLoginObserver);
74 };
75
76 static base::LazyInstance<KioskModeLoginObserver> g_kiosk_mode_login_observer =
77 LAZY_INSTANCE_INITIALIZER;
78
79
80 void KioskModeScreenLocker::InitClass() {
81 g_kiosk_mode_login_observer.Get();
82 }
83
84 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698