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 virtual ~ProfilePolicyConnector(); | |
30 | |
31 // Schedules initialization of the policy backend service if the service is | |
32 // already constructed. | |
33 void ScheduleServiceInitialization(int64 delay_milliseconds); | |
34 | |
35 // Initializes the context. Should be called only after the profile's request | |
36 // context is up. | |
37 void Initialize(); | |
38 | |
39 // Shuts the context down. This must be called before the networking | |
40 // infrastructure in the profile goes away. | |
41 // | |
42 // TODO(jknotten): this will be called by ProfileDependencyManager -- | |
43 // ensure that it is dependent on the right services. See comment | |
44 // in ProfilePolicyConnectorFactory::ProfilePolicyConnectorFactory. | |
45 virtual void Shutdown() OVERRIDE; | |
46 | |
47 ConfigurationPolicyProvider* GetManagedCloudProvider(); | |
48 ConfigurationPolicyProvider* GetRecommendedCloudProvider(); | |
49 | |
50 private: | |
51 Profile* profile_; | |
52 | |
53 scoped_ptr<UserPolicyIdentityStrategy> identity_strategy_; | |
54 scoped_ptr<CloudPolicySubsystem> cloud_policy_subsystem_; | |
55 | |
56 scoped_ptr<ConfigurationPolicyProvider> managed_cloud_provider_; | |
57 scoped_ptr<ConfigurationPolicyProvider> recommended_cloud_provider_; | |
58 | |
59 DISALLOW_COPY_AND_ASSIGN(ProfilePolicyConnector); | |
60 }; | |
61 | |
62 // A wrapper for the ProfilePolicyConnector's cloud providers. | |
63 // | |
64 // Some well-known policies that are not provided by the | |
65 // |profile_policy_provider_| are instead provided by the | |
66 // |browser_policy_provider_|, thus merging device policies into | |
67 // profile policies. | |
68 // | |
69 // Currently used to pass the device proxy settings into the profile | |
70 // preferences. | |
71 class MergingPolicyProvider: public ConfigurationPolicyProvider, | |
72 public ConfigurationPolicyProvider::Observer { | |
73 public: | |
74 MergingPolicyProvider(ConfigurationPolicyProvider* browser_policy_provider, | |
75 ConfigurationPolicyProvider* profile_policy_provider); | |
76 virtual ~MergingPolicyProvider(); | |
77 | |
78 // ConfigurationPolicyProvider methods: | |
79 virtual bool Provide(ConfigurationPolicyStoreInterface* store) OVERRIDE; | |
80 virtual void AddObserver( | |
81 ConfigurationPolicyProvider::Observer* observer) OVERRIDE; | |
82 virtual void RemoveObserver( | |
83 ConfigurationPolicyProvider::Observer* observer) OVERRIDE; | |
84 | |
85 // ConfigurationPolicyProvider::Observer methods: | |
86 virtual void OnUpdatePolicy() OVERRIDE; | |
87 virtual void OnProviderGoingAway() OVERRIDE; | |
88 | |
89 private: | |
90 ConfigurationPolicyProvider* browser_policy_provider_; | |
91 ConfigurationPolicyProvider* profile_policy_provider_; | |
92 scoped_ptr<ConfigurationPolicyObserverRegistrar> browser_registrar_; | |
93 scoped_ptr<ConfigurationPolicyObserverRegistrar> profile_registrar_; | |
94 ObserverList<ConfigurationPolicyProvider::Observer, true> observer_list_; | |
95 | |
96 DISALLOW_COPY_AND_ASSIGN(MergingPolicyProvider); | |
97 }; | |
98 | |
99 | |
100 } // namespace policy | |
101 | |
102 #endif // CHROME_BROWSER_POLICY_PROFILE_POLICY_CONNECTOR_H_ | |
Joao da Silva
2011/06/03 12:23:51
Yay, it's gone! :-)
| |
OLD | NEW |