Chromium Code Reviews

Side by Side Diff: chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h

Issue 9701084: Integrate Kiosk Mode with enterprise policies. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: clang fix. Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | 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 #ifndef CHROME_BROWSER_CHROMEOS_KIOSK_MODE_KIOSK_MODE_SETTINGS_H_
6 #define CHROME_BROWSER_CHROMEOS_KIOSK_MODE_KIOSK_MODE_SETTINGS_H_
7 #pragma once
8
9 #include <string>
10
11 #include "base/basictypes.h"
12 #include "base/callback_forward.h"
13 #include "base/time.h"
14
15 namespace base {
16 template <typename T> struct DefaultLazyInstanceTraits;
17 }
18
19 namespace {
20
21 const int kMaxIdleLogoutTimeout = 600000; // ms = 600s = 10m.
22 const int kMinIdleLogoutTimeout = 5000; // ms = 5s.
23
24 const int kMaxIdleLogoutWarningDuration = 60000; // ms = 60s.
25 const int kMinIdleLogoutWarningDuration = 1000; // ms = 1s.
26
27 const int kFudgeInt = 100;
Mattias Nissler (ping if slow) 2012/03/20 13:10:35 what's this? only used in tests, so move there?
rkc 2012/03/20 21:00:42 Done.
28
29 } // namespace
30
31 namespace chromeos {
32
33 // This class centralizes all our code to get KioskMode settings; since
34 // KioskMode interferes with normal operations all over Chrome, having all
35 // data about it pulled from a central location would make future
36 // refactorings easier. This class also handles getting trust for the policies
37 // via it's init method.
38 //
39 // Note: If Initialize is not called before the various Getters, we'll return
40 // invalid values.
41 class KioskModeSettings {
42 public:
43 // This method checks if Kiosk Mode is enabled or not.
44 static bool IsKioskModeEnabled();
45 // This method is used when we're testing to do what the method above does.
46 virtual bool IsTestKioskModeEnabled() { return false; }
Mattias Nissler (ping if slow) 2012/03/20 13:10:35 Why not make the IsKioskModeEnabled() a virtual me
rkc 2012/03/20 21:00:42 Removed all code related to the mock class; I'll p
47
48 static KioskModeSettings* Get();
49
50 // Initialize the settings; this will call the callback once trust is
51 // established with the policy settings provider.
52 void Initialize(const base::Closure& notify_initialized);
53 bool is_initialized() const { return is_initialized_; }
54
55 // The path to the screensaver extension.
56 std::string GetScreensaverPath() const;
57 // The timeout before which we'll start showing the screensaver.
58 base::TimeDelta GetScreensaverTimeout() const;
59
60 // NOTE: The idle logout timeout is the time 'till' we show the idle dialog
61 // box. After we show the dialog box, it remains up for an 'additional'
62 // IdleLogoutWarningTimeout seconds, which adds to the total time before the
63 // user is logged out.
64 // The time to logout the user in on idle.
65 base::TimeDelta GetIdleLogoutTimeout() const;
66 // The time to show the countdown timer for.
67 base::TimeDelta GetIdleLogoutWarningDuration() const;
68
69 protected:
70 // Needed here so MockKioskModeSettings can inherit from us.
71 KioskModeSettings();
72 virtual ~KioskModeSettings();
73
74 private:
75 friend struct base::DefaultLazyInstanceTraits<KioskModeSettings>;
76 friend class KioskModeSettingsTest;
77
78 bool is_initialized_;
79
80 // Used for testing.
81 static void set_test_instance(KioskModeSettings* instance);
82 static KioskModeSettings* test_instance_;
83 void set_initialized(bool value) { is_initialized_ = value; }
84
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_;
90
91 DISALLOW_COPY_AND_ASSIGN(KioskModeSettings);
92 };
93
94 } // namespace chromeos
95
96 #endif // CHROME_BROWSER_CHROMEOS_KIOSK_MODE_KIOSK_MODE_SETTINGS_H_
OLDNEW

Powered by Google App Engine