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

Side by Side Diff: chrome/browser/chromeos/settings/session_manager_operation.cc

Issue 640063008: Revert of Implemented OwnerSettingsService::Set() method. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 #include "chrome/browser/chromeos/settings/session_manager_operation.h" 5 #include "chrome/browser/chromeos/settings/session_manager_operation.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 else 238 else
239 StartLoading(); 239 StartLoading();
240 } 240 }
241 241
242 SignAndStoreSettingsOperation::SignAndStoreSettingsOperation( 242 SignAndStoreSettingsOperation::SignAndStoreSettingsOperation(
243 const Callback& callback, 243 const Callback& callback,
244 scoped_ptr<em::PolicyData> new_policy) 244 scoped_ptr<em::PolicyData> new_policy)
245 : SessionManagerOperation(callback), 245 : SessionManagerOperation(callback),
246 new_policy_(new_policy.Pass()), 246 new_policy_(new_policy.Pass()),
247 weak_factory_(this) { 247 weak_factory_(this) {
248 DCHECK(new_policy_);
248 } 249 }
249 250
250 SignAndStoreSettingsOperation::~SignAndStoreSettingsOperation() {} 251 SignAndStoreSettingsOperation::~SignAndStoreSettingsOperation() {}
251 252
252 void SignAndStoreSettingsOperation::Run() { 253 void SignAndStoreSettingsOperation::Run() {
253 if (!new_policy_) {
254 ReportResult(DeviceSettingsService::STORE_POLICY_ERROR);
255 return;
256 }
257 if (!owner_settings_service_) { 254 if (!owner_settings_service_) {
258 ReportResult(DeviceSettingsService::STORE_KEY_UNAVAILABLE); 255 ReportResult(DeviceSettingsService::STORE_KEY_UNAVAILABLE);
259 return; 256 return;
260 } 257 }
261 owner_settings_service_->IsOwnerAsync( 258 owner_settings_service_->IsOwnerAsync(
262 base::Bind(&SignAndStoreSettingsOperation::StartSigning, 259 base::Bind(&SignAndStoreSettingsOperation::StartSigning,
263 weak_factory_.GetWeakPtr())); 260 weak_factory_.GetWeakPtr()));
264 } 261 }
265 262
266 void SignAndStoreSettingsOperation::StartSigning(bool is_owner) { 263 void SignAndStoreSettingsOperation::StartSigning(bool is_owner) {
267 if (!owner_settings_service_ || !is_owner) { 264 if (!owner_settings_service_ || !is_owner) {
268 ReportResult(DeviceSettingsService::STORE_KEY_UNAVAILABLE); 265 ReportResult(DeviceSettingsService::STORE_KEY_UNAVAILABLE);
269 return; 266 return;
270 } 267 }
271 268
272 bool rv = owner_settings_service_->AssembleAndSignPolicyAsync( 269 bool rv = owner_settings_service_->AssembleAndSignPolicyAsync(
273 content::BrowserThread::GetBlockingPool(), 270 content::BrowserThread::GetBlockingPool(),
274 new_policy_.Pass(), 271 new_policy_.Pass(),
275 base::Bind(&SignAndStoreSettingsOperation::StoreDeviceSettings, 272 base::Bind(&SignAndStoreSettingsOperation::StoreDeviceSettingsBlob,
276 weak_factory_.GetWeakPtr())); 273 weak_factory_.GetWeakPtr()));
277 if (!rv) { 274 if (!rv) {
278 ReportResult(DeviceSettingsService::STORE_KEY_UNAVAILABLE); 275 ReportResult(DeviceSettingsService::STORE_KEY_UNAVAILABLE);
279 return; 276 return;
280 } 277 }
281 } 278 }
282 279
283 void SignAndStoreSettingsOperation::StoreDeviceSettings( 280 void SignAndStoreSettingsOperation::StoreDeviceSettingsBlob(
284 scoped_ptr<em::PolicyFetchResponse> policy_response) { 281 std::string device_settings_blob) {
285 if (!policy_response.get()) { 282 if (device_settings_blob.empty()) {
286 ReportResult(DeviceSettingsService::STORE_POLICY_ERROR); 283 ReportResult(DeviceSettingsService::STORE_POLICY_ERROR);
287 return; 284 return;
288 } 285 }
289 286
290 session_manager_client()->StoreDevicePolicy( 287 session_manager_client()->StoreDevicePolicy(
291 policy_response->SerializeAsString(), 288 device_settings_blob,
292 base::Bind(&SignAndStoreSettingsOperation::HandleStoreResult, 289 base::Bind(&SignAndStoreSettingsOperation::HandleStoreResult,
293 weak_factory_.GetWeakPtr())); 290 weak_factory_.GetWeakPtr()));
294 } 291 }
295 292
296 void SignAndStoreSettingsOperation::HandleStoreResult(bool success) { 293 void SignAndStoreSettingsOperation::HandleStoreResult(bool success) {
297 if (!success) 294 if (!success)
298 ReportResult(DeviceSettingsService::STORE_OPERATION_FAILED); 295 ReportResult(DeviceSettingsService::STORE_OPERATION_FAILED);
299 else 296 else
300 StartLoading(); 297 StartLoading();
301 } 298 }
302 299
303 } // namespace chromeos 300 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/settings/session_manager_operation.h ('k') | chrome/chrome_tests_unit.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698