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_USER_POLICY_CACHE_H_ | 5 #ifndef CHROME_BROWSER_POLICY_USER_POLICY_CACHE_H_ |
6 #define CHROME_BROWSER_POLICY_USER_POLICY_CACHE_H_ | 6 #define CHROME_BROWSER_POLICY_USER_POLICY_CACHE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "chrome/browser/policy/cloud_policy_cache_base.h" | 10 #include "chrome/browser/policy/cloud_policy_cache_base.h" |
11 | 11 |
| 12 // <Old-style policy support> (see comment below) |
| 13 namespace enterprise_management { |
| 14 class CloudPolicySettings; |
| 15 class GenericValue; |
| 16 } // namespace enterprise_management |
| 17 // </Old-style policy support> |
| 18 |
12 namespace policy { | 19 namespace policy { |
13 | 20 |
14 // CloudPolicyCacheBase implementation that persists policy information | 21 // CloudPolicyCacheBase implementation that persists policy information |
15 // into the file specified by the c'tor parameter |backing_file_path|. | 22 // into the file specified by the c'tor parameter |backing_file_path|. |
16 class UserPolicyCache : public CloudPolicyCacheBase { | 23 class UserPolicyCache : public CloudPolicyCacheBase { |
17 public: | 24 public: |
18 explicit UserPolicyCache(const FilePath& backing_file_path); | 25 explicit UserPolicyCache(const FilePath& backing_file_path); |
19 virtual ~UserPolicyCache(); | 26 virtual ~UserPolicyCache(); |
20 | 27 |
21 // CloudPolicyCacheBase implementation: | 28 // CloudPolicyCacheBase implementation: |
22 virtual void Load() OVERRIDE; | 29 virtual void Load() OVERRIDE; |
23 virtual void SetPolicy(const em::PolicyFetchResponse& policy) OVERRIDE; | 30 virtual void SetPolicy(const em::PolicyFetchResponse& policy) OVERRIDE; |
24 virtual void SetUnmanaged() OVERRIDE; | 31 virtual void SetUnmanaged() OVERRIDE; |
25 | 32 |
26 private: | 33 private: |
27 void PersistPolicy(const em::PolicyFetchResponse& policy, | 34 void PersistPolicy(const em::PolicyFetchResponse& policy, |
28 const base::Time& timestamp); | 35 const base::Time& timestamp); |
29 | 36 |
30 // CloudPolicyCacheBase implementation: | 37 // CloudPolicyCacheBase implementation: |
31 virtual bool DecodePolicyData(const em::PolicyData& policy_data, | 38 virtual bool DecodePolicyData(const em::PolicyData& policy_data, |
32 PolicyMap* mandatory, | 39 PolicyMap* mandatory, |
33 PolicyMap* recommended) OVERRIDE; | 40 PolicyMap* recommended) OVERRIDE; |
34 | 41 |
| 42 // <Old-style policy support> |
| 43 // The following methods are needed to support old-style policy and can |
| 44 // be removed once all server-side components (CPanel, D3) have been migrated |
| 45 // to providing the new policy format. |
| 46 |
| 47 // If |mandatory| and |recommended| are both empty, and |policy_data| |
| 48 // contains a field named "repeated GenericNamedValue named_value = 2;", |
| 49 // this field is decoded into |mandatory|. |
| 50 void MaybeDecodeOldstylePolicy(const em::CloudPolicySettings& policy, |
| 51 PolicyMap* mandatory, |
| 52 PolicyMap* recommended); |
| 53 |
| 54 Value* DecodeIntegerValue(google::protobuf::int64 value) const; |
| 55 Value* DecodeValue(const em::GenericValue& value) const; |
| 56 |
| 57 // </Old-style policy support> |
| 58 |
35 // The file in which we store a cached version of the policy information. | 59 // The file in which we store a cached version of the policy information. |
36 const FilePath backing_file_path_; | 60 const FilePath backing_file_path_; |
37 | 61 |
38 DISALLOW_COPY_AND_ASSIGN(UserPolicyCache); | 62 DISALLOW_COPY_AND_ASSIGN(UserPolicyCache); |
39 }; | 63 }; |
40 | 64 |
41 } // namespace policy | 65 } // namespace policy |
42 | 66 |
43 #endif // CHROME_BROWSER_POLICY_USER_POLICY_CACHE_H_ | 67 #endif // CHROME_BROWSER_POLICY_USER_POLICY_CACHE_H_ |
OLD | NEW |