| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_POLICY_USER_CLOUD_POLICY_STORE_H_ | |
| 6 #define CHROME_BROWSER_POLICY_USER_CLOUD_POLICY_STORE_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/compiler_specific.h" | |
| 12 #include "base/files/file_path.h" | |
| 13 #include "base/memory/weak_ptr.h" | |
| 14 #include "chrome/browser/policy/user_cloud_policy_store_base.h" | |
| 15 | |
| 16 class Profile; | |
| 17 | |
| 18 namespace policy { | |
| 19 | |
| 20 // Implements a cloud policy store that is stored in a simple file in the user's | |
| 21 // profile directory. This is used on (non-chromeos) platforms that do not have | |
| 22 // a secure storage implementation. | |
| 23 class UserCloudPolicyStore : public UserCloudPolicyStoreBase { | |
| 24 public: | |
| 25 // Creates a policy store associated with the user signed in to this | |
| 26 // |profile|. | |
| 27 UserCloudPolicyStore(Profile* profile, const base::FilePath& policy_file); | |
| 28 virtual ~UserCloudPolicyStore(); | |
| 29 | |
| 30 // Factory method for creating a UserCloudPolicyStore for |profile|. | |
| 31 static scoped_ptr<UserCloudPolicyStore> Create(Profile* profile); | |
| 32 | |
| 33 // Loads policy immediately on the current thread. Virtual for mocks. | |
| 34 virtual void LoadImmediately(); | |
| 35 | |
| 36 // Deletes any existing policy blob and notifies observers via OnStoreLoaded() | |
| 37 // that the blob has changed. Virtual for mocks. | |
| 38 virtual void Clear(); | |
| 39 | |
| 40 // CloudPolicyStore implementation. | |
| 41 virtual void Load() OVERRIDE; | |
| 42 virtual void Store( | |
| 43 const enterprise_management::PolicyFetchResponse& policy) OVERRIDE; | |
| 44 | |
| 45 private: | |
| 46 // Callback invoked when a new policy has been loaded from disk. If | |
| 47 // |validate_in_background| is true, then policy is validated via a background | |
| 48 // thread. | |
| 49 void PolicyLoaded(bool validate_in_background, | |
| 50 struct PolicyLoadResult policy_load_result); | |
| 51 | |
| 52 // Starts policy blob validation. |callback| is invoked once validation is | |
| 53 // complete. If |validate_in_background| is true, then the validation work | |
| 54 // occurs on a background thread (results are sent back to the calling | |
| 55 // thread). | |
| 56 void Validate( | |
| 57 scoped_ptr<enterprise_management::PolicyFetchResponse> policy, | |
| 58 bool validate_in_background, | |
| 59 const UserCloudPolicyValidator::CompletionCallback& callback); | |
| 60 | |
| 61 // Callback invoked to install a just-loaded policy after validation has | |
| 62 // finished. | |
| 63 void InstallLoadedPolicyAfterValidation(UserCloudPolicyValidator* validator); | |
| 64 | |
| 65 // Callback invoked to store the policy after validation has finished. | |
| 66 void StorePolicyAfterValidation(UserCloudPolicyValidator* validator); | |
| 67 | |
| 68 // WeakPtrFactory used to create callbacks for validating and storing policy. | |
| 69 base::WeakPtrFactory<UserCloudPolicyStore> weak_factory_; | |
| 70 | |
| 71 // Weak pointer to the profile associated with this store. | |
| 72 Profile* profile_; | |
| 73 | |
| 74 // Path to file where we store persisted policy. | |
| 75 base::FilePath backing_file_path_; | |
| 76 | |
| 77 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyStore); | |
| 78 }; | |
| 79 | |
| 80 } // namespace policy | |
| 81 | |
| 82 #endif // CHROME_BROWSER_POLICY_USER_CLOUD_POLICY_STORE_H_ | |
| OLD | NEW |