OLD | NEW |
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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 } | 127 } |
128 | 128 |
129 void SessionManagerOperation::RetrieveDeviceSettings() { | 129 void SessionManagerOperation::RetrieveDeviceSettings() { |
130 session_manager_client()->RetrieveDevicePolicy( | 130 session_manager_client()->RetrieveDevicePolicy( |
131 base::Bind(&SessionManagerOperation::ValidateDeviceSettings, | 131 base::Bind(&SessionManagerOperation::ValidateDeviceSettings, |
132 weak_factory_.GetWeakPtr())); | 132 weak_factory_.GetWeakPtr())); |
133 } | 133 } |
134 | 134 |
135 void SessionManagerOperation::ValidateDeviceSettings( | 135 void SessionManagerOperation::ValidateDeviceSettings( |
136 const std::string& policy_blob) { | 136 const std::string& policy_blob) { |
137 scoped_ptr<em::PolicyFetchResponse> policy(new em::PolicyFetchResponse()); | 137 std::unique_ptr<em::PolicyFetchResponse> policy( |
| 138 new em::PolicyFetchResponse()); |
138 if (policy_blob.empty()) { | 139 if (policy_blob.empty()) { |
139 ReportResult(DeviceSettingsService::STORE_NO_POLICY); | 140 ReportResult(DeviceSettingsService::STORE_NO_POLICY); |
140 return; | 141 return; |
141 } | 142 } |
142 | 143 |
143 if (!policy->ParseFromString(policy_blob) || | 144 if (!policy->ParseFromString(policy_blob) || |
144 !policy->IsInitialized()) { | 145 !policy->IsInitialized()) { |
145 ReportResult(DeviceSettingsService::STORE_INVALID_POLICY); | 146 ReportResult(DeviceSettingsService::STORE_INVALID_POLICY); |
146 return; | 147 return; |
147 } | 148 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 : SessionManagerOperation(callback) {} | 213 : SessionManagerOperation(callback) {} |
213 | 214 |
214 LoadSettingsOperation::~LoadSettingsOperation() {} | 215 LoadSettingsOperation::~LoadSettingsOperation() {} |
215 | 216 |
216 void LoadSettingsOperation::Run() { | 217 void LoadSettingsOperation::Run() { |
217 StartLoading(); | 218 StartLoading(); |
218 } | 219 } |
219 | 220 |
220 StoreSettingsOperation::StoreSettingsOperation( | 221 StoreSettingsOperation::StoreSettingsOperation( |
221 const Callback& callback, | 222 const Callback& callback, |
222 scoped_ptr<em::PolicyFetchResponse> policy) | 223 std::unique_ptr<em::PolicyFetchResponse> policy) |
223 : SessionManagerOperation(callback), | 224 : SessionManagerOperation(callback), |
224 policy_(std::move(policy)), | 225 policy_(std::move(policy)), |
225 weak_factory_(this) {} | 226 weak_factory_(this) {} |
226 | 227 |
227 StoreSettingsOperation::~StoreSettingsOperation() {} | 228 StoreSettingsOperation::~StoreSettingsOperation() {} |
228 | 229 |
229 void StoreSettingsOperation::Run() { | 230 void StoreSettingsOperation::Run() { |
230 session_manager_client()->StoreDevicePolicy( | 231 session_manager_client()->StoreDevicePolicy( |
231 policy_->SerializeAsString(), | 232 policy_->SerializeAsString(), |
232 base::Bind(&StoreSettingsOperation::HandleStoreResult, | 233 base::Bind(&StoreSettingsOperation::HandleStoreResult, |
233 weak_factory_.GetWeakPtr())); | 234 weak_factory_.GetWeakPtr())); |
234 } | 235 } |
235 | 236 |
236 void StoreSettingsOperation::HandleStoreResult(bool success) { | 237 void StoreSettingsOperation::HandleStoreResult(bool success) { |
237 if (!success) | 238 if (!success) |
238 ReportResult(DeviceSettingsService::STORE_OPERATION_FAILED); | 239 ReportResult(DeviceSettingsService::STORE_OPERATION_FAILED); |
239 else | 240 else |
240 StartLoading(); | 241 StartLoading(); |
241 } | 242 } |
242 | 243 |
243 } // namespace chromeos | 244 } // namespace chromeos |
OLD | NEW |