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

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

Issue 769703003: SetManagementSettings() is moved to OwnerSettingsServiceChromeOS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Failing test fixed. Created 6 years 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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 weak_factory_.GetWeakPtr())); 232 weak_factory_.GetWeakPtr()));
233 } 233 }
234 234
235 void StoreSettingsOperation::HandleStoreResult(bool success) { 235 void StoreSettingsOperation::HandleStoreResult(bool success) {
236 if (!success) 236 if (!success)
237 ReportResult(DeviceSettingsService::STORE_OPERATION_FAILED); 237 ReportResult(DeviceSettingsService::STORE_OPERATION_FAILED);
238 else 238 else
239 StartLoading(); 239 StartLoading();
240 } 240 }
241 241
242 SignAndStoreSettingsOperation::SignAndStoreSettingsOperation(
243 const Callback& callback,
244 scoped_ptr<em::PolicyData> new_policy)
245 : SessionManagerOperation(callback),
246 new_policy_(new_policy.Pass()),
247 weak_factory_(this) {
248 }
249
250 SignAndStoreSettingsOperation::~SignAndStoreSettingsOperation() {}
251
252 void SignAndStoreSettingsOperation::Run() {
253 if (!new_policy_) {
254 ReportResult(DeviceSettingsService::STORE_POLICY_ERROR);
255 return;
256 }
257 if (!owner_settings_service_) {
258 ReportResult(DeviceSettingsService::STORE_KEY_UNAVAILABLE);
259 return;
260 }
261 owner_settings_service_->IsOwnerAsync(
262 base::Bind(&SignAndStoreSettingsOperation::StartSigning,
263 weak_factory_.GetWeakPtr()));
264 }
265
266 void SignAndStoreSettingsOperation::StartSigning(bool is_owner) {
267 if (!owner_settings_service_ || !is_owner) {
268 ReportResult(DeviceSettingsService::STORE_KEY_UNAVAILABLE);
269 return;
270 }
271
272 bool rv = owner_settings_service_->AssembleAndSignPolicyAsync(
273 content::BrowserThread::GetBlockingPool(),
274 new_policy_.Pass(),
275 base::Bind(&SignAndStoreSettingsOperation::StoreDeviceSettings,
276 weak_factory_.GetWeakPtr()));
277 if (!rv) {
278 ReportResult(DeviceSettingsService::STORE_KEY_UNAVAILABLE);
279 return;
280 }
281 }
282
283 void SignAndStoreSettingsOperation::StoreDeviceSettings(
284 scoped_ptr<em::PolicyFetchResponse> policy_response) {
285 if (!policy_response.get()) {
286 ReportResult(DeviceSettingsService::STORE_POLICY_ERROR);
287 return;
288 }
289
290 session_manager_client()->StoreDevicePolicy(
291 policy_response->SerializeAsString(),
292 base::Bind(&SignAndStoreSettingsOperation::HandleStoreResult,
293 weak_factory_.GetWeakPtr()));
294 }
295
296 void SignAndStoreSettingsOperation::HandleStoreResult(bool success) {
297 if (!success)
298 ReportResult(DeviceSettingsService::STORE_OPERATION_FAILED);
299 else
300 StartLoading();
301 }
302
303 } // namespace chromeos 242 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698