Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / chromeos / kiosk_mode / kiosk_mode_settings.h
blob2fc47fe60cffb2513646e22f789c9be1d9d421ff
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.
5 #ifndef CHROME_BROWSER_CHROMEOS_KIOSK_MODE_KIOSK_MODE_SETTINGS_H_
6 #define CHROME_BROWSER_CHROMEOS_KIOSK_MODE_KIOSK_MODE_SETTINGS_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/callback_forward.h"
12 #include "base/time/time.h"
13 #include "chrome/browser/chromeos/policy/app_pack_updater.h"
14 #include "chrome/browser/chromeos/settings/device_settings_service.h"
16 namespace base {
17 template <typename T> struct DefaultLazyInstanceTraits;
20 namespace chromeos {
22 // This class centralizes all our code to get KioskMode settings; since
23 // KioskMode interferes with normal operations all over Chrome, having all
24 // data about it pulled from a central location would make future
25 // refactorings easier. This class also handles getting trust for the policies
26 // via its init method.
28 // Note: If Initialize is not called before the various Getters, we'll return
29 // invalid values.
30 class KioskModeSettings {
31 public:
32 static KioskModeSettings* Get();
34 // This method checks if Kiosk Mode is enabled or not.
35 virtual bool IsKioskModeEnabled();
37 // Initialize the settings; this will call the callback once trust is
38 // established with the policy settings provider.
39 virtual void Initialize(const base::Closure& notify_initialized);
40 virtual bool is_initialized() const;
42 // The path to the screensaver extension. This callback may get called
43 // very late, or even never (depending on the state of the app pack).
44 virtual void GetScreensaverPath(
45 policy::AppPackUpdater::ScreenSaverUpdateCallback callback) const;
47 // The timeout before which we'll start showing the screensaver.
48 virtual base::TimeDelta GetScreensaverTimeout() const;
50 // NOTE: The idle logout timeout is the time 'till' we show the idle dialog
51 // box. After we show the dialog box, it remains up for an 'additional'
52 // IdleLogoutWarningTimeout seconds, which adds to the total time before the
53 // user is logged out.
54 // The time to logout the user in on idle.
55 virtual base::TimeDelta GetIdleLogoutTimeout() const;
57 // The time to show the countdown timer for.
58 virtual base::TimeDelta GetIdleLogoutWarningDuration() const;
60 static const int kMaxIdleLogoutTimeout;
61 static const int kMinIdleLogoutTimeout;
63 static const int kMaxIdleLogoutWarningDuration;
64 static const int kMinIdleLogoutWarningDuration;
66 protected:
67 // Needed here so MockKioskModeSettings can inherit from us.
68 KioskModeSettings();
69 virtual ~KioskModeSettings();
71 private:
72 friend struct base::DefaultLazyInstanceTraits<KioskModeSettings>;
73 friend class KioskModeSettingsTest;
75 // Makes sure the browser will switch to kiosk mode if cryptohome was not
76 // ready when the browser was starting after a machine reboot.
77 void VerifyModeIsKnown(DeviceSettingsService::OwnershipStatus status);
79 bool is_initialized_;
80 bool is_kiosk_mode_;
82 // Used for testing.
83 void set_initialized(bool value) { is_initialized_ = value; }
85 std::string screensaver_id_;
86 std::string screensaver_path_;
87 base::TimeDelta screensaver_timeout_;
88 base::TimeDelta idle_logout_timeout_;
89 base::TimeDelta idle_logout_warning_duration_;
91 DISALLOW_COPY_AND_ASSIGN(KioskModeSettings);
94 } // namespace chromeos
96 #endif // CHROME_BROWSER_CHROMEOS_KIOSK_MODE_KIOSK_MODE_SETTINGS_H_