blob: 6ef3a5045ec7e38c9825468e6255db7f6553b259 [file] [log] [blame]
// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/browsing_data/browsing_data_lifetime_policy_handler.h"
#include "components/policy/core/browser/policy_error_map.h"
#include "components/policy/core/common/policy_map.h"
#include "components/policy/policy_constants.h"
#include "components/strings/grit/components_strings.h"
BrowsingDataLifetimePolicyHandler::BrowsingDataLifetimePolicyHandler(
const char* policy_name,
const char* pref_path,
policy::Schema schema)
: policy::SimpleSchemaValidatingPolicyHandler(
policy_name,
pref_path,
schema,
policy::SchemaOnErrorStrategy::SCHEMA_ALLOW_UNKNOWN,
SimpleSchemaValidatingPolicyHandler::RECOMMENDED_PROHIBITED,
SimpleSchemaValidatingPolicyHandler::MANDATORY_ALLOWED) {}
BrowsingDataLifetimePolicyHandler::~BrowsingDataLifetimePolicyHandler() =
default;
bool BrowsingDataLifetimePolicyHandler::CheckPolicySettings(
const policy::PolicyMap& policies,
policy::PolicyErrorMap* errors) {
if (!policy::SimpleSchemaValidatingPolicyHandler::CheckPolicySettings(
policies, errors)) {
return false;
}
if (!policies.Get(policy_name()))
return true;
const auto* sync_disabled =
policies.GetValue(policy::key::kSyncDisabled, base::Value::Type::BOOLEAN);
if (!sync_disabled || !sync_disabled->GetBool()) {
errors->AddError(policy_name(), IDS_POLICY_DEPENDENCY_ERROR,
policy::key::kSyncDisabled, "true");
return false;
}
return true;
}