Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(395)

Side by Side Diff: chrome/browser/policy/user_cloud_policy_store.h

Issue 10825415: Added code to persist downloaded cloud policy to disk. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed unneeded #include Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/file_path.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"
14 15
15 namespace policy { 16 namespace policy {
16 17
17 // Implements a cloud policy store that is stored in a simple file in the user's 18 // 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 19 // profile directory. This is used on (non-chromeos) platforms that do not have
19 // a secure storage implementation. 20 // a secure storage implementation.
20 class UserCloudPolicyStore : public UserCloudPolicyStoreBase { 21 class UserCloudPolicyStore : public UserCloudPolicyStoreBase {
21 public: 22 public:
22 // Creates a policy store associated with the user signed in to this 23 // Creates a policy store associated with the user signed in to this
23 // |profile|. 24 // |profile|.
24 explicit UserCloudPolicyStore(Profile* profile); 25 explicit UserCloudPolicyStore(Profile* profile,
Joao da Silva 2012/08/22 08:07:00 Nit: no need to be explicit
Andrew T Wilson (Slow) 2012/08/22 23:39:30 Done.
26 const FilePath& policy_file);
25 virtual ~UserCloudPolicyStore(); 27 virtual ~UserCloudPolicyStore();
26 28
27 // CloudPolicyStore implementation. 29 // CloudPolicyStore implementation.
28 virtual void Load() OVERRIDE; 30 virtual void Load() OVERRIDE;
29 virtual void Store( 31 virtual void Store(
30 const enterprise_management::PolicyFetchResponse& policy) OVERRIDE; 32 const enterprise_management::PolicyFetchResponse& policy) OVERRIDE;
31 33
34 // Callback invoked when a new policy has been loaded from disk. If
35 // |error| is true, there was an error reading the policy from disk.
36 // Otherwise |policy| contains the policy blob, or NULL if no policy was
37 // found on disk.
38 void PolicyLoaded(
39 bool error,
40 scoped_ptr<enterprise_management::PolicyFetchResponse> policy);
41
32 protected: 42 protected:
33 virtual void RemoveStoredPolicy() OVERRIDE; 43 virtual void RemoveStoredPolicy() OVERRIDE;
34 44
35 private: 45 private:
36 // Starts policy blob validation. |callback| is invoked once validation is 46 // Starts policy blob validation. |callback| is invoked once validation is
37 // complete. 47 // complete.
38 void Validate( 48 void Validate(
39 scoped_ptr<enterprise_management::PolicyFetchResponse> policy, 49 scoped_ptr<enterprise_management::PolicyFetchResponse> policy,
40 const UserCloudPolicyValidator::CompletionCallback& callback); 50 const UserCloudPolicyValidator::CompletionCallback& callback);
41 51
52 // Callback invoked to install a just-loaded policy after validation has
53 // finished.
54 void InstallLoadedPolicyAfterValidation(UserCloudPolicyValidator* validator);
55
42 // Callback invoked to store the policy after validation has finished. 56 // Callback invoked to store the policy after validation has finished.
43 void StorePolicyAfterValidation(UserCloudPolicyValidator* validator); 57 void StorePolicyAfterValidation(UserCloudPolicyValidator* validator);
44 58
59 // WeakPtrFactory used to create callbacks for validating and storing policy.
45 base::WeakPtrFactory<UserCloudPolicyStore> weak_factory_; 60 base::WeakPtrFactory<UserCloudPolicyStore> weak_factory_;
46 61
47 // Weak pointer to the profile associated with this store. 62 // Weak pointer to the profile associated with this store.
48 Profile* profile_; 63 Profile* profile_;
49 64
65 // Path to file where we store persisted policy.
66 FilePath backing_file_path_;
67
50 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyStore); 68 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyStore);
51 }; 69 };
52 70
53 } // namespace policy 71 } // namespace policy
54 72
55 #endif // CHROME_BROWSER_POLICY_USER_CLOUD_POLICY_STORE_H_ 73 #endif // CHROME_BROWSER_POLICY_USER_CLOUD_POLICY_STORE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698