OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_USER_CLOUD_POLICY_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_POLICY_USER_CLOUD_POLICY_MANAGER_H_ |
6 #define CHROME_BROWSER_POLICY_USER_CLOUD_POLICY_MANAGER_H_ | 6 #define CHROME_BROWSER_POLICY_USER_CLOUD_POLICY_MANAGER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "chrome/browser/policy/cloud_policy_client.h" | 10 #include "chrome/browser/policy/cloud_policy_client.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 UserCloudPolicyManager(scoped_ptr<CloudPolicyStore> store, | 33 UserCloudPolicyManager(scoped_ptr<CloudPolicyStore> store, |
34 bool wait_for_policy_fetch); | 34 bool wait_for_policy_fetch); |
35 virtual ~UserCloudPolicyManager(); | 35 virtual ~UserCloudPolicyManager(); |
36 | 36 |
37 // Creates a UserCloudPolicyService instance associated with the passed | 37 // Creates a UserCloudPolicyService instance associated with the passed |
38 // |profile|. | 38 // |profile|. |
39 static scoped_ptr<UserCloudPolicyManager> Create(Profile* profile, | 39 static scoped_ptr<UserCloudPolicyManager> Create(Profile* profile, |
40 bool wait_for_policy_fetch); | 40 bool wait_for_policy_fetch); |
41 | 41 |
42 // Initializes the cloud connection. |local_prefs| and |service| must stay | 42 // Initializes the cloud connection. |local_prefs| and |service| must stay |
43 // valid until Shutdown() gets called. Virtual for mocking. | 43 // valid until this object is deleted or ShutdownAndRemovePolicy() gets |
| 44 // called. Virtual for mocking. |
44 virtual void Initialize(PrefService* local_prefs, | 45 virtual void Initialize(PrefService* local_prefs, |
45 DeviceManagementService* service, | 46 DeviceManagementService* service, |
46 UserAffiliation user_affiliation); | 47 UserAffiliation user_affiliation); |
47 | 48 |
48 // Virtual for mocks. | 49 // Shuts down the UserCloudPolicyManager (removes and stops refreshing the |
49 virtual void Shutdown(); | 50 // cached cloud policy). This is typically called when a profile is being |
| 51 // disassociated from a given user (e.g. during signout). No policy will be |
| 52 // provided by this object until the next time Initialize() is invoked. |
| 53 void ShutdownAndRemovePolicy(); |
50 | 54 |
51 // Cancels waiting for the policy fetch and flags the | 55 // Cancels waiting for the policy fetch and flags the |
52 // ConfigurationPolicyProvider ready (assuming all other initialization tasks | 56 // ConfigurationPolicyProvider ready (assuming all other initialization tasks |
53 // have completed). | 57 // have completed). |
54 void CancelWaitForPolicyFetch(); | 58 void CancelWaitForPolicyFetch(); |
55 | 59 |
56 // Returns true if the underlying CloudPolicyClient is already registered. | 60 // Returns true if the underlying CloudPolicyClient is already registered. |
57 // Virtual for mocking. | 61 // Virtual for mocking. |
58 virtual bool IsClientRegistered() const; | 62 virtual bool IsClientRegistered() const; |
59 | 63 |
(...skipping 20 matching lines...) Expand all Loading... |
80 // ConfigurationPolicyStore::UpdatePolicy(). | 84 // ConfigurationPolicyStore::UpdatePolicy(). |
81 void CheckAndPublishPolicy(); | 85 void CheckAndPublishPolicy(); |
82 | 86 |
83 // Completion handler for the explicit policy fetch triggered on startup in | 87 // Completion handler for the explicit policy fetch triggered on startup in |
84 // case |wait_for_policy_fetch_| is true. | 88 // case |wait_for_policy_fetch_| is true. |
85 void OnInitialPolicyFetchComplete(); | 89 void OnInitialPolicyFetchComplete(); |
86 | 90 |
87 // Completion handler for policy refresh operations. | 91 // Completion handler for policy refresh operations. |
88 void OnRefreshComplete(); | 92 void OnRefreshComplete(); |
89 | 93 |
| 94 // Frees the CloudPolicyService and stops refreshing policy. Any previously |
| 95 // cached policy will continue to be served. |
| 96 void Shutdown(); |
| 97 |
90 // Whether to wait for a policy fetch to complete before reporting | 98 // Whether to wait for a policy fetch to complete before reporting |
91 // IsInitializationComplete(). | 99 // IsInitializationComplete(). |
92 bool wait_for_policy_fetch_; | 100 bool wait_for_policy_fetch_; |
93 | 101 |
94 // Whether there's a policy refresh operation pending, in which case all | 102 // Whether there's a policy refresh operation pending, in which case all |
95 // policy update notifications are deferred until after it completes. | 103 // policy update notifications are deferred until after it completes. |
96 bool wait_for_policy_refresh_; | 104 bool wait_for_policy_refresh_; |
97 | 105 |
98 scoped_ptr<CloudPolicyStore> store_; | 106 scoped_ptr<CloudPolicyStore> store_; |
99 scoped_ptr<CloudPolicyService> service_; | 107 scoped_ptr<CloudPolicyService> service_; |
100 scoped_ptr<CloudPolicyRefreshScheduler> refresh_scheduler_; | 108 scoped_ptr<CloudPolicyRefreshScheduler> refresh_scheduler_; |
101 | 109 |
102 // The pref service to pass to the refresh scheduler on initialization. | 110 // The pref service to pass to the refresh scheduler on initialization. |
103 PrefService* prefs_; | 111 PrefService* prefs_; |
104 | 112 |
105 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyManager); | 113 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyManager); |
106 }; | 114 }; |
107 | 115 |
108 } // namespace policy | 116 } // namespace policy |
109 | 117 |
110 #endif // CHROME_BROWSER_POLICY_USER_CLOUD_POLICY_MANAGER_H_ | 118 #endif // CHROME_BROWSER_POLICY_USER_CLOUD_POLICY_MANAGER_H_ |
OLD | NEW |