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

Side by Side Diff: chrome/browser/chromeos/settings/device_settings_service.h

Issue 654263003: Implemented OwnerSettingsService::Set() method. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes. Created 6 years, 2 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
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_SETTINGS_DEVICE_SETTINGS_SERVICE_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_SETTINGS_SERVICE_H_
6 #define CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_SETTINGS_SERVICE_H_ 6 #define CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_SETTINGS_SERVICE_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
15 #include "base/memory/linked_ptr.h"
15 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
16 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
17 #include "base/observer_list.h" 18 #include "base/observer_list.h"
18 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" 19 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h"
19 #include "chromeos/dbus/session_manager_client.h" 20 #include "chromeos/dbus/session_manager_client.h"
20 #include "components/ownership/owner_settings_service.h" 21 #include "components/ownership/owner_settings_service.h"
21 #include "components/policy/core/common/cloud/cloud_policy_validator.h" 22 #include "components/policy/core/common/cloud/cloud_policy_validator.h"
22 #include "crypto/scoped_nss_types.h" 23 #include "crypto/scoped_nss_types.h"
23 #include "policy/proto/device_management_backend.pb.h" 24 #include "policy/proto/device_management_backend.pb.h"
24 25
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 bool HasPrivateOwnerKey(); 163 bool HasPrivateOwnerKey();
163 164
164 // Sets the identity of the user that's interacting with the service. This is 165 // Sets the identity of the user that's interacting with the service. This is
165 // relevant only for writing settings through SignAndStore(). 166 // relevant only for writing settings through SignAndStore().
166 void InitOwner(const std::string& username, 167 void InitOwner(const std::string& username,
167 const base::WeakPtr<ownership::OwnerSettingsService>& 168 const base::WeakPtr<ownership::OwnerSettingsService>&
168 owner_settings_service); 169 owner_settings_service);
169 170
170 const std::string& GetUsername() const; 171 const std::string& GetUsername() const;
171 172
173 ownership::OwnerSettingsService* GetOwnerSettingsService() const;
174
172 // Adds an observer. 175 // Adds an observer.
173 void AddObserver(Observer* observer); 176 void AddObserver(Observer* observer);
174 // Removes an observer. 177 // Removes an observer.
175 void RemoveObserver(Observer* observer); 178 void RemoveObserver(Observer* observer);
176 179
177 // SessionManagerClient::Observer: 180 // SessionManagerClient::Observer:
178 virtual void OwnerKeySet(bool success) override; 181 virtual void OwnerKeySet(bool success) override;
179 virtual void PropertyChangeComplete(bool success) override; 182 virtual void PropertyChangeComplete(bool success) override;
180 183
181 private: 184 private:
182 friend class OwnerSettingsServiceChromeOS; 185 friend class OwnerSettingsServiceChromeOS;
183 186
184 // Enqueues a new operation. Takes ownership of |operation| and starts it 187 // Enqueues a new operation. Takes ownership of |operation| and starts it
185 // right away if there is no active operation currently. 188 // right away if there is no active operation currently.
186 void Enqueue(SessionManagerOperation* operation); 189 void Enqueue(const linked_ptr<SessionManagerOperation>& operation);
187 190
188 // Enqueues a load operation. 191 // Enqueues a load operation.
189 void EnqueueLoad(bool force_key_load); 192 void EnqueueLoad(bool force_key_load);
190 193
194 // Enqueues a sign and store operation.
195 void EnqueueSignAndStore(scoped_ptr<enterprise_management::PolicyData> policy,
196 const base::Closure& callback);
197
191 // Makes sure there's a reload operation so changes to the settings (and key, 198 // Makes sure there's a reload operation so changes to the settings (and key,
192 // in case force_key_load is set) are getting picked up. 199 // in case force_key_load is set) are getting picked up.
193 void EnsureReload(bool force_key_load); 200 void EnsureReload(bool force_key_load);
194 201
195 // Runs the next pending operation. 202 // Runs the next pending operation.
196 void StartNextOperation(); 203 void StartNextOperation();
197 204
198 // Updates status, policy data and owner key from a finished operation. 205 // Updates status, policy data and owner key from a finished operation.
199 // Starts the next pending operation if available. 206 // Starts the next pending operation if available.
200 void HandleCompletedOperation(const base::Closure& callback, 207 void HandleCompletedOperation(const base::Closure& callback,
201 SessionManagerOperation* operation, 208 SessionManagerOperation* operation,
202 Status status); 209 Status status);
203 210
204 // Updates status and invokes the callback immediately. 211 // Updates status and invokes the callback immediately.
205 void HandleError(Status status, const base::Closure& callback); 212 void HandleError(Status status, const base::Closure& callback);
206 213
207 // Called by OwnerSettingsService when sign-and-store operation completes.
208 void OnSignAndStoreOperationCompleted(Status status);
209
210 void set_policy_data(
211 scoped_ptr<enterprise_management::PolicyData> policy_data) {
212 policy_data_ = policy_data.Pass();
213 }
214
215 void set_device_settings(scoped_ptr<
216 enterprise_management::ChromeDeviceSettingsProto> device_settings) {
217 device_settings_ = device_settings.Pass();
218 }
219
220 SessionManagerClient* session_manager_client_; 214 SessionManagerClient* session_manager_client_;
221 scoped_refptr<ownership::OwnerKeyUtil> owner_key_util_; 215 scoped_refptr<ownership::OwnerKeyUtil> owner_key_util_;
222 216
223 Status store_status_; 217 Status store_status_;
224 218
225 std::vector<OwnershipStatusCallback> pending_ownership_status_callbacks_; 219 std::vector<OwnershipStatusCallback> pending_ownership_status_callbacks_;
226 220
227 std::string username_; 221 std::string username_;
228 scoped_refptr<ownership::PublicKey> public_key_; 222 scoped_refptr<ownership::PublicKey> public_key_;
229 base::WeakPtr<ownership::OwnerSettingsService> owner_settings_service_; 223 base::WeakPtr<ownership::OwnerSettingsService> owner_settings_service_;
230 224
231 scoped_ptr<enterprise_management::PolicyData> policy_data_; 225 scoped_ptr<enterprise_management::PolicyData> policy_data_;
232 scoped_ptr<enterprise_management::ChromeDeviceSettingsProto> device_settings_; 226 scoped_ptr<enterprise_management::ChromeDeviceSettingsProto> device_settings_;
233 227
234 // The queue of pending operations. The first operation on the queue is 228 // The queue of pending operations. The first operation on the queue is
235 // currently active; it gets removed and destroyed once it completes. 229 // currently active; it gets removed and destroyed once it completes.
236 std::deque<SessionManagerOperation*> pending_operations_; 230 std::deque<linked_ptr<SessionManagerOperation>> pending_operations_;
237 231
238 ObserverList<Observer, true> observers_; 232 ObserverList<Observer> observers_;
239 233
240 // For recoverable load errors how many retries are left before we give up. 234 // For recoverable load errors how many retries are left before we give up.
241 int load_retries_left_; 235 int load_retries_left_;
242 236
243 base::WeakPtrFactory<DeviceSettingsService> weak_factory_; 237 base::WeakPtrFactory<DeviceSettingsService> weak_factory_;
244 238
245 DISALLOW_COPY_AND_ASSIGN(DeviceSettingsService); 239 DISALLOW_COPY_AND_ASSIGN(DeviceSettingsService);
246 }; 240 };
247 241
248 // Helper class for tests. Initializes the DeviceSettingsService singleton on 242 // Helper class for tests. Initializes the DeviceSettingsService singleton on
249 // construction and tears it down again on destruction. 243 // construction and tears it down again on destruction.
250 class ScopedTestDeviceSettingsService { 244 class ScopedTestDeviceSettingsService {
251 public: 245 public:
252 ScopedTestDeviceSettingsService(); 246 ScopedTestDeviceSettingsService();
253 ~ScopedTestDeviceSettingsService(); 247 ~ScopedTestDeviceSettingsService();
254 248
255 private: 249 private:
256 DISALLOW_COPY_AND_ASSIGN(ScopedTestDeviceSettingsService); 250 DISALLOW_COPY_AND_ASSIGN(ScopedTestDeviceSettingsService);
257 }; 251 };
258 252
259 } // namespace chromeos 253 } // namespace chromeos
260 254
261 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_SETTINGS_SERVICE_H_ 255 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_SETTINGS_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698