| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_POLICY_PROFILE_POLICY_CONTEXT_H_ | 5 #ifndef CHROME_BROWSER_POLICY_PROFILE_POLICY_CONTEXT_H_ |
| 6 #define CHROME_BROWSER_POLICY_PROFILE_POLICY_CONTEXT_H_ | 6 #define CHROME_BROWSER_POLICY_PROFILE_POLICY_CONTEXT_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/basictypes.h" |
| 9 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
| 10 #include "chrome/browser/prefs/pref_member.h" | |
| 11 #include "chrome/common/notification_observer.h" | |
| 12 | 11 |
| 13 class Profile; | 12 class Profile; |
| 14 | 13 |
| 15 namespace policy { | 14 namespace policy { |
| 16 | 15 |
| 17 class DeviceManagementPolicyProvider; | 16 class CloudPolicyContext; |
| 18 class DeviceManagementService; | 17 class ConfigurationPolicyProvider; |
| 18 class UserPolicyController; |
| 19 | 19 |
| 20 // This class is a container for the profile-specific policy bits located in the | 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 | 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 | 22 // initialized before the profile's prefs and destroyed after the prefs are |
| 23 // gone. | 23 // gone. |
| 24 class ProfilePolicyContext : public NotificationObserver { | 24 class ProfilePolicyContext { |
| 25 public: | 25 public: |
| 26 explicit ProfilePolicyContext(Profile* profile); | 26 explicit ProfilePolicyContext(Profile* profile); |
| 27 ~ProfilePolicyContext(); | 27 ~ProfilePolicyContext(); |
| 28 | 28 |
| 29 // Initializes the context. Should be called only after the profile's request | 29 // Initializes the context. Should be called only after the profile's request |
| 30 // context is up. | 30 // context is up. |
| 31 void Initialize(); | 31 void Initialize(); |
| 32 | 32 |
| 33 // Shuts the context down. This must be called before the networking | 33 // Shuts the context down. This must be called before the networking |
| 34 // infrastructure in the profile goes away. | 34 // infrastructure in the profile goes away. |
| 35 void Shutdown(); | 35 void Shutdown(); |
| 36 | 36 |
| 37 // Get the policy provider. | 37 ConfigurationPolicyProvider* GetManagedPolicyProvider(); |
| 38 DeviceManagementPolicyProvider* GetDeviceManagementPolicyProvider(); | 38 ConfigurationPolicyProvider* GetRecommendedPolicyProvider(); |
| 39 | 39 |
| 40 // Register preferences. | 40 static void RegisterPrefs(PrefService* user_prefs); |
| 41 static void RegisterUserPrefs(PrefService* user_prefs); | |
| 42 | 41 |
| 43 static const int kDefaultPolicyRefreshRateInMilliseconds = | 42 static const int kDefaultPolicyRefreshRateInMilliseconds = |
| 44 3 * 60 * 60 * 1000; // 3 hours. | 43 3 * 60 * 60 * 1000; // 3 hours. |
| 45 | 44 |
| 46 private: | 45 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_; | 46 Profile* profile_; |
| 57 | 47 |
| 58 // Tracks the pref value for the policy refresh rate. | 48 scoped_ptr<UserPolicyController> controller_; |
| 59 IntegerPrefMember policy_refresh_rate_; | 49 scoped_ptr<CloudPolicyContext> cloud_context_; |
| 60 | 50 |
| 61 // The device management service. | 51 DISALLOW_COPY_AND_ASSIGN(ProfilePolicyContext); |
| 62 scoped_ptr<DeviceManagementService> device_management_service_; | |
| 63 | |
| 64 // Our provider. | |
| 65 scoped_ptr<DeviceManagementPolicyProvider> device_management_policy_provider_; | |
| 66 }; | 52 }; |
| 67 | 53 |
| 68 } // namespace policy | 54 } // namespace policy |
| 69 | 55 |
| 70 #endif // CHROME_BROWSER_POLICY_PROFILE_POLICY_CONTEXT_H_ | 56 #endif // CHROME_BROWSER_POLICY_PROFILE_POLICY_CONTEXT_H_ |
| OLD | NEW |