Chromium Code Reviews| 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_POLICY_STORE_H_ | 5 #ifndef CHROME_BROWSER_POLICY_CLOUD_POLICY_STORE_H_ |
| 6 #define CHROME_BROWSER_POLICY_CLOUD_POLICY_STORE_H_ | 6 #define CHROME_BROWSER_POLICY_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/observer_list.h" | 10 #include "base/observer_list.h" |
| 11 #include "chrome/browser/policy/cloud_policy_validator.h" | 11 #include "chrome/browser/policy/cloud_policy_validator.h" |
| 12 #include "chrome/browser/policy/policy_map.h" | 12 #include "chrome/browser/policy/policy_map.h" |
| 13 #include "chrome/browser/policy/proto/device_management_backend.pb.h" | 13 #include "chrome/browser/policy/proto/device_management_backend.pb.h" |
| 14 | 14 |
| 15 class Profile; | 15 class Profile; |
|
Joao da Silva
2012/11/21 17:06:34
nit: not needed
Mattias Nissler (ping if slow)
2012/11/22 20:51:59
Done.
| |
| 16 | 16 |
| 17 namespace policy { | 17 namespace policy { |
| 18 | 18 |
| 19 // Defines the low-level interface used by the cloud policy code to: | 19 // Defines the low-level interface used by the cloud policy code to: |
| 20 // 1. Validate policy blobs that should be applied locally | 20 // 1. Validate policy blobs that should be applied locally |
| 21 // 2. Persist policy blobs | 21 // 2. Persist policy blobs |
| 22 // 3. Decode policy blobs to PolicyMap representation | 22 // 3. Decode policy blobs to PolicyMap representation |
| 23 class CloudPolicyStore { | 23 class CloudPolicyStore { |
| 24 public: | 24 public: |
| 25 // Status codes. | 25 // Status codes. |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 82 // Errors generate OnStoreError() notifications. | 82 // Errors generate OnStoreError() notifications. |
| 83 virtual void Store( | 83 virtual void Store( |
| 84 const enterprise_management::PolicyFetchResponse& policy) = 0; | 84 const enterprise_management::PolicyFetchResponse& policy) = 0; |
| 85 | 85 |
| 86 // Load the current policy blob from persistent storage. Pending load/store | 86 // Load the current policy blob from persistent storage. Pending load/store |
| 87 // operations will be canceled. This may trigger asynchronous operations. | 87 // operations will be canceled. This may trigger asynchronous operations. |
| 88 // Upon success, OnStoreLoaded() will be called on the registered observers. | 88 // Upon success, OnStoreLoaded() will be called on the registered observers. |
| 89 // Otherwise, OnStoreError() reports the reason for failure. | 89 // Otherwise, OnStoreError() reports the reason for failure. |
| 90 virtual void Load() = 0; | 90 virtual void Load() = 0; |
| 91 | 91 |
| 92 // Deletes any existing policy blob and notifies observers via OnStoreLoaded() | |
| 93 // that the blob has changed. Virtual for mocks. | |
| 94 virtual void Clear(); | |
| 95 | |
| 96 // Registers an observer to be notified when policy changes. | 92 // Registers an observer to be notified when policy changes. |
| 97 void AddObserver(Observer* observer); | 93 void AddObserver(Observer* observer); |
| 98 | 94 |
| 99 // Removes the specified observer. | 95 // Removes the specified observer. |
| 100 void RemoveObserver(Observer* observer); | 96 void RemoveObserver(Observer* observer); |
| 101 | 97 |
| 102 // Factory method to create a CloudPolicyStore appropriate for the current | |
| 103 // platform, for storing user policy for the user associated with the passed | |
| 104 // |profile|. Implementation is defined in the individual platform store | |
| 105 // files. | |
| 106 static scoped_ptr<CloudPolicyStore> CreateUserPolicyStore( | |
| 107 Profile* profile, | |
| 108 bool force_immediate_policy_load); | |
| 109 | |
| 110 protected: | 98 protected: |
| 111 // Invokes the corresponding callback on all registered observers. | 99 // Invokes the corresponding callback on all registered observers. |
| 112 void NotifyStoreLoaded(); | 100 void NotifyStoreLoaded(); |
| 113 void NotifyStoreError(); | 101 void NotifyStoreError(); |
| 114 | 102 |
| 115 // Invoked by Clear() to remove stored policy. | |
| 116 virtual void RemoveStoredPolicy() = 0; | |
| 117 | |
| 118 // Decoded version of the currently effective policy. | 103 // Decoded version of the currently effective policy. |
| 119 PolicyMap policy_map_; | 104 PolicyMap policy_map_; |
| 120 | 105 |
| 121 // Currently effective policy. | 106 // Currently effective policy. |
| 122 scoped_ptr<enterprise_management::PolicyData> policy_; | 107 scoped_ptr<enterprise_management::PolicyData> policy_; |
| 123 | 108 |
| 124 // Latest status code. | 109 // Latest status code. |
| 125 Status status_; | 110 Status status_; |
| 126 | 111 |
| 127 // Latest validation status. | 112 // Latest validation status. |
| 128 CloudPolicyValidatorBase::Status validation_status_; | 113 CloudPolicyValidatorBase::Status validation_status_; |
| 129 | 114 |
| 130 private: | 115 private: |
| 131 // Whether the store has completed asynchronous initialization, which is | 116 // Whether the store has completed asynchronous initialization, which is |
| 132 // triggered by calling Load(). | 117 // triggered by calling Load(). |
| 133 bool is_initialized_; | 118 bool is_initialized_; |
| 134 | 119 |
| 135 ObserverList<Observer, true> observers_; | 120 ObserverList<Observer, true> observers_; |
| 136 | 121 |
| 137 DISALLOW_COPY_AND_ASSIGN(CloudPolicyStore); | 122 DISALLOW_COPY_AND_ASSIGN(CloudPolicyStore); |
| 138 }; | 123 }; |
| 139 | 124 |
| 140 } // namespace policy | 125 } // namespace policy |
| 141 | 126 |
| 142 #endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_STORE_H_ | 127 #endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_STORE_H_ |
| OLD | NEW |