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