OLD | NEW |
| (Empty) |
1 // Copyright (c) 2010 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_POLICY_PROFILE_POLICY_CONTEXT_H_ | |
6 #define CHROME_BROWSER_POLICY_PROFILE_POLICY_CONTEXT_H_ | |
7 #pragma once | |
8 | |
9 #include "base/scoped_ptr.h" | |
10 #include "chrome/browser/prefs/pref_member.h" | |
11 #include "chrome/common/notification_observer.h" | |
12 | |
13 class Profile; | |
14 | |
15 namespace policy { | |
16 | |
17 class DeviceManagementPolicyProvider; | |
18 class DeviceManagementService; | |
19 | |
20 // This class is a container for the profile-specific policy bits located in the | |
21 // profile. Since the context owns the policy provider, it's vital that it gets | |
22 // initialized before the profile's prefs and destroyed after the prefs are | |
23 // gone. | |
24 class ProfilePolicyContext : public NotificationObserver { | |
25 public: | |
26 explicit ProfilePolicyContext(Profile* profile); | |
27 ~ProfilePolicyContext(); | |
28 | |
29 // Initializes the context. Should be called only after the profile's request | |
30 // context is up. | |
31 void Initialize(); | |
32 | |
33 // Shuts the context down. This must be called before the networking | |
34 // infrastructure in the profile goes away. | |
35 void Shutdown(); | |
36 | |
37 // Get the policy provider. | |
38 DeviceManagementPolicyProvider* GetDeviceManagementPolicyProvider(); | |
39 | |
40 // Register preferences. | |
41 static void RegisterUserPrefs(PrefService* user_prefs); | |
42 | |
43 static const int kDefaultPolicyRefreshRateInMilliseconds = | |
44 3 * 60 * 60 * 1000; // 3 hours. | |
45 | |
46 private: | |
47 // Updates the policy provider with a new refresh rate value. | |
48 void UpdatePolicyRefreshRate(); | |
49 | |
50 // NotificationObserver overrides. | |
51 virtual void Observe(NotificationType type, | |
52 const NotificationSource& source, | |
53 const NotificationDetails& details); | |
54 | |
55 // The profile this context is associated with. | |
56 Profile* profile_; | |
57 | |
58 // Tracks the pref value for the policy refresh rate. | |
59 IntegerPrefMember policy_refresh_rate_; | |
60 | |
61 // The device management service. | |
62 scoped_ptr<DeviceManagementService> device_management_service_; | |
63 | |
64 // Our provider. | |
65 scoped_ptr<DeviceManagementPolicyProvider> device_management_policy_provider_; | |
66 }; | |
67 | |
68 } // namespace policy | |
69 | |
70 #endif // CHROME_BROWSER_POLICY_PROFILE_POLICY_CONTEXT_H_ | |
OLD | NEW |