| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_POLICY_DEVICE_POLICY_CACHE_H_ | 5 #ifndef CHROME_BROWSER_POLICY_DEVICE_POLICY_CACHE_H_ |
| 6 #define CHROME_BROWSER_POLICY_DEVICE_POLICY_CACHE_H_ | 6 #define CHROME_BROWSER_POLICY_DEVICE_POLICY_CACHE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/memory/scoped_callback_factory.h" | 9 #include "base/memory/scoped_callback_factory.h" |
| 12 #include "chrome/browser/chromeos/login/signed_settings.h" | 10 #include "chrome/browser/chromeos/login/signed_settings.h" |
| 13 #include "chrome/browser/chromeos/login/signed_settings_helper.h" | 11 #include "chrome/browser/chromeos/login/signed_settings_helper.h" |
| 14 #include "chrome/browser/policy/cloud_policy_cache_base.h" | 12 #include "chrome/browser/policy/cloud_policy_cache_base.h" |
| 15 #include "chrome/browser/policy/proto/chrome_device_policy.pb.h" | 13 #include "chrome/browser/policy/proto/chrome_device_policy.pb.h" |
| 16 | 14 |
| 17 namespace policy { | 15 namespace policy { |
| 18 | 16 |
| 19 class DevicePolicyIdentityStrategy; | 17 class CloudPolicyDataStore; |
| 20 class EnterpriseInstallAttributes; | 18 class EnterpriseInstallAttributes; |
| 21 class PolicyMap; | 19 class PolicyMap; |
| 22 | 20 |
| 23 namespace em = enterprise_management; | 21 namespace em = enterprise_management; |
| 24 | 22 |
| 25 // CloudPolicyCacheBase implementation that persists policy information | 23 // CloudPolicyCacheBase implementation that persists policy information |
| 26 // to ChromeOS' session manager (via SignedSettingsHelper). | 24 // to ChromeOS' session manager (via SignedSettingsHelper). |
| 27 class DevicePolicyCache : public CloudPolicyCacheBase, | 25 class DevicePolicyCache : public CloudPolicyCacheBase, |
| 28 public chromeos::SignedSettingsHelper::Callback { | 26 public chromeos::SignedSettingsHelper::Callback { |
| 29 public: | 27 public: |
| 30 explicit DevicePolicyCache(DevicePolicyIdentityStrategy* identity_strategy, | 28 explicit DevicePolicyCache(CloudPolicyDataStore* data_store, |
| 31 EnterpriseInstallAttributes* install_attributes); | 29 EnterpriseInstallAttributes* install_attributes); |
| 32 virtual ~DevicePolicyCache(); | 30 virtual ~DevicePolicyCache(); |
| 33 | 31 |
| 34 // CloudPolicyCacheBase implementation: | 32 // CloudPolicyCacheBase implementation: |
| 35 virtual void Load() OVERRIDE; | 33 virtual void Load() OVERRIDE; |
| 36 virtual void SetPolicy(const em::PolicyFetchResponse& policy) OVERRIDE; | 34 virtual void SetPolicy(const em::PolicyFetchResponse& policy) OVERRIDE; |
| 37 virtual void SetUnmanaged() OVERRIDE; | 35 virtual void SetUnmanaged() OVERRIDE; |
| 38 virtual bool IsReady() OVERRIDE; | 36 virtual bool IsReady() OVERRIDE; |
| 39 | 37 |
| 40 // SignedSettingsHelper::Callback implementation: | 38 // SignedSettingsHelper::Callback implementation: |
| 41 virtual void OnRetrievePolicyCompleted( | 39 virtual void OnRetrievePolicyCompleted( |
| 42 chromeos::SignedSettings::ReturnCode code, | 40 chromeos::SignedSettings::ReturnCode code, |
| 43 const em::PolicyFetchResponse& policy) OVERRIDE; | 41 const em::PolicyFetchResponse& policy) OVERRIDE; |
| 44 | 42 |
| 45 private: | 43 private: |
| 46 friend class DevicePolicyCacheTest; | 44 friend class DevicePolicyCacheTest; |
| 47 | 45 |
| 48 // Alternate c'tor allowing tests to mock out the SignedSettingsHelper | 46 // Alternate c'tor allowing tests to mock out the SignedSettingsHelper |
| 49 // singleton. | 47 // singleton. |
| 50 DevicePolicyCache( | 48 DevicePolicyCache( |
| 51 DevicePolicyIdentityStrategy* identity_strategy, | 49 CloudPolicyDataStore* data_store, |
| 52 EnterpriseInstallAttributes* install_attributes, | 50 EnterpriseInstallAttributes* install_attributes, |
| 53 chromeos::SignedSettingsHelper* signed_settings_helper); | 51 chromeos::SignedSettingsHelper* signed_settings_helper); |
| 54 | 52 |
| 55 // CloudPolicyCacheBase implementation: | 53 // CloudPolicyCacheBase implementation: |
| 56 virtual bool DecodePolicyData(const em::PolicyData& policy_data, | 54 virtual bool DecodePolicyData(const em::PolicyData& policy_data, |
| 57 PolicyMap* mandatory, | 55 PolicyMap* mandatory, |
| 58 PolicyMap* recommended) OVERRIDE; | 56 PolicyMap* recommended) OVERRIDE; |
| 59 | 57 |
| 60 void PolicyStoreOpCompleted(chromeos::SignedSettings::ReturnCode code); | 58 void PolicyStoreOpCompleted(chromeos::SignedSettings::ReturnCode code); |
| 61 | 59 |
| 62 // Checks with immutable attributes whether this is an enterprise device and | 60 // Checks with immutable attributes whether this is an enterprise device and |
| 63 // read the registration user if this is the case. | 61 // read the registration user if this is the case. |
| 64 void CheckImmutableAttributes(); | 62 void CheckImmutableAttributes(); |
| 65 | 63 |
| 66 static void DecodeDevicePolicy(const em::ChromeDeviceSettingsProto& policy, | 64 static void DecodeDevicePolicy(const em::ChromeDeviceSettingsProto& policy, |
| 67 PolicyMap* mandatory, | 65 PolicyMap* mandatory, |
| 68 PolicyMap* recommended); | 66 PolicyMap* recommended); |
| 69 | 67 |
| 70 DevicePolicyIdentityStrategy* identity_strategy_; | 68 CloudPolicyDataStore* data_store_; |
| 71 EnterpriseInstallAttributes* install_attributes_; | 69 EnterpriseInstallAttributes* install_attributes_; |
| 72 | 70 |
| 73 chromeos::SignedSettingsHelper* signed_settings_helper_; | 71 chromeos::SignedSettingsHelper* signed_settings_helper_; |
| 74 | 72 |
| 75 bool starting_up_; | 73 bool starting_up_; |
| 76 | 74 |
| 77 base::ScopedCallbackFactory<DevicePolicyCache> callback_factory_; | 75 base::ScopedCallbackFactory<DevicePolicyCache> callback_factory_; |
| 78 | 76 |
| 79 DISALLOW_COPY_AND_ASSIGN(DevicePolicyCache); | 77 DISALLOW_COPY_AND_ASSIGN(DevicePolicyCache); |
| 80 }; | 78 }; |
| 81 | 79 |
| 82 } // namespace policy | 80 } // namespace policy |
| 83 | 81 |
| 84 #endif // CHROME_BROWSER_POLICY_DEVICE_POLICY_CACHE_H_ | 82 #endif // CHROME_BROWSER_POLICY_DEVICE_POLICY_CACHE_H_ |
| OLD | NEW |