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 #ifndef CHROME_BROWSER_POLICY_CLOUD_CLOUD_POLICY_STORE_H_ | 5 #ifndef CHROME_BROWSER_POLICY_CLOUD_CLOUD_POLICY_STORE_H_ |
6 #define CHROME_BROWSER_POLICY_CLOUD_CLOUD_POLICY_STORE_H_ | 6 #define CHROME_BROWSER_POLICY_CLOUD_CLOUD_POLICY_STORE_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/weak_ptr.h" |
10 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
11 #include "chrome/browser/policy/cloud/cloud_policy_validator.h" | 12 #include "chrome/browser/policy/cloud/cloud_policy_validator.h" |
12 #include "chrome/browser/policy/policy_map.h" | 13 #include "chrome/browser/policy/policy_map.h" |
13 #include "chrome/browser/policy/proto/cloud/device_management_backend.pb.h" | 14 #include "chrome/browser/policy/proto/cloud/device_management_backend.pb.h" |
14 | 15 |
15 namespace policy { | 16 namespace policy { |
16 | 17 |
| 18 class CloudExternalDataManager; |
| 19 |
17 // Defines the low-level interface used by the cloud policy code to: | 20 // Defines the low-level interface used by the cloud policy code to: |
18 // 1. Validate policy blobs that should be applied locally | 21 // 1. Validate policy blobs that should be applied locally |
19 // 2. Persist policy blobs | 22 // 2. Persist policy blobs |
20 // 3. Decode policy blobs to PolicyMap representation | 23 // 3. Decode policy blobs to PolicyMap representation |
21 class CloudPolicyStore { | 24 class CloudPolicyStore { |
22 public: | 25 public: |
23 // Status codes. | 26 // Status codes. |
24 enum Status { | 27 enum Status { |
25 // Everything is in good order. | 28 // Everything is in good order. |
26 STATUS_OK, | 29 STATUS_OK, |
(...skipping 23 matching lines...) Expand all Loading... |
50 virtual void OnStoreError(CloudPolicyStore* store) = 0; | 53 virtual void OnStoreError(CloudPolicyStore* store) = 0; |
51 }; | 54 }; |
52 | 55 |
53 CloudPolicyStore(); | 56 CloudPolicyStore(); |
54 virtual ~CloudPolicyStore(); | 57 virtual ~CloudPolicyStore(); |
55 | 58 |
56 // Indicates whether the store has been fully initialized. This is | 59 // Indicates whether the store has been fully initialized. This is |
57 // accomplished by calling Load() after startup. | 60 // accomplished by calling Load() after startup. |
58 bool is_initialized() const { return is_initialized_; } | 61 bool is_initialized() const { return is_initialized_; } |
59 | 62 |
| 63 base::WeakPtr<CloudExternalDataManager> external_data_manager() const { |
| 64 return external_data_manager_; |
| 65 } |
| 66 |
60 const PolicyMap& policy_map() const { return policy_map_; } | 67 const PolicyMap& policy_map() const { return policy_map_; } |
61 bool has_policy() const { | 68 bool has_policy() const { |
62 return policy_.get() != NULL; | 69 return policy_.get() != NULL; |
63 } | 70 } |
64 const enterprise_management::PolicyData* policy() const { | 71 const enterprise_management::PolicyData* policy() const { |
65 return policy_.get(); | 72 return policy_.get(); |
66 } | 73 } |
67 bool is_managed() const { | 74 bool is_managed() const { |
68 return policy_.get() && | 75 return policy_.get() && |
69 policy_->state() == enterprise_management::PolicyData::ACTIVE; | 76 policy_->state() == enterprise_management::PolicyData::ACTIVE; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 | 111 |
105 // Removes the specified observer. | 112 // Removes the specified observer. |
106 void RemoveObserver(Observer* observer); | 113 void RemoveObserver(Observer* observer); |
107 | 114 |
108 // The invalidation version of the last policy stored. This value can be read | 115 // The invalidation version of the last policy stored. This value can be read |
109 // by observers to determine which version of the policy is now available. | 116 // by observers to determine which version of the policy is now available. |
110 int64 invalidation_version() { | 117 int64 invalidation_version() { |
111 return invalidation_version_; | 118 return invalidation_version_; |
112 } | 119 } |
113 | 120 |
| 121 // Indicate that external data referenced by policies in this store is managed |
| 122 // by |external_data_manager|. The |external_data_manager| will be notified |
| 123 // about policy changes before any other observers. |
| 124 void SetExternalDataManager( |
| 125 base::WeakPtr<CloudExternalDataManager> external_data_manager); |
| 126 |
114 protected: | 127 protected: |
115 // Invokes the corresponding callback on all registered observers. | 128 // Invokes the corresponding callback on all registered observers. |
116 void NotifyStoreLoaded(); | 129 void NotifyStoreLoaded(); |
117 void NotifyStoreError(); | 130 void NotifyStoreError(); |
118 | 131 |
| 132 // Manages external data referenced by policies. |
| 133 base::WeakPtr<CloudExternalDataManager> external_data_manager_; |
| 134 |
119 // Decoded version of the currently effective policy. | 135 // Decoded version of the currently effective policy. |
120 PolicyMap policy_map_; | 136 PolicyMap policy_map_; |
121 | 137 |
122 // Currently effective policy. | 138 // Currently effective policy. |
123 scoped_ptr<enterprise_management::PolicyData> policy_; | 139 scoped_ptr<enterprise_management::PolicyData> policy_; |
124 | 140 |
125 // Latest status code. | 141 // Latest status code. |
126 Status status_; | 142 Status status_; |
127 | 143 |
128 // Latest validation status. | 144 // Latest validation status. |
(...skipping 15 matching lines...) Expand all Loading... |
144 uint32 hash_value_; | 160 uint32 hash_value_; |
145 | 161 |
146 ObserverList<Observer, true> observers_; | 162 ObserverList<Observer, true> observers_; |
147 | 163 |
148 DISALLOW_COPY_AND_ASSIGN(CloudPolicyStore); | 164 DISALLOW_COPY_AND_ASSIGN(CloudPolicyStore); |
149 }; | 165 }; |
150 | 166 |
151 } // namespace policy | 167 } // namespace policy |
152 | 168 |
153 #endif // CHROME_BROWSER_POLICY_CLOUD_CLOUD_POLICY_STORE_H_ | 169 #endif // CHROME_BROWSER_POLICY_CLOUD_CLOUD_POLICY_STORE_H_ |
OLD | NEW |