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_CLOUD_POLICY_CACHE_H_ | 5 #ifndef CHROME_BROWSER_POLICY_CLOUD_POLICY_CACHE_H_ |
6 #define CHROME_BROWSER_POLICY_CLOUD_POLICY_CACHE_H_ | 6 #define CHROME_BROWSER_POLICY_CLOUD_POLICY_CACHE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 explicit CloudPolicyCache(const FilePath& backing_file_path); | 47 explicit CloudPolicyCache(const FilePath& backing_file_path); |
48 ~CloudPolicyCache(); | 48 ~CloudPolicyCache(); |
49 | 49 |
50 // Loads policy information from the backing file. Non-existing or erroneous | 50 // Loads policy information from the backing file. Non-existing or erroneous |
51 // cache files are ignored. | 51 // cache files are ignored. |
52 void LoadFromFile(); | 52 void LoadFromFile(); |
53 | 53 |
54 // Resets the policy information. Returns true if the new policy is different | 54 // Resets the policy information. Returns true if the new policy is different |
55 // from the previously stored policy. | 55 // from the previously stored policy. |
56 // Marked virtual so it can be overridden by mocks. | 56 // Marked virtual so it can be overridden by mocks. |
57 virtual bool SetPolicy(const em::CloudPolicyResponse& policy); | 57 virtual bool SetPolicy(const em::PolicyFetchResponse& policy); |
58 virtual bool SetDevicePolicy(const em::DevicePolicyResponse& policy); | 58 virtual bool SetDevicePolicy(const em::DevicePolicyResponse& policy); |
59 | 59 |
60 ConfigurationPolicyProvider* GetManagedPolicyProvider(); | 60 ConfigurationPolicyProvider* GetManagedPolicyProvider(); |
61 ConfigurationPolicyProvider* GetRecommendedPolicyProvider(); | 61 ConfigurationPolicyProvider* GetRecommendedPolicyProvider(); |
62 | 62 |
63 void SetUnmanaged(); | 63 void SetUnmanaged(); |
64 bool is_unmanaged() const { | 64 bool is_unmanaged() const { |
65 return is_unmanaged_; | 65 return is_unmanaged_; |
66 } | 66 } |
67 | 67 |
(...skipping 12 matching lines...) Expand all Loading... |
80 class CloudPolicyProvider; | 80 class CloudPolicyProvider; |
81 | 81 |
82 friend class CloudPolicyCacheTest; | 82 friend class CloudPolicyCacheTest; |
83 friend class DeviceManagementPolicyCacheTest; | 83 friend class DeviceManagementPolicyCacheTest; |
84 friend class DeviceManagementPolicyCacheDecodeTest; | 84 friend class DeviceManagementPolicyCacheDecodeTest; |
85 | 85 |
86 // Decodes a CloudPolicyResponse into two (ConfigurationPolicyType -> Value*) | 86 // Decodes a CloudPolicyResponse into two (ConfigurationPolicyType -> Value*) |
87 // maps and a timestamp. Also performs verification, returns NULL if any | 87 // maps and a timestamp. Also performs verification, returns NULL if any |
88 // check fails. | 88 // check fails. |
89 static bool DecodePolicyResponse( | 89 static bool DecodePolicyResponse( |
90 const em::CloudPolicyResponse& policy_response, | 90 const em::PolicyFetchResponse& policy_response, |
91 PolicyMap* mandatory, | 91 PolicyMap* mandatory, |
92 PolicyMap* recommended, | 92 PolicyMap* recommended, |
93 base::Time* timestamp); | 93 base::Time* timestamp); |
94 | 94 |
95 // Returns true if |certificate_chain| is trusted and a |signature| created | 95 // Returns true if |certificate_chain| is trusted and a |signature| created |
96 // from it matches |data|. | 96 // from it matches |data|. |
97 static bool VerifySignature( | 97 static bool VerifySignature( |
98 const std::string& signature, | 98 const std::string& signature, |
99 const std::string& data, | 99 const std::string& data, |
100 const RepeatedPtrField<std::string>& certificate_chain); | 100 const RepeatedPtrField<std::string>& certificate_chain); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 scoped_ptr<ConfigurationPolicyProvider> managed_policy_provider_; | 140 scoped_ptr<ConfigurationPolicyProvider> managed_policy_provider_; |
141 scoped_ptr<ConfigurationPolicyProvider> recommended_policy_provider_; | 141 scoped_ptr<ConfigurationPolicyProvider> recommended_policy_provider_; |
142 | 142 |
143 // Provider observers that are registered with this cache's providers. | 143 // Provider observers that are registered with this cache's providers. |
144 ObserverList<ConfigurationPolicyProvider::Observer, true> observer_list_; | 144 ObserverList<ConfigurationPolicyProvider::Observer, true> observer_list_; |
145 }; | 145 }; |
146 | 146 |
147 } // namespace policy | 147 } // namespace policy |
148 | 148 |
149 #endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_CACHE_H_ | 149 #endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_CACHE_H_ |
OLD | NEW |