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

Side by Side Diff: chrome/browser/chromeos/policy/device_local_account_policy_store.cc

Issue 2801993002: Abandon user sign in when policy is retrieved before session started (Closed)
Patch Set: Nit Created 3 years, 8 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/policy/device_local_account_policy_store.h" 5 #include "chrome/browser/chromeos/policy/device_local_account_policy_store.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 // However, on those paths we must load policy synchronously so that the 52 // However, on those paths we must load policy synchronously so that the
53 // Profile initialization never sees unmanaged prefs, which would lead to 53 // Profile initialization never sees unmanaged prefs, which would lead to
54 // data loss. http://crbug.com/263061 54 // data loss. http://crbug.com/263061
55 55
56 // Cancel all running async loads. 56 // Cancel all running async loads.
57 weak_factory_.InvalidateWeakPtrs(); 57 weak_factory_.InvalidateWeakPtrs();
58 58
59 const std::string policy_blob = 59 const std::string policy_blob =
60 session_manager_client_->BlockingRetrieveDeviceLocalAccountPolicy( 60 session_manager_client_->BlockingRetrieveDeviceLocalAccountPolicy(
61 account_id_); 61 account_id_);
62 ValidateLoadedPolicyBlob(false /*validate_in_background*/, policy_blob); 62 ValidateLoadedPolicyBlob(false /*validate_in_background*/, policy_blob,
63 chromeos::SessionManagerClient::SUCCESS);
emaxx 2017/04/18 15:03:16 It's a bit weird that the asynchronous method (Ret
igorcov 2017/04/20 14:52:29 Changed to have the same pattern for all.
63 } 64 }
64 65
65 void DeviceLocalAccountPolicyStore::Store( 66 void DeviceLocalAccountPolicyStore::Store(
66 const em::PolicyFetchResponse& policy) { 67 const em::PolicyFetchResponse& policy) {
67 weak_factory_.InvalidateWeakPtrs(); 68 weak_factory_.InvalidateWeakPtrs();
68 CheckKeyAndValidate( 69 CheckKeyAndValidate(
69 true, base::MakeUnique<em::PolicyFetchResponse>(policy), 70 true, base::MakeUnique<em::PolicyFetchResponse>(policy),
70 true /*validate_in_background*/, 71 true /*validate_in_background*/,
71 base::Bind(&DeviceLocalAccountPolicyStore::StoreValidatedPolicy, 72 base::Bind(&DeviceLocalAccountPolicyStore::StoreValidatedPolicy,
72 weak_factory_.GetWeakPtr())); 73 weak_factory_.GetWeakPtr()));
73 } 74 }
74 75
75 void DeviceLocalAccountPolicyStore::ValidateLoadedPolicyBlob( 76 void DeviceLocalAccountPolicyStore::ValidateLoadedPolicyBlob(
76 bool validate_in_background, 77 bool validate_in_background,
77 const std::string& policy_blob) { 78 const std::string& policy_blob,
79 const chromeos::SessionManagerClient::RetrievePolicyResponseType&
80 response_type) {
78 if (policy_blob.empty()) { 81 if (policy_blob.empty()) {
79 status_ = CloudPolicyStore::STATUS_LOAD_ERROR; 82 status_ = CloudPolicyStore::STATUS_LOAD_ERROR;
80 NotifyStoreError(); 83 NotifyStoreError();
81 } else { 84 } else {
82 std::unique_ptr<em::PolicyFetchResponse> policy( 85 std::unique_ptr<em::PolicyFetchResponse> policy(
83 new em::PolicyFetchResponse()); 86 new em::PolicyFetchResponse());
84 if (policy->ParseFromString(policy_blob)) { 87 if (policy->ParseFromString(policy_blob)) {
85 CheckKeyAndValidate( 88 CheckKeyAndValidate(
86 false, std::move(policy), validate_in_background, 89 false, std::move(policy), validate_in_background,
87 base::Bind(&DeviceLocalAccountPolicyStore::UpdatePolicy, 90 base::Bind(&DeviceLocalAccountPolicyStore::UpdatePolicy,
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 validator.release()->StartValidation( 220 validator.release()->StartValidation(
218 base::Bind(callback, key->as_string())); 221 base::Bind(callback, key->as_string()));
219 } else { 222 } else {
220 validator->RunValidation(); 223 validator->RunValidation();
221 224
222 UpdatePolicy(key->as_string(), validator.get()); 225 UpdatePolicy(key->as_string(), validator.get());
223 } 226 }
224 } 227 }
225 228
226 } // namespace policy 229 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698