Remove cloud_policy_generated.cc
Store enough metadata in policy_constants.cc that we can use it to decode policies, and so don't need to generate any more code in cloud_policy_generated.cc The metadata required to decode a policy from a proto is the key, the type (both the raw type ie integer or string, and also whether it is JSON or external), and pointers to both has_policyproto() and policyproto() functions, where policyproto is the message field that holds this policy. The metadata that is stored in policy_constants.cc looks like so - the lines starting with &em are function pointers into the CloudPolicySettings proto: constexpr BooleanPolicyAccess kBooleanPolicyAccess[] = { {key::kAbusiveExperienceInterventionEnforce, &em::CloudPolicySettings::has_abusiveexperienceinterventionenforce, &em::CloudPolicySettings::abusiveexperienceinterventionenforce}, {key::kAllowCrossOriginAuthPrompt, &em::CloudPolicySettings::has_allowcrossoriginauthprompt, &em::CloudPolicySettings::allowcrossoriginauthprompt}, ... {nullptr, nullptr, nullptr}, }; constexpr IntegerPolicyAccess kIntegerPolicyAccess[] = { {key::kAdsSettingForIntrusiveAdsSites, &em::CloudPolicySettings::has_adssettingforintrusiveadssites, &em::CloudPolicySettings::adssettingforintrusiveadssites}, {key::kArcBackupRestoreServiceEnabled, &em::CloudPolicySettings::has_arcbackuprestoreserviceenabled, &em::CloudPolicySettings::arcbackuprestoreserviceenabled}, ... {nullptr, nullptr, nullptr}, }; constexpr StringPolicyAccess kStringPolicyAccess[] = { {key::kAllowedDomainsForApps, &em::CloudPolicySettings::has_alloweddomainsforapps, &em::CloudPolicySettings::alloweddomainsforapps, StringPolicyType::STRING}, {key::kContentPackManualBehaviorHosts, &em::CloudPolicySettings::has_contentpackmanualbehaviorhosts, &em::CloudPolicySettings::contentpackmanualbehaviorhosts, StringPolicyType::JSON}, {key::kNativePrintersBulkConfiguration, &em::CloudPolicySettings::has_nativeprintersbulkconfiguration, &em::CloudPolicySettings::nativeprintersbulkconfiguration, StringPolicyType::EXTERNAL}, ... {nullptr, nullptr, nullptr}, }; constexpr StringListPolicyAccess kStringListPolicyAccess[] = { {key::kAllowedInputMethods, &em::CloudPolicySettings::has_allowedinputmethods, &em::CloudPolicySettings::allowedinputmethods}, ... {nullptr, nullptr, nullptr}, }; Bug: 852366 Change-Id: I1b8a0ebc0c6d5019e63d81a4cb7e1cd1cb461bb3 Reviewed-on: https://chromium-review.googlesource.com/1110219 Commit-Queue: A Olsen <olsen@chromium.org> Reviewed-by:Lutz Justen <ljusten@chromium.org> Cr-Commit-Position: refs/heads/master@{#572212}
Showing
Please register or sign in to comment