| 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 callback.Run(); | 131 callback.Run(); |
| 132 } | 132 } |
| 133 | 133 |
| 134 void SessionManagerOperation::RetrieveDeviceSettings() { | 134 void SessionManagerOperation::RetrieveDeviceSettings() { |
| 135 session_manager_client()->RetrieveDevicePolicy( | 135 session_manager_client()->RetrieveDevicePolicy( |
| 136 base::Bind(&SessionManagerOperation::ValidateDeviceSettings, | 136 base::Bind(&SessionManagerOperation::ValidateDeviceSettings, |
| 137 weak_factory_.GetWeakPtr())); | 137 weak_factory_.GetWeakPtr())); |
| 138 } | 138 } |
| 139 | 139 |
| 140 void SessionManagerOperation::BlockingRetrieveDeviceSettings() { | 140 void SessionManagerOperation::BlockingRetrieveDeviceSettings() { |
| 141 ValidateDeviceSettings( | 141 std::string policy_blob; |
| 142 session_manager_client()->BlockingRetrieveDevicePolicy()); | 142 RetrievePolicyResponseType response = |
| 143 session_manager_client()->BlockingRetrieveDevicePolicy(&policy_blob); |
| 144 ValidateDeviceSettings(policy_blob, response); |
| 143 } | 145 } |
| 144 | 146 |
| 145 void SessionManagerOperation::ValidateDeviceSettings( | 147 void SessionManagerOperation::ValidateDeviceSettings( |
| 146 const std::string& policy_blob) { | 148 const std::string& policy_blob, |
| 149 RetrievePolicyResponseType response_type) { |
| 147 std::unique_ptr<em::PolicyFetchResponse> policy( | 150 std::unique_ptr<em::PolicyFetchResponse> policy( |
| 148 new em::PolicyFetchResponse()); | 151 new em::PolicyFetchResponse()); |
| 149 if (policy_blob.empty()) { | 152 if (policy_blob.empty()) { |
| 150 ReportResult(DeviceSettingsService::STORE_NO_POLICY); | 153 ReportResult(DeviceSettingsService::STORE_NO_POLICY); |
| 151 return; | 154 return; |
| 152 } | 155 } |
| 153 | 156 |
| 154 if (!policy->ParseFromString(policy_blob) || | 157 if (!policy->ParseFromString(policy_blob) || !policy->IsInitialized()) { |
| 155 !policy->IsInitialized()) { | |
| 156 ReportResult(DeviceSettingsService::STORE_INVALID_POLICY); | 158 ReportResult(DeviceSettingsService::STORE_INVALID_POLICY); |
| 157 return; | 159 return; |
| 158 } | 160 } |
| 159 | 161 |
| 160 base::SequencedWorkerPool* pool = | 162 base::SequencedWorkerPool* pool = |
| 161 content::BrowserThread::GetBlockingPool(); | 163 content::BrowserThread::GetBlockingPool(); |
| 162 scoped_refptr<base::SequencedTaskRunner> background_task_runner = | 164 scoped_refptr<base::SequencedTaskRunner> background_task_runner = |
| 163 pool->GetSequencedTaskRunnerWithShutdownBehavior( | 165 pool->GetSequencedTaskRunnerWithShutdownBehavior( |
| 164 pool->GetSequenceToken(), | 166 pool->GetSequenceToken(), |
| 165 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); | 167 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 } | 275 } |
| 274 | 276 |
| 275 void StoreSettingsOperation::HandleStoreResult(bool success) { | 277 void StoreSettingsOperation::HandleStoreResult(bool success) { |
| 276 if (!success) | 278 if (!success) |
| 277 ReportResult(DeviceSettingsService::STORE_OPERATION_FAILED); | 279 ReportResult(DeviceSettingsService::STORE_OPERATION_FAILED); |
| 278 else | 280 else |
| 279 StartLoading(); | 281 StartLoading(); |
| 280 } | 282 } |
| 281 | 283 |
| 282 } // namespace chromeos | 284 } // namespace chromeos |
| OLD | NEW |