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

Unified Diff: chrome/browser/chromeos/settings/session_manager_operation.cc

Issue 2714493002: Load DeviceLocalAccount policy and DeviceSettings immediately on restore after Chrome crash. (Closed)
Patch Set: add flag to correctly process LoadImmediately() call Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/settings/session_manager_operation.cc
diff --git a/chrome/browser/chromeos/settings/session_manager_operation.cc b/chrome/browser/chromeos/settings/session_manager_operation.cc
index bfe8316c87e30cb90f995b6934152ddfec25c6e7..bbef032ee6da503a409bfeaeb405469f0dc5ec57 100644
--- a/chrome/browser/chromeos/settings/session_manager_operation.cc
+++ b/chrome/browser/chromeos/settings/session_manager_operation.cc
@@ -70,6 +70,28 @@ void SessionManagerOperation::StartLoading() {
}
}
+void SessionManagerOperation::LoadImmediately() {
+ scoped_refptr<PublicKey> public_key(new PublicKey());
+
+ // Keep already-existing public key.
+ if (public_key_.get() && public_key_->is_loaded()) {
emaxx 2017/02/22 17:24:33 I believe you have to honor the force_key_load_ fl
Sergey Poromov 2017/02/28 14:01:17 Done.
+ public_key->data() = public_key_->data();
+ }
+ if (!public_key->is_loaded() && owner_key_util_->IsPublicKeyPresent()) {
+ if (!owner_key_util_->ImportPublicKey(&public_key->data()))
+ LOG(ERROR) << "Failed to load public owner key.";
+ }
+
+ public_key_ = public_key;
+
+ if (!public_key_.get() || !public_key_->is_loaded()) {
+ ReportResult(DeviceSettingsService::STORE_KEY_UNAVAILABLE);
+ return;
+ }
+
+ BlockingRetrieveDeviceSettings();
+}
+
void SessionManagerOperation::ReportResult(
DeviceSettingsService::Status status) {
callback_.Run(this, status);
@@ -132,6 +154,11 @@ void SessionManagerOperation::RetrieveDeviceSettings() {
weak_factory_.GetWeakPtr()));
}
+void SessionManagerOperation::BlockingRetrieveDeviceSettings() {
+ ValidateDeviceSettings(
+ session_manager_client()->BlockingRetrieveDevicePolicy());
+}
+
void SessionManagerOperation::ValidateDeviceSettings(
const std::string& policy_blob) {
std::unique_ptr<em::PolicyFetchResponse> policy(
@@ -191,9 +218,14 @@ void SessionManagerOperation::ValidateDeviceSettings(
validator->ValidatePolicyType(policy::dm_protocol::kChromeDevicePolicyType);
validator->ValidatePayload();
- validator->StartValidation(
- base::Bind(&SessionManagerOperation::ReportValidatorStatus,
- weak_factory_.GetWeakPtr()));
+ if (force_immediate_load_) {
+ validator->RunValidation();
+ ReportValidatorStatus(validator);
+ } else {
+ validator->StartValidation(
+ base::Bind(&SessionManagerOperation::ReportValidatorStatus,
+ weak_factory_.GetWeakPtr()));
+ }
}
void SessionManagerOperation::ReportValidatorStatus(
@@ -219,16 +251,21 @@ void SessionManagerOperation::ReportValidatorStatus(
LoadSettingsOperation::LoadSettingsOperation(bool force_key_load,
bool cloud_validations,
+ bool force_immediate_load,
const Callback& callback)
: SessionManagerOperation(callback) {
force_key_load_ = force_key_load;
cloud_validations_ = cloud_validations;
+ force_immediate_load_ = force_immediate_load;
}
LoadSettingsOperation::~LoadSettingsOperation() {}
void LoadSettingsOperation::Run() {
- StartLoading();
+ if (force_immediate_load_)
+ LoadImmediately();
+ else
+ StartLoading();
}
StoreSettingsOperation::StoreSettingsOperation(

Powered by Google App Engine
This is Rietveld 408576698