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

Unified Diff: chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.cc

Issue 782483002: DeviceCloudPolicyStore should load consumer policies so that other classes may function normally. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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/policy/device_cloud_policy_store_chromeos.cc
diff --git a/chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.cc b/chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.cc
index 248c8c5a418e5a3f28b738c3b628cc838bced5e4..6121589138fc5d1ea0f5986c28e8d2ffa4807bf0 100644
--- a/chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.cc
+++ b/chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.cc
@@ -13,6 +13,7 @@
#include "chrome/browser/chromeos/policy/enterprise_install_attributes.h"
#include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h"
#include "components/ownership/owner_key_util.h"
+#include "components/policy/core/common/cloud/cloud_policy_constants.h"
#include "policy/proto/device_management_backend.pb.h"
namespace em = enterprise_management;
@@ -136,6 +137,27 @@ void DeviceCloudPolicyStoreChromeOS::OnPolicyStored() {
}
void DeviceCloudPolicyStoreChromeOS::UpdateFromService() {
+ const em::PolicyData* policy_data = device_settings_service_->policy_data();
+ if (policy_data) {
+ const ManagementMode management_mode = GetManagementMode(*policy_data);
+ if (management_mode == MANAGEMENT_MODE_CONSUMER_MANAGED ||
+ (management_mode == MANAGEMENT_MODE_LOCAL_OWNER &&
+ policy() &&
+ GetManagementMode(*policy()) == MANAGEMENT_MODE_CONSUMER_MANAGED)) {
+ // For consumer-managed devices, or devices that were consumer-managed
+ // and are now unmanaged, we clear the policy data and set the status to
+ // success. The management mode is propagated so that the store knows if
+ // it is consumer-managed.
+ policy_.reset(new em::PolicyData());
Mattias Nissler (ping if slow) 2014/12/05 12:28:37 Why can't you just copy device_settings_service_->
+ policy_->set_management_mode(policy_data->management_mode());
+ PolicyMap new_policy_map;
+ policy_map_.Swap(&new_policy_map);
Mattias Nissler (ping if slow) 2014/12/05 12:28:37 Instead of swapping in an empty map, you could jus
+ status_ = STATUS_OK;
+ NotifyStoreLoaded();
+ return;
+ }
+ }
+
if (!install_attributes_->IsEnterpriseDevice()) {
status_ = STATUS_BAD_STATE;
NotifyStoreError();
@@ -157,8 +179,8 @@ void DeviceCloudPolicyStoreChromeOS::UpdateFromService() {
enrollment_validation_done_ = true;
const bool has_dm_token =
status == chromeos::DeviceSettingsService::STORE_SUCCESS &&
- device_settings_service_->policy_data() &&
- device_settings_service_->policy_data()->has_request_token();
+ policy_data &&
+ policy_data->has_request_token();
// At the time LoginDisplayHostImpl decides whether enrollment flow is
// to be started, policy hasn't been read yet. To work around this,
@@ -186,8 +208,8 @@ void DeviceCloudPolicyStoreChromeOS::UpdateFromService() {
case chromeos::DeviceSettingsService::STORE_SUCCESS: {
status_ = STATUS_OK;
policy_.reset(new em::PolicyData());
- if (device_settings_service_->policy_data())
- policy_->MergeFrom(*device_settings_service_->policy_data());
+ if (policy_data)
+ policy_->MergeFrom(*policy_data);
PolicyMap new_policy_map;
if (is_managed()) {

Powered by Google App Engine
This is Rietveld 408576698