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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 ValidateDeviceSettings( |
142 session_manager_client()->BlockingRetrieveDevicePolicy()); | 142 session_manager_client()->BlockingRetrieveDevicePolicy(), |
143 SessionManagerClient::SUCCESS); | |
emaxx
2017/04/18 15:03:17
Same comment as was above for DeviceLocalAccountPo
igorcov
2017/04/20 14:52:29
Done.
| |
143 } | 144 } |
144 | 145 |
145 void SessionManagerOperation::ValidateDeviceSettings( | 146 void SessionManagerOperation::ValidateDeviceSettings( |
146 const std::string& policy_blob) { | 147 const std::string& policy_blob, |
148 const chromeos::SessionManagerClient::RetrievePolicyResponseType& | |
149 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() && response_type == SessionManagerClient::SUCCESS) { |
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()) { | 158 response_type != SessionManagerClient::SUCCESS) { |
emaxx
2017/04/18 15:03:17
nit: Maybe move the response_type comparison into
igorcov
2017/04/20 14:52:29
Didn't notice that, thanks.
| |
156 ReportResult(DeviceSettingsService::STORE_INVALID_POLICY); | 159 ReportResult(DeviceSettingsService::STORE_INVALID_POLICY); |
157 return; | 160 return; |
158 } | 161 } |
159 | 162 |
160 base::SequencedWorkerPool* pool = | 163 base::SequencedWorkerPool* pool = |
161 content::BrowserThread::GetBlockingPool(); | 164 content::BrowserThread::GetBlockingPool(); |
162 scoped_refptr<base::SequencedTaskRunner> background_task_runner = | 165 scoped_refptr<base::SequencedTaskRunner> background_task_runner = |
163 pool->GetSequencedTaskRunnerWithShutdownBehavior( | 166 pool->GetSequencedTaskRunnerWithShutdownBehavior( |
164 pool->GetSequenceToken(), | 167 pool->GetSequenceToken(), |
165 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); | 168 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
273 } | 276 } |
274 | 277 |
275 void StoreSettingsOperation::HandleStoreResult(bool success) { | 278 void StoreSettingsOperation::HandleStoreResult(bool success) { |
276 if (!success) | 279 if (!success) |
277 ReportResult(DeviceSettingsService::STORE_OPERATION_FAILED); | 280 ReportResult(DeviceSettingsService::STORE_OPERATION_FAILED); |
278 else | 281 else |
279 StartLoading(); | 282 StartLoading(); |
280 } | 283 } |
281 | 284 |
282 } // namespace chromeos | 285 } // namespace chromeos |
OLD | NEW |