#include "components/policy/core/common/cloud/user_cloud_policy_store.h"
#include <stddef.h>
#include <utility>
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_macros.h"
#include "base/sequence_checker.h"
#include "base/task/sequenced_task_runner.h"
#include "components/policy/core/common/cloud/cloud_policy_constants.h"
#include "components/policy/proto/cloud_policy.pb.h"
#include "components/policy/proto/device_management_backend.pb.h"
#include "components/policy/proto/policy_signing_key.pb.h"
#include "google_apis/gaia/gaia_auth_util.h"
em;
namespace policy {
namespace {
const base::FilePath::CharType kPolicyDir[] = …);
const base::FilePath::CharType kPolicyCacheFile[] = …);
const base::FilePath::CharType kKeyCacheFile[] = …);
const size_t kPolicySizeLimit = …;
const size_t kKeySizeLimit = …;
bool WriteStringToFile(const base::FilePath path, const std::string& data) { … }
void StorePolicyToDiskOnBackgroundThread(
const base::FilePath& policy_path,
const base::FilePath& key_path,
const em::PolicyFetchResponse& policy) { … }
}
DesktopCloudPolicyStore::DesktopCloudPolicyStore(
const base::FilePath& policy_path,
const base::FilePath& key_path,
PolicyLoadFilter policy_load_filter,
scoped_refptr<base::SequencedTaskRunner> background_task_runner,
PolicyScope policy_scope)
: … { … }
DesktopCloudPolicyStore::~DesktopCloudPolicyStore() { … }
void DesktopCloudPolicyStore::LoadImmediately() { … }
void DesktopCloudPolicyStore::Clear() { … }
void DesktopCloudPolicyStore::Load() { … }
PolicyLoadResult DesktopCloudPolicyStore::LoadAndFilterPolicyFromDisk(
const base::FilePath& policy_path,
const base::FilePath& key_path,
const PolicyLoadFilter& policy_load_filter) { … }
PolicyLoadResult DesktopCloudPolicyStore::LoadPolicyFromDisk(
const base::FilePath& policy_path,
const base::FilePath& key_path) { … }
void DesktopCloudPolicyStore::OnPolicyLoaded(PolicyLoadResult result) { … }
void DesktopCloudPolicyStore::ValidateKeyAndSignature(
UserCloudPolicyValidator* validator,
const em::PolicySigningKey* cached_key,
const std::string& owning_domain) { … }
void DesktopCloudPolicyStore::InstallLoadedPolicyAfterValidation(
bool doing_key_rotation,
const std::string& signing_key,
UserCloudPolicyValidator* validator) { … }
void DesktopCloudPolicyStore::Store(const em::PolicyFetchResponse& policy) { … }
void DesktopCloudPolicyStore::ResetPolicyKey() { … }
void DesktopCloudPolicyStore::OnPolicyToStoreValidated(
UserCloudPolicyValidator* validator) { … }
UserCloudPolicyStore::UserCloudPolicyStore(
const base::FilePath& policy_path,
const base::FilePath& key_path,
scoped_refptr<base::SequencedTaskRunner> background_task_runner)
: … { … }
UserCloudPolicyStore::~UserCloudPolicyStore() { … }
std::unique_ptr<UserCloudPolicyStore> UserCloudPolicyStore::Create(
const base::FilePath& profile_path,
scoped_refptr<base::SequencedTaskRunner> background_task_runner) { … }
void UserCloudPolicyStore::SetSigninAccountId(const AccountId& account_id) { … }
void UserCloudPolicyStore::Validate(
std::unique_ptr<em::PolicyFetchResponse> policy,
std::unique_ptr<em::PolicySigningKey> cached_key,
UserCloudPolicyValidator::CompletionCallback callback) { … }
}