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

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

Issue 7233006: Store/Retrieve CrOS user policy in session_manager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 6 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
(Empty)
1 // Copyright (c) 2011 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_CROS_USER_POLICY_CACHE_H_
6 #define CHROME_BROWSER_POLICY_CROS_USER_POLICY_CACHE_H_
7 #pragma once
8
9 #include <string>
10
11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h"
13 #include "base/file_path.h"
14 #include "base/memory/ref_counted.h"
15 #include "chrome/browser/chromeos/cros/login_library.h"
16 #include "chrome/browser/policy/cloud_policy_cache_base.h"
17 #include "chrome/browser/policy/user_policy_token_cache.h"
18
19 namespace policy {
20
21 class CrosUserPolicyIdentityStrategy;
22
23 // User policy cache that talks to the ChromeOS login library in order to store
24 // and fetch policy data.
25 class CrosUserPolicyCache : public CloudPolicyCacheBase,
26 public UserPolicyTokenCache::Delegate {
27 public:
28 CrosUserPolicyCache(chromeos::LoginLibrary* login_library,
29 CrosUserPolicyIdentityStrategy* identity_strategy,
30 const FilePath& legacy_cache_file_);
31 virtual ~CrosUserPolicyCache();
32
33 // CloudPolicyCacheBase implementation.
34 virtual void Load() OVERRIDE;
35 virtual void SetPolicy(const em::PolicyFetchResponse& policy) OVERRIDE;
36 virtual void SetUnmanaged() OVERRIDE;
37
38 protected:
39 virtual bool DecodePolicyData(const em::PolicyData& policy_data,
40 PolicyMap* mandatory,
41 PolicyMap* recommended) OVERRIDE;
42
43 private:
44 class PolicyKey;
45 class StorePolicyOperation;
46 class RetrievePolicyOperation;
47
48 // UserPolicyTokenCache::Delegate:
49 virtual void OnTokenCacheLoaded(const std::string& token,
50 const std::string& device_id) OVERRIDE;
51
52 // Used as a callback for the policy store operation.
53 void OnPolicyStored(bool result);
54
55 // Callback for the initial policy load. Installs the policy and passes the
56 // loaded token and device ID to the identity strategy.
57 void OnPolicyLoadDone(bool result, const em::PolicyFetchResponse& policy);
58
59 // Callback for the policy retrieval operation run to reload the policy after
60 // new policy has been successfully stored. Installs the new policy in the
61 // cache and publishes it if successful.
62 void OnPolicyReloadDone(bool result, const em::PolicyFetchResponse& policy);
63
64 // Starts a new retrieval operation.
65 void StartRetrieve(bool reload_key);
66
67 void CancelStore();
68 void CancelRetrieve();
69
70 // Removes the legacy cache dir.
71 static void RemoveLegacyCacheDir(const FilePath& dir);
72
73 scoped_refptr<PolicyKey> key_;
74 chromeos::LoginLibrary* login_library_;
75 CrosUserPolicyIdentityStrategy* identity_strategy_;
76
77 base::WeakPtrFactory<UserPolicyTokenCache::Delegate> weak_ptr_factory_;
78 const FilePath legacy_cache_file_;
79 scoped_refptr<UserPolicyTokenCache> legacy_token_cache_;
gfeher 2011/06/22 12:41:31 Add a TODO to remove the above two when all the le
Mattias Nissler (ping if slow) 2011/06/22 17:17:35 Done.
80
81 // Storage and retrieval operations that are currently in flight.
82 StorePolicyOperation* store_operation_;
83 RetrievePolicyOperation* retrieve_operation_;
84
85 DISALLOW_COPY_AND_ASSIGN(CrosUserPolicyCache);
86 };
87
88 } // namespace policy
89
90 #endif // CHROME_BROWSER_POLICY_CROS_USER_POLICY_CACHE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698