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

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

Issue 2801993002: Abandon user sign in when policy is retrieved before session started (Closed)
Patch Set: Fixed review comments Created 3 years, 7 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 <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"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
14 #include "base/stl_util.h" 14 #include "base/stl_util.h"
15 #include "base/task_runner_util.h" 15 #include "base/task_runner_util.h"
16 #include "base/task_scheduler/post_task.h" 16 #include "base/task_scheduler/post_task.h"
17 #include "base/threading/sequenced_worker_pool.h" 17 #include "base/threading/sequenced_worker_pool.h"
18 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" 18 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h"
19 #include "chrome/browser/net/nss_context.h" 19 #include "chrome/browser/net/nss_context.h"
20 #include "components/ownership/owner_key_util.h" 20 #include "components/ownership/owner_key_util.h"
21 #include "components/policy/core/common/cloud/cloud_policy_constants.h" 21 #include "components/policy/core/common/cloud/cloud_policy_constants.h"
22 #include "components/policy/proto/device_management_backend.pb.h" 22 #include "components/policy/proto/device_management_backend.pb.h"
23 #include "content/public/browser/browser_thread.h" 23 #include "content/public/browser/browser_thread.h"
24 #include "crypto/rsa_private_key.h" 24 #include "crypto/rsa_private_key.h"
25 #include "crypto/signature_creator.h" 25 #include "crypto/signature_creator.h"
26 26
27 using RetrievePolicyResponseType =
28 chromeos::SessionManagerClient::RetrievePolicyResponseType;
27 using ownership::OwnerKeyUtil; 29 using ownership::OwnerKeyUtil;
28 using ownership::PublicKey; 30 using ownership::PublicKey;
29 31
30 namespace em = enterprise_management; 32 namespace em = enterprise_management;
31 33
32 namespace chromeos { 34 namespace chromeos {
33 35
34 SessionManagerOperation::SessionManagerOperation(const Callback& callback) 36 SessionManagerOperation::SessionManagerOperation(const Callback& callback)
35 : callback_(callback), weak_factory_(this) {} 37 : callback_(callback), weak_factory_(this) {}
36 38
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 callback.Run(); 137 callback.Run();
136 } 138 }
137 139
138 void SessionManagerOperation::RetrieveDeviceSettings() { 140 void SessionManagerOperation::RetrieveDeviceSettings() {
139 session_manager_client()->RetrieveDevicePolicy( 141 session_manager_client()->RetrieveDevicePolicy(
140 base::Bind(&SessionManagerOperation::ValidateDeviceSettings, 142 base::Bind(&SessionManagerOperation::ValidateDeviceSettings,
141 weak_factory_.GetWeakPtr())); 143 weak_factory_.GetWeakPtr()));
142 } 144 }
143 145
144 void SessionManagerOperation::BlockingRetrieveDeviceSettings() { 146 void SessionManagerOperation::BlockingRetrieveDeviceSettings() {
145 ValidateDeviceSettings( 147 std::string policy_blob;
146 session_manager_client()->BlockingRetrieveDevicePolicy()); 148 RetrievePolicyResponseType response =
149 session_manager_client()->BlockingRetrieveDevicePolicy(&policy_blob);
150 ValidateDeviceSettings(policy_blob, response);
147 } 151 }
148 152
149 void SessionManagerOperation::ValidateDeviceSettings( 153 void SessionManagerOperation::ValidateDeviceSettings(
150 const std::string& policy_blob) { 154 const std::string& policy_blob,
155 RetrievePolicyResponseType response_type) {
151 std::unique_ptr<em::PolicyFetchResponse> policy( 156 std::unique_ptr<em::PolicyFetchResponse> policy(
152 new em::PolicyFetchResponse()); 157 new em::PolicyFetchResponse());
153 if (policy_blob.empty()) { 158 if (policy_blob.empty()) {
154 ReportResult(DeviceSettingsService::STORE_NO_POLICY); 159 ReportResult(DeviceSettingsService::STORE_NO_POLICY);
155 return; 160 return;
156 } 161 }
157 162
158 if (!policy->ParseFromString(policy_blob) || 163 if (!policy->ParseFromString(policy_blob) || !policy->IsInitialized()) {
159 !policy->IsInitialized()) {
160 ReportResult(DeviceSettingsService::STORE_INVALID_POLICY); 164 ReportResult(DeviceSettingsService::STORE_INVALID_POLICY);
161 return; 165 return;
162 } 166 }
163 167
164 base::SequencedWorkerPool* pool = 168 base::SequencedWorkerPool* pool =
165 content::BrowserThread::GetBlockingPool(); 169 content::BrowserThread::GetBlockingPool();
166 scoped_refptr<base::SequencedTaskRunner> background_task_runner = 170 scoped_refptr<base::SequencedTaskRunner> background_task_runner =
167 pool->GetSequencedTaskRunnerWithShutdownBehavior( 171 pool->GetSequencedTaskRunnerWithShutdownBehavior(
168 pool->GetSequenceToken(), 172 pool->GetSequenceToken(),
169 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); 173 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN);
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 } 270 }
267 271
268 void StoreSettingsOperation::HandleStoreResult(bool success) { 272 void StoreSettingsOperation::HandleStoreResult(bool success) {
269 if (!success) 273 if (!success)
270 ReportResult(DeviceSettingsService::STORE_OPERATION_FAILED); 274 ReportResult(DeviceSettingsService::STORE_OPERATION_FAILED);
271 else 275 else
272 StartLoading(); 276 StartLoading();
273 } 277 }
274 278
275 } // namespace chromeos 279 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/settings/session_manager_operation.h ('k') | chromeos/dbus/blocking_method_caller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698