| 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..563c2234fdbd86f1b1c72eefd8d5f6dd98fcc21d
|
| --- /dev/null
|
| +++ b/chrome/browser/policy/cros_user_policy_cache.h
|
| @@ -0,0 +1,92 @@
|
| +// 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_;
|
| +
|
| + // TODO(mnissler): Remove when the number of M13 clients is back to zero.
|
| + scoped_refptr<UserPolicyTokenCache> legacy_token_cache_;
|
| +
|
| + // 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_
|
|
|