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