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_USER_CLOUD_POLICY_STORE_H_ | 5 #ifndef CHROME_BROWSER_POLICY_USER_CLOUD_POLICY_STORE_H_ |
| 6 #define CHROME_BROWSER_POLICY_USER_CLOUD_POLICY_STORE_H_ | 6 #define CHROME_BROWSER_POLICY_USER_CLOUD_POLICY_STORE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/memory/ref_counted.h" | |
| 12 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 13 #include "chrome/browser/policy/user_cloud_policy_store_base.h" | 14 #include "chrome/browser/policy/user_cloud_policy_store_base.h" |
| 15 #include "chrome/browser/policy/user_policy_disk_cache.h" | |
|
Mattias Nissler (ping if slow)
2012/08/20 15:29:30
This is a part of the chrome OS user policy legacy
Andrew T Wilson (Slow)
2012/08/20 18:04:37
OK, I'll roll my own version that doesn't use the
| |
| 14 | 16 |
| 15 namespace policy { | 17 namespace policy { |
| 16 | 18 |
| 17 // Implements a cloud policy store that is stored in a simple file in the user's | 19 // Implements a cloud policy store that is stored in a simple file in the user's |
| 18 // profile directory. This is used on (non-chromeos) platforms that do not have | 20 // profile directory. This is used on (non-chromeos) platforms that do not have |
| 19 // a secure storage implementation. | 21 // a secure storage implementation. |
| 20 class UserCloudPolicyStore : public UserCloudPolicyStoreBase { | 22 class UserCloudPolicyStore : public UserCloudPolicyStoreBase, |
| 23 public UserPolicyDiskCache::Delegate { | |
| 21 public: | 24 public: |
| 22 // Creates a policy store associated with the user signed in to this | 25 // Creates a policy store associated with the user signed in to this |
| 23 // |profile|. | 26 // |profile|. |
| 24 explicit UserCloudPolicyStore(Profile* profile); | 27 explicit UserCloudPolicyStore(Profile* profile, |
| 28 const FilePath& policy_file); | |
| 25 virtual ~UserCloudPolicyStore(); | 29 virtual ~UserCloudPolicyStore(); |
| 26 | 30 |
| 27 // CloudPolicyStore implementation. | 31 // CloudPolicyStore implementation. |
| 28 virtual void Load() OVERRIDE; | 32 virtual void Load() OVERRIDE; |
| 29 virtual void Store( | 33 virtual void Store( |
| 30 const enterprise_management::PolicyFetchResponse& policy) OVERRIDE; | 34 const enterprise_management::PolicyFetchResponse& policy) OVERRIDE; |
| 31 | 35 |
| 36 // UserPolicyDiskCache::Delegate implementation. | |
| 37 virtual void OnDiskCacheLoaded( | |
| 38 UserPolicyDiskCache::LoadResult result, | |
| 39 const enterprise_management::CachedCloudPolicyResponse& policy) OVERRIDE; | |
| 40 | |
|
Mattias Nissler (ping if slow)
2012/08/20 15:29:30
remove extra blank line
Andrew T Wilson (Slow)
2012/08/21 23:18:19
Done.
| |
| 41 | |
| 32 private: | 42 private: |
| 33 // Starts policy blob validation. |callback| is invoked once validation is | 43 // Starts policy blob validation. |callback| is invoked once validation is |
| 34 // complete. | 44 // complete. |
| 35 void Validate( | 45 void Validate( |
| 36 scoped_ptr<enterprise_management::PolicyFetchResponse> policy, | 46 scoped_ptr<enterprise_management::PolicyFetchResponse> policy, |
| 37 const UserCloudPolicyValidator::CompletionCallback& callback); | 47 const UserCloudPolicyValidator::CompletionCallback& callback); |
| 38 | 48 |
| 49 // Callback invoked to install a just-loaded policy after validation has | |
| 50 // finished. | |
| 51 void InstallLoadedPolicyAfterValidation(UserCloudPolicyValidator* validator); | |
| 52 | |
| 39 // Callback invoked to store the policy after validation has finished. | 53 // Callback invoked to store the policy after validation has finished. |
| 40 void StorePolicyAfterValidation(UserCloudPolicyValidator* validator); | 54 void StorePolicyAfterValidation(UserCloudPolicyValidator* validator); |
| 41 | 55 |
| 56 // WeakPtrFactory used to create callbacks for validating and storing policy. | |
| 42 base::WeakPtrFactory<UserCloudPolicyStore> weak_factory_; | 57 base::WeakPtrFactory<UserCloudPolicyStore> weak_factory_; |
| 43 | 58 |
| 59 // Helper object used to read/write policy to disk. | |
| 60 scoped_refptr<UserPolicyDiskCache> policy_cache_; | |
| 61 | |
| 44 // Weak pointer to the profile associated with this store. | 62 // Weak pointer to the profile associated with this store. |
| 45 Profile* profile_; | 63 Profile* profile_; |
| 46 | 64 |
| 47 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyStore); | 65 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyStore); |
| 48 }; | 66 }; |
| 49 | 67 |
| 50 } // namespace policy | 68 } // namespace policy |
| 51 | 69 |
| 52 #endif // CHROME_BROWSER_POLICY_USER_CLOUD_POLICY_STORE_H_ | 70 #endif // CHROME_BROWSER_POLICY_USER_CLOUD_POLICY_STORE_H_ |
| OLD | NEW |