OLD | NEW |
| (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_helper.h" | |
6 | |
7 #include "base/bind.h" | |
8 #include "base/command_line.h" | |
9 #include "base/lazy_instance.h" | |
10 #include "chrome/browser/browser_process.h" | |
11 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_screensaver.h" | |
12 #include "chrome/browser/policy/cloud_policy_constants.h" | |
13 #include "chrome/browser/policy/browser_policy_connector.h" | |
14 #include "chrome/common/chrome_switches.h" | |
15 | |
16 namespace { | |
17 | |
18 const int64 kScreensaverIdleTimeout = 60; | |
19 const int64 kLoginIdleTimeout = 100; | |
20 const int64 kLoginIdleCountdownTimeout = 20; | |
21 | |
22 } // namespace | |
23 | |
24 namespace chromeos { | |
25 | |
26 static base::LazyInstance<KioskModeHelper> g_kiosk_mode_helper = | |
27 LAZY_INSTANCE_INITIALIZER; | |
28 | |
29 // static | |
30 bool KioskModeHelper::IsKioskModeEnabled() { | |
31 if (g_browser_process) { | |
32 policy::BrowserPolicyConnector* bpc = | |
33 g_browser_process->browser_policy_connector(); | |
34 if (bpc && policy::DEVICE_MODE_KIOSK == bpc->GetDeviceMode()) | |
35 return true; | |
36 } | |
37 // In case we've force-enabled kiosk mode. | |
38 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableKioskMode)) | |
39 return true; | |
40 | |
41 return false; | |
42 } | |
43 | |
44 // static | |
45 KioskModeHelper* KioskModeHelper::Get() { | |
46 return g_kiosk_mode_helper.Pointer(); | |
47 } | |
48 | |
49 void KioskModeHelper::Initialize(const base::Closure& notify_initialized) { | |
50 is_initialized_ = true; | |
51 notify_initialized.Run(); | |
52 } | |
53 | |
54 std::string KioskModeHelper::GetScreensaverPath() const { | |
55 if (!is_initialized_) | |
56 return std::string(); | |
57 | |
58 return CommandLine::ForCurrentProcess()-> | |
59 GetSwitchValueASCII(switches::kKioskModeScreensaverPath); | |
60 } | |
61 | |
62 int64 KioskModeHelper::GetScreensaverTimeout() const { | |
63 if (!is_initialized_) | |
64 return -1; | |
65 | |
66 return kScreensaverIdleTimeout; | |
67 } | |
68 | |
69 int64 KioskModeHelper::GetIdleLogoutTimeout() const { | |
70 if (!is_initialized_) | |
71 return -1; | |
72 | |
73 return kLoginIdleTimeout; | |
74 } | |
75 int64 KioskModeHelper::GetIdleLogoutWarningTimeout() const { | |
76 if (!is_initialized_) | |
77 return -1; | |
78 | |
79 return kLoginIdleCountdownTimeout; | |
80 } | |
81 | |
82 KioskModeHelper::KioskModeHelper() : is_initialized_(false) { | |
83 } | |
84 | |
85 } // namespace chromeos | |
OLD | NEW |