Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1169)

Side by Side Diff: chrome/browser/chromeos/policy/device_local_account_policy_service.h

Issue 341043005: Wire up component cloud policy to device local accounts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix tests Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_POLICY_SERVICE_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_POLICY_SERVICE_H_
6 #define CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_POLICY_SERVICE_H_ 6 #define CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_POLICY_SERVICE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/files/file_path.h"
14 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
15 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
16 #include "base/memory/weak_ptr.h" 17 #include "base/memory/weak_ptr.h"
17 #include "base/observer_list.h" 18 #include "base/observer_list.h"
18 #include "chrome/browser/chromeos/extensions/device_local_account_external_polic y_loader.h" 19 #include "chrome/browser/chromeos/extensions/device_local_account_external_polic y_loader.h"
19 #include "chrome/browser/chromeos/policy/device_local_account_external_data_mana ger.h" 20 #include "chrome/browser/chromeos/policy/device_local_account_external_data_mana ger.h"
20 #include "chrome/browser/chromeos/settings/cros_settings.h" 21 #include "chrome/browser/chromeos/settings/cros_settings.h"
21 #include "components/policy/core/common/cloud/cloud_policy_core.h" 22 #include "components/policy/core/common/cloud/cloud_policy_core.h"
22 #include "components/policy/core/common/cloud/cloud_policy_store.h" 23 #include "components/policy/core/common/cloud/cloud_policy_store.h"
23 24
(...skipping 17 matching lines...) Expand all
41 class DeviceLocalAccountPolicyStore; 42 class DeviceLocalAccountPolicyStore;
42 class DeviceManagementService; 43 class DeviceManagementService;
43 44
44 // The main switching central that downloads, caches, refreshes, etc. policy for 45 // The main switching central that downloads, caches, refreshes, etc. policy for
45 // a single device-local account. 46 // a single device-local account.
46 class DeviceLocalAccountPolicyBroker { 47 class DeviceLocalAccountPolicyBroker {
47 public: 48 public:
48 // |task_runner| is the runner for policy refresh tasks. 49 // |task_runner| is the runner for policy refresh tasks.
49 DeviceLocalAccountPolicyBroker( 50 DeviceLocalAccountPolicyBroker(
50 const DeviceLocalAccount& account, 51 const DeviceLocalAccount& account,
52 const base::FilePath& component_policy_cache_path,
51 scoped_ptr<DeviceLocalAccountPolicyStore> store, 53 scoped_ptr<DeviceLocalAccountPolicyStore> store,
52 scoped_refptr<DeviceLocalAccountExternalDataManager> 54 scoped_refptr<DeviceLocalAccountExternalDataManager>
53 external_data_manager, 55 external_data_manager,
54 const scoped_refptr<base::SequencedTaskRunner>& task_runner); 56 const scoped_refptr<base::SequencedTaskRunner>& task_runner);
55 ~DeviceLocalAccountPolicyBroker(); 57 ~DeviceLocalAccountPolicyBroker();
56 58
57 // Initialize the broker, loading its |store_|. 59 // Initialize the broker, loading its |store_|.
58 void Initialize(); 60 void Initialize();
59 61
60 // For the difference between |account_id| and |user_id|, see the 62 // For the difference between |account_id| and |user_id|, see the
(...skipping 18 matching lines...) Expand all
79 DeviceManagementService* device_management_service, 81 DeviceManagementService* device_management_service,
80 scoped_refptr<net::URLRequestContextGetter> request_context); 82 scoped_refptr<net::URLRequestContextGetter> request_context);
81 83
82 // Reads the refresh delay from policy and configures the refresh scheduler. 84 // Reads the refresh delay from policy and configures the refresh scheduler.
83 void UpdateRefreshDelay(); 85 void UpdateRefreshDelay();
84 86
85 // Retrieves the display name for the account as stored in policy. Returns an 87 // Retrieves the display name for the account as stored in policy. Returns an
86 // empty string if the policy is not present. 88 // empty string if the policy is not present.
87 std::string GetDisplayName() const; 89 std::string GetDisplayName() const;
88 90
91 // Returns a directory where component policy for this account can be cached.
bartfab (slow) 2014/06/20 09:17:25 Nit: s/ a / the /
Joao da Silva 2014/06/20 11:48:46 Obsolete in the next CL
92 // The DeviceLocalAccountPolicyService takes care of cleaning up caches of
bartfab (slow) 2014/06/20 09:17:25 Nit: s /caches of/caches belonging to/
Joao da Silva 2014/06/20 11:48:45 Obsolete in the next CL
93 // accounts that have been removed.
94 base::FilePath GetComponentPolicyCachePath() const;
95
89 private: 96 private:
90 const std::string account_id_; 97 const std::string account_id_;
91 const std::string user_id_; 98 const std::string user_id_;
99 const base::FilePath component_policy_cache_path_;
92 const scoped_ptr<DeviceLocalAccountPolicyStore> store_; 100 const scoped_ptr<DeviceLocalAccountPolicyStore> store_;
93 scoped_refptr<DeviceLocalAccountExternalDataManager> external_data_manager_; 101 scoped_refptr<DeviceLocalAccountExternalDataManager> external_data_manager_;
94 scoped_refptr<chromeos::DeviceLocalAccountExternalPolicyLoader> 102 scoped_refptr<chromeos::DeviceLocalAccountExternalPolicyLoader>
95 extension_loader_; 103 extension_loader_;
96 CloudPolicyCore core_; 104 CloudPolicyCore core_;
97 105
98 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyBroker); 106 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyBroker);
99 }; 107 };
100 108
101 // Manages user policy blobs for device-local accounts present on the device. 109 // Manages user policy blobs for device-local accounts present on the device.
102 // The actual policy blobs are brokered by session_manager (to prevent file 110 // The actual policy blobs are brokered by session_manager (to prevent file
103 // manipulation), and we're making signature checks on the policy blobs to 111 // manipulation), and we're making signature checks on the policy blobs to
104 // ensure they're issued by the device owner. 112 // ensure they're issued by the device owner.
105 class DeviceLocalAccountPolicyService : public CloudPolicyStore::Observer { 113 class DeviceLocalAccountPolicyService : public CloudPolicyStore::Observer {
106 public: 114 public:
107 // Interface for interested parties to observe policy changes. 115 // Interface for interested parties to observe policy changes.
108 class Observer { 116 class Observer {
109 public: 117 public:
110 virtual ~Observer() {} 118 virtual ~Observer() {}
111 119
112 // Policy for the given |user_id| has changed. 120 // Policy for the given |user_id| has changed.
113 virtual void OnPolicyUpdated(const std::string& user_id) = 0; 121 virtual void OnPolicyUpdated(const std::string& user_id) = 0;
114 122
115 // The list of accounts has been updated. 123 // The list of accounts has been updated.
116 virtual void OnDeviceLocalAccountsChanged() = 0; 124 virtual void OnDeviceLocalAccountsChanged() = 0;
125
126 // The given |broker| is about to be destroyed.
127 virtual void OnBrokerShutdown(DeviceLocalAccountPolicyBroker* broker) {}
bartfab (slow) 2014/06/20 09:17:25 Nit: Instead of exposing the internal detail that
Joao da Silva 2014/06/20 11:48:45 This method has been removed.
117 }; 128 };
118 129
119 DeviceLocalAccountPolicyService( 130 DeviceLocalAccountPolicyService(
120 chromeos::SessionManagerClient* session_manager_client, 131 chromeos::SessionManagerClient* session_manager_client,
121 chromeos::DeviceSettingsService* device_settings_service, 132 chromeos::DeviceSettingsService* device_settings_service,
122 chromeos::CrosSettings* cros_settings, 133 chromeos::CrosSettings* cros_settings,
123 scoped_refptr<base::SequencedTaskRunner> store_background_task_runner, 134 scoped_refptr<base::SequencedTaskRunner> store_background_task_runner,
124 scoped_refptr<base::SequencedTaskRunner> extension_cache_task_runner, 135 scoped_refptr<base::SequencedTaskRunner> extension_cache_task_runner,
125 scoped_refptr<base::SequencedTaskRunner> 136 scoped_refptr<base::SequencedTaskRunner>
126 external_data_service_backend_task_runner, 137 external_data_service_backend_task_runner,
127 scoped_refptr<base::SequencedTaskRunner> io_task_runner, 138 scoped_refptr<base::SequencedTaskRunner> io_task_runner,
128 scoped_refptr<net::URLRequestContextGetter> request_context); 139 scoped_refptr<net::URLRequestContextGetter> request_context);
129 virtual ~DeviceLocalAccountPolicyService(); 140 virtual ~DeviceLocalAccountPolicyService();
130 141
131 // Shuts down the service and prevents further policy fetches from the cloud. 142 // Shuts down the service and prevents further policy fetches from the cloud.
132 void Shutdown(); 143 void Shutdown();
133 144
134 // Initializes the cloud policy service connection. 145 // Initializes the cloud policy service connection.
135 void Connect(DeviceManagementService* device_management_service); 146 void Connect(DeviceManagementService* device_management_service);
136 147
137 // Get the policy broker for a given |user_id|. Returns NULL if that |user_id| 148 // Get the policy broker for a given |user_id|. Returns NULL if that |user_id|
138 // does not belong to an existing device-local account. 149 // does not belong to an existing device-local account.
139 DeviceLocalAccountPolicyBroker* GetBrokerForUser(const std::string& user_id); 150 DeviceLocalAccountPolicyBroker* GetBrokerForUser(const std::string& user_id);
140 151
141 // Indicates whether policy has been successfully fetched for the given 152 // Indicates whether policy has been successfully fetched for the given
142 // |user_id|. 153 // |user_id|.
143 bool IsPolicyAvailableForUser(const std::string& user_id); 154 bool IsPolicyAvailableForUser(const std::string& user_id);
144 155
156 scoped_refptr<net::URLRequestContextGetter> request_context() const;
157
145 void AddObserver(Observer* observer); 158 void AddObserver(Observer* observer);
146 void RemoveObserver(Observer* observer); 159 void RemoveObserver(Observer* observer);
147 160
148 // CloudPolicyStore::Observer: 161 // CloudPolicyStore::Observer:
149 virtual void OnStoreLoaded(CloudPolicyStore* store) OVERRIDE; 162 virtual void OnStoreLoaded(CloudPolicyStore* store) OVERRIDE;
150 virtual void OnStoreError(CloudPolicyStore* store) OVERRIDE; 163 virtual void OnStoreError(CloudPolicyStore* store) OVERRIDE;
151 164
152 private: 165 private:
153 typedef std::map<std::string, DeviceLocalAccountPolicyBroker*> 166 typedef std::map<std::string, DeviceLocalAccountPolicyBroker*>
154 PolicyBrokerMap; 167 PolicyBrokerMap;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 // are not trusted yet. 218 // are not trusted yet.
206 bool waiting_for_cros_settings_; 219 bool waiting_for_cros_settings_;
207 220
208 // Orphaned extension caches are removed at startup. This tracks the status of 221 // Orphaned extension caches are removed at startup. This tracks the status of
209 // that process. 222 // that process.
210 enum OrphanCacheDeletionState { 223 enum OrphanCacheDeletionState {
211 NOT_STARTED, 224 NOT_STARTED,
212 IN_PROGRESS, 225 IN_PROGRESS,
213 DONE, 226 DONE,
214 }; 227 };
215 OrphanCacheDeletionState orphan_cache_deletion_state_; 228 OrphanCacheDeletionState orphan_cache_deletion_state_;
bartfab (slow) 2014/06/20 09:17:25 Nit: The type, member name and comment need to be
Joao da Silva 2014/06/20 11:48:46 Done.
216 229
217 // Account IDs whose extension cache directories are busy, either because a 230 // Account IDs whose extension cache directories are busy, either because a
218 // broker for the account has not shut down completely yet or because the 231 // broker for the account has not shut down completely yet or because the
219 // directory is being deleted. 232 // directory is being deleted.
220 std::set<std::string> busy_extension_cache_directories_; 233 std::set<std::string> busy_extension_cache_directories_;
221 234
222 const scoped_refptr<base::SequencedTaskRunner> store_background_task_runner_; 235 const scoped_refptr<base::SequencedTaskRunner> store_background_task_runner_;
223 const scoped_refptr<base::SequencedTaskRunner> extension_cache_task_runner_; 236 const scoped_refptr<base::SequencedTaskRunner> extension_cache_task_runner_;
224 237
225 scoped_ptr<DeviceLocalAccountExternalDataService> external_data_service_; 238 scoped_ptr<DeviceLocalAccountExternalDataService> external_data_service_;
226 239
227 scoped_refptr<net::URLRequestContextGetter> request_context_; 240 scoped_refptr<net::URLRequestContextGetter> request_context_;
228 241
229 const scoped_ptr<chromeos::CrosSettings::ObserverSubscription> 242 const scoped_ptr<chromeos::CrosSettings::ObserverSubscription>
230 local_accounts_subscription_; 243 local_accounts_subscription_;
231 244
245 // Path to the directory that contains the cached policies for components
bartfab (slow) 2014/06/20 09:17:25 Nit: s/policies/policy/
Joao da Silva 2014/06/20 11:48:45 Done.
246 // for device local accounts.
bartfab (slow) 2014/06/20 09:17:25 Nit: s/device local/device-local/
Joao da Silva 2014/06/20 11:48:45 Done.
247 base::FilePath component_policy_cache_root_;
248
232 base::WeakPtrFactory<DeviceLocalAccountPolicyService> weak_factory_; 249 base::WeakPtrFactory<DeviceLocalAccountPolicyService> weak_factory_;
233 250
234 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyService); 251 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyService);
235 }; 252 };
236 253
237 } // namespace policy 254 } // namespace policy
238 255
239 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_POLICY_SERVICE_H_ 256 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_POLICY_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698