#include "components/policy/core/browser/policy_conversions.h"
#include <string>
#include <utility>
#include "base/check.h"
#include "base/values.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "components/policy/core/browser/policy_conversions_client.h"
#include "components/strings/grit/components_strings.h"
#include "extensions/buildflags/buildflags.h"
#include "ui/base/l10n/l10n_util.h"
Value;
namespace policy {
const webui::LocalizedString kPolicySources[POLICY_SOURCE_COUNT] = …;
const char kIdKey[] = …;
const char kNameKey[] = …;
const char kPoliciesKey[] = …;
const char kPolicyNamesKey[] = …;
const char kChromePoliciesId[] = …;
const char kChromePoliciesName[] = …;
#if !BUILDFLAG(IS_CHROMEOS)
const char kPrecedenceOrderKey[] = …;
const char kPrecedencePoliciesId[] = …;
const char kPrecedencePoliciesName[] = …;
#endif
#if BUILDFLAG(IS_CHROMEOS_ASH)
const char kDeviceLocalAccountPoliciesId[] = "deviceLocalAccountPolicies";
#endif
PolicyConversions::Delegate::Delegate(PolicyConversionsClient* client)
: … { … }
PolicyConversions::Delegate::~Delegate() = default;
PolicyConversions::PolicyConversions(
std::unique_ptr<PolicyConversionsClient> client)
: … { … }
PolicyConversions::~PolicyConversions() = default;
PolicyConversions& PolicyConversions::EnableConvertTypes(bool enabled) { … }
PolicyConversions& PolicyConversions::EnableConvertValues(bool enabled) { … }
PolicyConversions& PolicyConversions::EnableDeviceLocalAccountPolicies(
bool enabled) { … }
PolicyConversions& PolicyConversions::EnableDeviceInfo(bool enabled) { … }
PolicyConversions& PolicyConversions::EnablePrettyPrint(bool enabled) { … }
PolicyConversions& PolicyConversions::EnableUserPolicies(bool enabled) { … }
PolicyConversions& PolicyConversions::SetDropDefaultValues(bool enabled) { … }
PolicyConversions& PolicyConversions::EnableShowMachineValues(bool enabled) { … }
PolicyConversions& PolicyConversions::UseChromePolicyConversions() { … }
std::string PolicyConversions::ToJSON() { … }
base::Value::Dict PolicyConversions::ToValueDict() { … }
DefaultPolicyConversions::DefaultPolicyConversions(
PolicyConversionsClient* client)
: … { … }
DefaultPolicyConversions::~DefaultPolicyConversions() = default;
Value::Dict DefaultPolicyConversions::ToValueDict() { … }
#if BUILDFLAG(IS_CHROMEOS_ASH)
Value::Dict DefaultPolicyConversions::GetDeviceLocalAccountPolicies() {
Value::List policies = client()->GetDeviceLocalAccountPolicies();
Value::Dict device_values;
for (auto&& policy : policies) {
const std::string* id = policy.GetDict().FindString(kIdKey);
Value* policies_value = policy.GetDict().Find(kPoliciesKey);
DCHECK(id);
DCHECK(policies_value);
device_values.Set(*id, std::move(*policies_value));
}
return device_values;
}
#endif
#if BUILDFLAG(ENABLE_EXTENSIONS)
base::Value::Dict DefaultPolicyConversions::GetExtensionPolicies() { … }
Value::Dict DefaultPolicyConversions::GetExtensionPolicies(
PolicyDomain policy_domain) { … }
#endif
ChromePolicyConversions::ChromePolicyConversions(
PolicyConversionsClient* client)
: … { … }
ChromePolicyConversions::~ChromePolicyConversions() = default;
Value::Dict ChromePolicyConversions::ToValueDict() { … }
Value::Dict ChromePolicyConversions::GetChromePolicies() { … }
#if !BUILDFLAG(IS_CHROMEOS)
Value::Dict ChromePolicyConversions::GetPrecedencePolicies() { … }
#endif
}