| 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/policy/device_cloud_policy_store_chromeos.h" | 5 #include "chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/sequenced_task_runner.h" | 10 #include "base/sequenced_task_runner.h" |
| 11 #include "chrome/browser/chromeos/login/startup_utils.h" | 11 #include "chrome/browser/chromeos/login/startup_utils.h" |
| 12 #include "chrome/browser/chromeos/policy/device_policy_decoder_chromeos.h" | 12 #include "chrome/browser/chromeos/policy/device_policy_decoder_chromeos.h" |
| 13 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h" | 13 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h" |
| 14 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" | 14 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" |
| 15 #include "chrome/browser/chromeos/settings/owner_key_util.h" | 15 #include "components/ownership/owner_key_util.h" |
| 16 #include "policy/proto/device_management_backend.pb.h" | 16 #include "policy/proto/device_management_backend.pb.h" |
| 17 | 17 |
| 18 namespace em = enterprise_management; | 18 namespace em = enterprise_management; |
| 19 | 19 |
| 20 namespace policy { | 20 namespace policy { |
| 21 | 21 |
| 22 DeviceCloudPolicyStoreChromeOS::DeviceCloudPolicyStoreChromeOS( | 22 DeviceCloudPolicyStoreChromeOS::DeviceCloudPolicyStoreChromeOS( |
| 23 chromeos::DeviceSettingsService* device_settings_service, | 23 chromeos::DeviceSettingsService* device_settings_service, |
| 24 EnterpriseInstallAttributes* install_attributes, | 24 EnterpriseInstallAttributes* install_attributes, |
| 25 scoped_refptr<base::SequencedTaskRunner> background_task_runner) | 25 scoped_refptr<base::SequencedTaskRunner> background_task_runner) |
| 26 : device_settings_service_(device_settings_service), | 26 : device_settings_service_(device_settings_service), |
| 27 install_attributes_(install_attributes), | 27 install_attributes_(install_attributes), |
| 28 background_task_runner_(background_task_runner), | 28 background_task_runner_(background_task_runner), |
| 29 enrollment_validation_done_(false), | 29 enrollment_validation_done_(false), |
| 30 weak_factory_(this) { | 30 weak_factory_(this) { |
| 31 device_settings_service_->AddObserver(this); | 31 device_settings_service_->AddObserver(this); |
| 32 } | 32 } |
| 33 | 33 |
| 34 DeviceCloudPolicyStoreChromeOS::~DeviceCloudPolicyStoreChromeOS() { | 34 DeviceCloudPolicyStoreChromeOS::~DeviceCloudPolicyStoreChromeOS() { |
| 35 device_settings_service_->RemoveObserver(this); | 35 device_settings_service_->RemoveObserver(this); |
| 36 } | 36 } |
| 37 | 37 |
| 38 void DeviceCloudPolicyStoreChromeOS::Store( | 38 void DeviceCloudPolicyStoreChromeOS::Store( |
| 39 const em::PolicyFetchResponse& policy) { | 39 const em::PolicyFetchResponse& policy) { |
| 40 // Cancel all pending requests. | 40 // Cancel all pending requests. |
| 41 weak_factory_.InvalidateWeakPtrs(); | 41 weak_factory_.InvalidateWeakPtrs(); |
| 42 | 42 |
| 43 scoped_refptr<chromeos::PublicKey> public_key( | 43 scoped_refptr<ownership::PublicKey> public_key( |
| 44 device_settings_service_->GetPublicKey()); | 44 device_settings_service_->GetPublicKey()); |
| 45 if (!install_attributes_->IsEnterpriseDevice() || | 45 if (!install_attributes_->IsEnterpriseDevice() || |
| 46 !device_settings_service_->policy_data() || !public_key.get() || | 46 !device_settings_service_->policy_data() || !public_key.get() || |
| 47 !public_key->is_loaded()) { | 47 !public_key->is_loaded()) { |
| 48 status_ = STATUS_BAD_STATE; | 48 status_ = STATUS_BAD_STATE; |
| 49 NotifyStoreError(); | 49 NotifyStoreError(); |
| 50 return; | 50 return; |
| 51 } | 51 } |
| 52 | 52 |
| 53 scoped_ptr<DeviceCloudPolicyValidator> validator(CreateValidator(policy)); | 53 scoped_ptr<DeviceCloudPolicyValidator> validator(CreateValidator(policy)); |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 case chromeos::DeviceSettingsService::STORE_VALIDATION_ERROR: | 207 case chromeos::DeviceSettingsService::STORE_VALIDATION_ERROR: |
| 208 case chromeos::DeviceSettingsService::STORE_TEMP_VALIDATION_ERROR: | 208 case chromeos::DeviceSettingsService::STORE_TEMP_VALIDATION_ERROR: |
| 209 status_ = STATUS_LOAD_ERROR; | 209 status_ = STATUS_LOAD_ERROR; |
| 210 break; | 210 break; |
| 211 } | 211 } |
| 212 | 212 |
| 213 NotifyStoreError(); | 213 NotifyStoreError(); |
| 214 } | 214 } |
| 215 | 215 |
| 216 } // namespace policy | 216 } // namespace policy |
| OLD | NEW |