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

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

Issue 343103005: Revert 278518 "Wire up component cloud policy to device local ac..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: 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"
15 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
16 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
17 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
18 #include "base/observer_list.h" 17 #include "base/observer_list.h"
19 #include "chrome/browser/chromeos/extensions/device_local_account_external_polic y_loader.h" 18 #include "chrome/browser/chromeos/extensions/device_local_account_external_polic y_loader.h"
20 #include "chrome/browser/chromeos/policy/device_local_account_external_data_mana ger.h" 19 #include "chrome/browser/chromeos/policy/device_local_account_external_data_mana ger.h"
21 #include "chrome/browser/chromeos/settings/cros_settings.h" 20 #include "chrome/browser/chromeos/settings/cros_settings.h"
22 #include "components/policy/core/common/cloud/cloud_policy_core.h" 21 #include "components/policy/core/common/cloud/cloud_policy_core.h"
23 #include "components/policy/core/common/cloud/cloud_policy_store.h" 22 #include "components/policy/core/common/cloud/cloud_policy_store.h"
24 23
(...skipping 17 matching lines...) Expand all
42 class DeviceLocalAccountPolicyStore; 41 class DeviceLocalAccountPolicyStore;
43 class DeviceManagementService; 42 class DeviceManagementService;
44 43
45 // The main switching central that downloads, caches, refreshes, etc. policy for 44 // The main switching central that downloads, caches, refreshes, etc. policy for
46 // a single device-local account. 45 // a single device-local account.
47 class DeviceLocalAccountPolicyBroker { 46 class DeviceLocalAccountPolicyBroker {
48 public: 47 public:
49 // |task_runner| is the runner for policy refresh tasks. 48 // |task_runner| is the runner for policy refresh tasks.
50 DeviceLocalAccountPolicyBroker( 49 DeviceLocalAccountPolicyBroker(
51 const DeviceLocalAccount& account, 50 const DeviceLocalAccount& account,
52 const base::FilePath& component_policy_cache_path,
53 scoped_ptr<DeviceLocalAccountPolicyStore> store, 51 scoped_ptr<DeviceLocalAccountPolicyStore> store,
54 scoped_refptr<DeviceLocalAccountExternalDataManager> 52 scoped_refptr<DeviceLocalAccountExternalDataManager>
55 external_data_manager, 53 external_data_manager,
56 const scoped_refptr<base::SequencedTaskRunner>& task_runner); 54 const scoped_refptr<base::SequencedTaskRunner>& task_runner);
57 ~DeviceLocalAccountPolicyBroker(); 55 ~DeviceLocalAccountPolicyBroker();
58 56
59 // Initialize the broker, loading its |store_|. 57 // Initialize the broker, loading its |store_|.
60 void Initialize(); 58 void Initialize();
61 59
62 // For the difference between |account_id| and |user_id|, see the 60 // For the difference between |account_id| and |user_id|, see the
(...skipping 18 matching lines...) Expand all
81 DeviceManagementService* device_management_service, 79 DeviceManagementService* device_management_service,
82 scoped_refptr<net::URLRequestContextGetter> request_context); 80 scoped_refptr<net::URLRequestContextGetter> request_context);
83 81
84 // Reads the refresh delay from policy and configures the refresh scheduler. 82 // Reads the refresh delay from policy and configures the refresh scheduler.
85 void UpdateRefreshDelay(); 83 void UpdateRefreshDelay();
86 84
87 // Retrieves the display name for the account as stored in policy. Returns an 85 // Retrieves the display name for the account as stored in policy. Returns an
88 // empty string if the policy is not present. 86 // empty string if the policy is not present.
89 std::string GetDisplayName() const; 87 std::string GetDisplayName() const;
90 88
91 // Returns a directory where component policy for this account can be cached.
92 // The DeviceLocalAccountPolicyService takes care of cleaning up caches of
93 // accounts that have been removed.
94 base::FilePath GetComponentPolicyCachePath() const;
95
96 private: 89 private:
97 const std::string account_id_; 90 const std::string account_id_;
98 const std::string user_id_; 91 const std::string user_id_;
99 const base::FilePath component_policy_cache_path_;
100 const scoped_ptr<DeviceLocalAccountPolicyStore> store_; 92 const scoped_ptr<DeviceLocalAccountPolicyStore> store_;
101 scoped_refptr<DeviceLocalAccountExternalDataManager> external_data_manager_; 93 scoped_refptr<DeviceLocalAccountExternalDataManager> external_data_manager_;
102 scoped_refptr<chromeos::DeviceLocalAccountExternalPolicyLoader> 94 scoped_refptr<chromeos::DeviceLocalAccountExternalPolicyLoader>
103 extension_loader_; 95 extension_loader_;
104 CloudPolicyCore core_; 96 CloudPolicyCore core_;
105 97
106 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyBroker); 98 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyBroker);
107 }; 99 };
108 100
109 // Manages user policy blobs for device-local accounts present on the device. 101 // Manages user policy blobs for device-local accounts present on the device.
110 // The actual policy blobs are brokered by session_manager (to prevent file 102 // The actual policy blobs are brokered by session_manager (to prevent file
111 // manipulation), and we're making signature checks on the policy blobs to 103 // manipulation), and we're making signature checks on the policy blobs to
112 // ensure they're issued by the device owner. 104 // ensure they're issued by the device owner.
113 class DeviceLocalAccountPolicyService : public CloudPolicyStore::Observer { 105 class DeviceLocalAccountPolicyService : public CloudPolicyStore::Observer {
114 public: 106 public:
115 // Interface for interested parties to observe policy changes. 107 // Interface for interested parties to observe policy changes.
116 class Observer { 108 class Observer {
117 public: 109 public:
118 virtual ~Observer() {} 110 virtual ~Observer() {}
119 111
120 // Policy for the given |user_id| has changed. 112 // Policy for the given |user_id| has changed.
121 virtual void OnPolicyUpdated(const std::string& user_id) = 0; 113 virtual void OnPolicyUpdated(const std::string& user_id) = 0;
122 114
123 // The list of accounts has been updated. 115 // The list of accounts has been updated.
124 virtual void OnDeviceLocalAccountsChanged() = 0; 116 virtual void OnDeviceLocalAccountsChanged() = 0;
125
126 // The given |broker| is about to be destroyed.
127 virtual void OnBrokerShutdown(DeviceLocalAccountPolicyBroker* broker) {}
128 }; 117 };
129 118
130 DeviceLocalAccountPolicyService( 119 DeviceLocalAccountPolicyService(
131 chromeos::SessionManagerClient* session_manager_client, 120 chromeos::SessionManagerClient* session_manager_client,
132 chromeos::DeviceSettingsService* device_settings_service, 121 chromeos::DeviceSettingsService* device_settings_service,
133 chromeos::CrosSettings* cros_settings, 122 chromeos::CrosSettings* cros_settings,
134 scoped_refptr<base::SequencedTaskRunner> store_background_task_runner, 123 scoped_refptr<base::SequencedTaskRunner> store_background_task_runner,
135 scoped_refptr<base::SequencedTaskRunner> extension_cache_task_runner, 124 scoped_refptr<base::SequencedTaskRunner> extension_cache_task_runner,
136 scoped_refptr<base::SequencedTaskRunner> 125 scoped_refptr<base::SequencedTaskRunner>
137 external_data_service_backend_task_runner, 126 external_data_service_backend_task_runner,
138 scoped_refptr<base::SequencedTaskRunner> io_task_runner, 127 scoped_refptr<base::SequencedTaskRunner> io_task_runner,
139 scoped_refptr<net::URLRequestContextGetter> request_context); 128 scoped_refptr<net::URLRequestContextGetter> request_context);
140 virtual ~DeviceLocalAccountPolicyService(); 129 virtual ~DeviceLocalAccountPolicyService();
141 130
142 // Shuts down the service and prevents further policy fetches from the cloud. 131 // Shuts down the service and prevents further policy fetches from the cloud.
143 void Shutdown(); 132 void Shutdown();
144 133
145 // Initializes the cloud policy service connection. 134 // Initializes the cloud policy service connection.
146 void Connect(DeviceManagementService* device_management_service); 135 void Connect(DeviceManagementService* device_management_service);
147 136
148 // Get the policy broker for a given |user_id|. Returns NULL if that |user_id| 137 // Get the policy broker for a given |user_id|. Returns NULL if that |user_id|
149 // does not belong to an existing device-local account. 138 // does not belong to an existing device-local account.
150 DeviceLocalAccountPolicyBroker* GetBrokerForUser(const std::string& user_id); 139 DeviceLocalAccountPolicyBroker* GetBrokerForUser(const std::string& user_id);
151 140
152 // Indicates whether policy has been successfully fetched for the given 141 // Indicates whether policy has been successfully fetched for the given
153 // |user_id|. 142 // |user_id|.
154 bool IsPolicyAvailableForUser(const std::string& user_id); 143 bool IsPolicyAvailableForUser(const std::string& user_id);
155 144
156 scoped_refptr<net::URLRequestContextGetter> request_context() const;
157
158 void AddObserver(Observer* observer); 145 void AddObserver(Observer* observer);
159 void RemoveObserver(Observer* observer); 146 void RemoveObserver(Observer* observer);
160 147
161 // CloudPolicyStore::Observer: 148 // CloudPolicyStore::Observer:
162 virtual void OnStoreLoaded(CloudPolicyStore* store) OVERRIDE; 149 virtual void OnStoreLoaded(CloudPolicyStore* store) OVERRIDE;
163 virtual void OnStoreError(CloudPolicyStore* store) OVERRIDE; 150 virtual void OnStoreError(CloudPolicyStore* store) OVERRIDE;
164 151
165 private: 152 private:
166 typedef std::map<std::string, DeviceLocalAccountPolicyBroker*> 153 typedef std::map<std::string, DeviceLocalAccountPolicyBroker*>
167 PolicyBrokerMap; 154 PolicyBrokerMap;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 const scoped_refptr<base::SequencedTaskRunner> store_background_task_runner_; 222 const scoped_refptr<base::SequencedTaskRunner> store_background_task_runner_;
236 const scoped_refptr<base::SequencedTaskRunner> extension_cache_task_runner_; 223 const scoped_refptr<base::SequencedTaskRunner> extension_cache_task_runner_;
237 224
238 scoped_ptr<DeviceLocalAccountExternalDataService> external_data_service_; 225 scoped_ptr<DeviceLocalAccountExternalDataService> external_data_service_;
239 226
240 scoped_refptr<net::URLRequestContextGetter> request_context_; 227 scoped_refptr<net::URLRequestContextGetter> request_context_;
241 228
242 const scoped_ptr<chromeos::CrosSettings::ObserverSubscription> 229 const scoped_ptr<chromeos::CrosSettings::ObserverSubscription>
243 local_accounts_subscription_; 230 local_accounts_subscription_;
244 231
245 // Path to the directory that contains the cached policies for components
246 // for device local accounts.
247 base::FilePath component_policy_cache_root_;
248
249 base::WeakPtrFactory<DeviceLocalAccountPolicyService> weak_factory_; 232 base::WeakPtrFactory<DeviceLocalAccountPolicyService> weak_factory_;
250 233
251 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyService); 234 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyService);
252 }; 235 };
253 236
254 } // namespace policy 237 } // namespace policy
255 238
256 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_POLICY_SERVICE_H_ 239 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_POLICY_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698