| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_POLICY_PROFILE_POLICY_CONNECTOR_H_ | |
| 6 #define CHROME_BROWSER_POLICY_PROFILE_POLICY_CONNECTOR_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include "base/basictypes.h" | |
| 10 #include "base/memory/scoped_ptr.h" | |
| 11 #include "base/observer_list.h" | |
| 12 #include "chrome/browser/policy/configuration_policy_provider.h" | |
| 13 #include "chrome/browser/prefs/pref_change_registrar.h" | |
| 14 #include "chrome/browser/profiles/profile_keyed_service.h" | |
| 15 | |
| 16 class Profile; | |
| 17 | |
| 18 namespace policy { | |
| 19 | |
| 20 class CloudPolicySubsystem; | |
| 21 class UserPolicyIdentityStrategy; | |
| 22 | |
| 23 // This class is a container for the profile-specific policy bits located in the | |
| 24 // profile. Since the subsystem owns the policy provider, it's vital that it | |
| 25 // gets initialized before the profile's prefs and destroyed after the prefs | |
| 26 // are gone. | |
| 27 class ProfilePolicyConnector : public ProfileKeyedService { | |
| 28 public: | |
| 29 explicit ProfilePolicyConnector(Profile* profile); | |
| 30 virtual ~ProfilePolicyConnector(); | |
| 31 | |
| 32 // Schedules initialization of the policy backend service if the service is | |
| 33 // already constructed. | |
| 34 void ScheduleServiceInitialization(int64 delay_milliseconds); | |
| 35 | |
| 36 // Initializes the context. Should be called only after the profile's request | |
| 37 // context is up. | |
| 38 void Initialize(); | |
| 39 | |
| 40 // Shuts the context down. This must be called before the networking | |
| 41 // infrastructure in the profile goes away. | |
| 42 // | |
| 43 // TODO(jknotten): this will be called by ProfileDependencyManager -- | |
| 44 // ensure that it is dependent on the right services. See comment | |
| 45 // in ProfilePolicyConnectorFactory::ProfilePolicyConnectorFactory. | |
| 46 virtual void Shutdown() OVERRIDE; | |
| 47 | |
| 48 ConfigurationPolicyProvider* GetManagedCloudProvider(); | |
| 49 ConfigurationPolicyProvider* GetRecommendedCloudProvider(); | |
| 50 | |
| 51 private: | |
| 52 Profile* profile_; | |
| 53 | |
| 54 scoped_ptr<UserPolicyIdentityStrategy> identity_strategy_; | |
| 55 scoped_ptr<CloudPolicySubsystem> cloud_policy_subsystem_; | |
| 56 | |
| 57 scoped_ptr<ConfigurationPolicyProvider> managed_cloud_provider_; | |
| 58 scoped_ptr<ConfigurationPolicyProvider> recommended_cloud_provider_; | |
| 59 | |
| 60 // Temporarily needed until we can serve user policy to local state. | |
| 61 PrefChangeRegistrar profile_pref_registrar_; | |
| 62 | |
| 63 DISALLOW_COPY_AND_ASSIGN(ProfilePolicyConnector); | |
| 64 }; | |
| 65 | |
| 66 // A wrapper for the ProfilePolicyConnector's cloud providers. | |
| 67 // | |
| 68 // Some well-known policies that are not provided by the | |
| 69 // |profile_policy_provider_| are instead provided by the | |
| 70 // |browser_policy_provider_|, thus merging device policies into | |
| 71 // profile policies. | |
| 72 // | |
| 73 // Currently used to pass the device proxy settings into the profile | |
| 74 // preferences. | |
| 75 class MergingPolicyProvider: public ConfigurationPolicyProvider, | |
| 76 public ConfigurationPolicyProvider::Observer { | |
| 77 public: | |
| 78 MergingPolicyProvider(ConfigurationPolicyProvider* browser_policy_provider, | |
| 79 ConfigurationPolicyProvider* profile_policy_provider); | |
| 80 virtual ~MergingPolicyProvider(); | |
| 81 | |
| 82 // ConfigurationPolicyProvider methods: | |
| 83 virtual bool Provide(ConfigurationPolicyStoreInterface* store) OVERRIDE; | |
| 84 virtual void AddObserver( | |
| 85 ConfigurationPolicyProvider::Observer* observer) OVERRIDE; | |
| 86 virtual void RemoveObserver( | |
| 87 ConfigurationPolicyProvider::Observer* observer) OVERRIDE; | |
| 88 | |
| 89 // ConfigurationPolicyProvider::Observer methods: | |
| 90 virtual void OnUpdatePolicy() OVERRIDE; | |
| 91 virtual void OnProviderGoingAway() OVERRIDE; | |
| 92 | |
| 93 private: | |
| 94 ConfigurationPolicyProvider* browser_policy_provider_; | |
| 95 ConfigurationPolicyProvider* profile_policy_provider_; | |
| 96 scoped_ptr<ConfigurationPolicyObserverRegistrar> browser_registrar_; | |
| 97 scoped_ptr<ConfigurationPolicyObserverRegistrar> profile_registrar_; | |
| 98 ObserverList<ConfigurationPolicyProvider::Observer, true> observer_list_; | |
| 99 | |
| 100 DISALLOW_COPY_AND_ASSIGN(MergingPolicyProvider); | |
| 101 }; | |
| 102 | |
| 103 | |
| 104 } // namespace policy | |
| 105 | |
| 106 #endif // CHROME_BROWSER_POLICY_PROFILE_POLICY_CONNECTOR_H_ | |
| OLD | NEW |