Chromium Code Reviews| OLD | NEW |
|---|---|
| (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/policy/cloud_policy_cache_base.h" | |
| 16 #include "chrome/browser/policy/user_policy_disk_cache.h" | |
| 17 #include "chrome/browser/policy/user_policy_token_cache.h" | |
| 18 | |
| 19 namespace chromeos { | |
| 20 class LoginLibrary; | |
| 21 } | |
| 22 | |
| 23 namespace policy { | |
| 24 | |
| 25 class CloudPolicyDataStore; | |
| 26 class CrosUserPolicyIdentityStrategy; | |
|
gfeher
2011/07/21 23:37:15
Obsolete, please remove.
Mattias Nissler (ping if slow)
2011/07/22 11:29:48
Done.
| |
| 27 | |
| 28 // User policy cache that talks to the ChromeOS login library in order to store | |
| 29 // and fetch policy data. | |
| 30 class CrosUserPolicyCache : public CloudPolicyCacheBase, | |
| 31 public UserPolicyTokenCache::Delegate, | |
| 32 public UserPolicyDiskCache::Delegate { | |
| 33 public: | |
| 34 CrosUserPolicyCache(chromeos::LoginLibrary* login_library, | |
| 35 CloudPolicyDataStore* data_store, | |
| 36 const FilePath& legacy_token_cache_file, | |
| 37 const FilePath& legacy_policy_cache_file); | |
| 38 virtual ~CrosUserPolicyCache(); | |
| 39 | |
| 40 // CloudPolicyCacheBase implementation. | |
| 41 virtual void Load() OVERRIDE; | |
| 42 virtual void SetPolicy(const em::PolicyFetchResponse& policy) OVERRIDE; | |
| 43 virtual void SetUnmanaged() OVERRIDE; | |
| 44 virtual bool IsReady() OVERRIDE; | |
| 45 | |
| 46 protected: | |
| 47 virtual bool DecodePolicyData(const em::PolicyData& policy_data, | |
| 48 PolicyMap* mandatory, | |
| 49 PolicyMap* recommended) OVERRIDE; | |
| 50 | |
| 51 private: | |
| 52 class PolicyKey; | |
| 53 class StorePolicyOperation; | |
| 54 class RetrievePolicyOperation; | |
| 55 | |
| 56 // UserPolicyTokenLoader::Delegate: | |
| 57 virtual void OnTokenLoaded(const std::string& token, | |
| 58 const std::string& device_id) OVERRIDE; | |
| 59 | |
| 60 // UserPolicyDiskCache::Delegate: | |
| 61 virtual void OnDiskCacheLoaded( | |
| 62 const em::CachedCloudPolicyResponse& policy) OVERRIDE; | |
| 63 | |
| 64 // Used as a callback for the policy store operation. | |
| 65 void OnPolicyStored(bool result); | |
| 66 | |
| 67 // Callback for the initial policy load. Installs the policy and passes the | |
| 68 // loaded token and device ID to the identity strategy. | |
|
gfeher
2011/07/21 23:37:15
Nit: identity strategy -> data store
Mattias Nissler (ping if slow)
2011/07/22 11:29:48
Done.
| |
| 69 void OnPolicyLoadDone(bool result, const em::PolicyFetchResponse& policy); | |
| 70 | |
| 71 // Callback for the policy retrieval operation run to reload the policy after | |
| 72 // new policy has been successfully stored. Installs the new policy in the | |
| 73 // cache and publishes it if successful. | |
| 74 void OnPolicyReloadDone(bool result, const em::PolicyFetchResponse& policy); | |
| 75 | |
| 76 // Starts a new retrieval operation. | |
| 77 void StartRetrieve(bool reload_key); | |
| 78 | |
| 79 void CancelStore(); | |
| 80 void CancelRetrieve(); | |
| 81 | |
| 82 // Removes the legacy cache dir. | |
| 83 static void RemoveLegacyCacheDir(const FilePath& dir); | |
| 84 | |
| 85 scoped_refptr<PolicyKey> key_; | |
| 86 chromeos::LoginLibrary* login_library_; | |
| 87 CloudPolicyDataStore* data_store_; | |
| 88 | |
| 89 // Whether we have loaded the policy cache. | |
| 90 bool policy_cache_loaded_; | |
| 91 | |
| 92 // Storage and retrieval operations that are currently in flight. | |
| 93 StorePolicyOperation* store_operation_; | |
| 94 RetrievePolicyOperation* retrieve_operation_; | |
| 95 | |
| 96 // TODO(mnissler): Remove all the legacy policy support members below after | |
| 97 // the number of M14 clients drops back to zero. | |
| 98 FilePath legacy_cache_dir_; | |
| 99 | |
| 100 base::WeakPtrFactory<UserPolicyTokenCache::Delegate> | |
| 101 legacy_token_cache_delegate_factory_; | |
| 102 scoped_refptr<UserPolicyTokenLoader> legacy_token_loader_; | |
| 103 | |
| 104 base::WeakPtrFactory<UserPolicyDiskCache::Delegate> | |
| 105 legacy_policy_cache_delegate_factory_; | |
| 106 scoped_refptr<UserPolicyDiskCache> legacy_policy_cache_; | |
| 107 | |
|
gfeher
2011/07/21 23:37:15
Nit: extra newline.
Mattias Nissler (ping if slow)
2011/07/22 11:29:48
Done.
| |
| 108 | |
| 109 DISALLOW_COPY_AND_ASSIGN(CrosUserPolicyCache); | |
| 110 }; | |
| 111 | |
| 112 } // namespace policy | |
| 113 | |
| 114 #endif // CHROME_BROWSER_POLICY_CROS_USER_POLICY_CACHE_H_ | |
| OLD | NEW |