#ifndef COMPONENTS_POLICY_CORE_COMMON_CLOUD_USER_CLOUD_POLICY_STORE_H_
#define COMPONENTS_POLICY_CORE_COMMON_CLOUD_USER_CLOUD_POLICY_STORE_H_
#include <string>
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/files/file_path.h"
#include "base/memory/weak_ptr.h"
#include "components/policy/core/common/cloud/user_cloud_policy_store_base.h"
#include "components/policy/policy_export.h"
#include "policy/proto/policy_signing_key.pb.h"
namespace base {
class SequencedTaskRunner;
}
namespace policy {
class POLICY_EXPORT UserCloudPolicyStore : public UserCloudPolicyStoreBase {
public:
UserCloudPolicyStore(
const base::FilePath& policy_file,
const base::FilePath& key_file,
const std::string& verification_key,
scoped_refptr<base::SequencedTaskRunner> background_task_runner);
virtual ~UserCloudPolicyStore();
static scoped_ptr<UserCloudPolicyStore> Create(
const base::FilePath& profile_path,
const std::string& verification_key,
scoped_refptr<base::SequencedTaskRunner> background_task_runner);
void SetSigninUsername(const std::string& username);
virtual void LoadImmediately();
virtual void Clear();
virtual void Load() OVERRIDE;
virtual void Store(
const enterprise_management::PolicyFetchResponse& policy) OVERRIDE;
const std::string& policy_key() { return policy_key_; }
protected:
std::string signin_username_;
private:
void PolicyLoaded(bool validate_in_background,
struct PolicyLoadResult policy_load_result);
void Validate(
scoped_ptr<enterprise_management::PolicyFetchResponse> policy,
scoped_ptr<enterprise_management::PolicySigningKey> key,
const std::string& verification_key,
bool validate_in_background,
const UserCloudPolicyValidator::CompletionCallback& callback);
void InstallLoadedPolicyAfterValidation(bool doing_key_rotation,
const std::string& signing_key,
UserCloudPolicyValidator* validator);
void StorePolicyAfterValidation(UserCloudPolicyValidator* validator);
base::WeakPtrFactory<UserCloudPolicyStore> weak_factory_;
std::string policy_key_;
base::FilePath policy_path_;
base::FilePath key_path_;
const std::string verification_key_;
DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyStore);
};
}
#endif