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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/policy/cros_user_policy_cache.h
diff --git a/chrome/browser/policy/cros_user_policy_cache.h b/chrome/browser/policy/cros_user_policy_cache.h
new file mode 100644
index 0000000000000000000000000000000000000000..46e16bd4cd1a6a71753ab9f33751f0cb5f9b620e
--- /dev/null
+++ b/chrome/browser/policy/cros_user_policy_cache.h
@@ -0,0 +1,90 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_POLICY_CROS_USER_POLICY_CACHE_H_
+#define CHROME_BROWSER_POLICY_CROS_USER_POLICY_CACHE_H_
+#pragma once
+
+#include <string>
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "base/file_path.h"
+#include "base/memory/ref_counted.h"
+#include "chrome/browser/chromeos/cros/login_library.h"
+#include "chrome/browser/policy/cloud_policy_cache_base.h"
+#include "chrome/browser/policy/user_policy_token_cache.h"
+
+namespace policy {
+
+class CrosUserPolicyIdentityStrategy;
+
+// User policy cache that talks to the ChromeOS login library in order to store
+// and fetch policy data.
+class CrosUserPolicyCache : public CloudPolicyCacheBase,
+ public UserPolicyTokenCache::Delegate {
+ public:
+ CrosUserPolicyCache(chromeos::LoginLibrary* login_library,
+ CrosUserPolicyIdentityStrategy* identity_strategy,
+ const FilePath& legacy_cache_file_);
+ virtual ~CrosUserPolicyCache();
+
+ // CloudPolicyCacheBase implementation.
+ virtual void Load() OVERRIDE;
+ virtual void SetPolicy(const em::PolicyFetchResponse& policy) OVERRIDE;
+ virtual void SetUnmanaged() OVERRIDE;
+
+ protected:
+ virtual bool DecodePolicyData(const em::PolicyData& policy_data,
+ PolicyMap* mandatory,
+ PolicyMap* recommended) OVERRIDE;
+
+ private:
+ class PolicyKey;
+ class StorePolicyOperation;
+ class RetrievePolicyOperation;
+
+ // UserPolicyTokenCache::Delegate:
+ virtual void OnTokenCacheLoaded(const std::string& token,
+ const std::string& device_id) OVERRIDE;
+
+ // Used as a callback for the policy store operation.
+ void OnPolicyStored(bool result);
+
+ // Callback for the initial policy load. Installs the policy and passes the
+ // loaded token and device ID to the identity strategy.
+ void OnPolicyLoadDone(bool result, const em::PolicyFetchResponse& policy);
+
+ // Callback for the policy retrieval operation run to reload the policy after
+ // new policy has been successfully stored. Installs the new policy in the
+ // cache and publishes it if successful.
+ void OnPolicyReloadDone(bool result, const em::PolicyFetchResponse& policy);
+
+ // Starts a new retrieval operation.
+ void StartRetrieve(bool reload_key);
+
+ void CancelStore();
+ void CancelRetrieve();
+
+ // Removes the legacy cache dir.
+ static void RemoveLegacyCacheDir(const FilePath& dir);
+
+ scoped_refptr<PolicyKey> key_;
+ chromeos::LoginLibrary* login_library_;
+ CrosUserPolicyIdentityStrategy* identity_strategy_;
+
+ base::WeakPtrFactory<UserPolicyTokenCache::Delegate> weak_ptr_factory_;
+ const FilePath legacy_cache_file_;
+ 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.
+
+ // Storage and retrieval operations that are currently in flight.
+ StorePolicyOperation* store_operation_;
+ RetrievePolicyOperation* retrieve_operation_;
+
+ DISALLOW_COPY_AND_ASSIGN(CrosUserPolicyCache);
+};
+
+} // namespace policy
+
+#endif // CHROME_BROWSER_POLICY_CROS_USER_POLICY_CACHE_H_

Powered by Google App Engine
This is Rietveld 408576698