| {% from 'templates/macros.tmpl' import license, source_files_for_generated_file %} |
| {{license()}} |
| |
| |
| #include "base/no_destructor.h" |
| #include "base/feature_list.h" |
| #include "third_party/blink/public/common/features.h" |
| #include "third_party/blink/public/common/feature_policy/document_policy_features.h" |
| #include "third_party/blink/public/common/feature_policy/policy_value.h" |
| #include "third_party/blink/public/mojom/feature_policy/policy_value.mojom.h" |
| #include "third_party/blink/public/mojom/feature_policy/document_policy_feature.mojom.h" |
| |
| |
| namespace blink { |
| |
| const DocumentPolicyFeatureInfoMap& GetDocumentPolicyFeatureInfoMap() { |
| static const base::NoDestructor<DocumentPolicyFeatureInfoMap> feature_info_map([] { |
| DocumentPolicyFeatureInfoMap map({ |
| {%- for feature in features %} |
| { |
| mojom::DocumentPolicyFeature::k{{feature.name}}, |
| { |
| "{{feature.document_policy_name}}", |
| {{parse_default_value(feature.default_value, feature.value_type)}} |
| } |
| }, |
| {%- endfor %} |
| }); |
| |
| {%- for feature in features %} |
| {%- if feature.default_value_behind_flag %} |
| {%- for flag, default_value in feature.default_value_behind_flag %} |
| {%- if not loop.first %} else {% endif %} |
| if (base::FeatureList::IsEnabled(features::k{{flag}})) { |
| map.find(mojom::DocumentPolicyFeature::k{{feature.name}})->second.default_value = |
| {{parse_default_value(default_value, feature.value_type)}}; |
| } |
| {%- endfor %} |
| {%- endif %} |
| {%- endfor %} |
| |
| return map; |
| }()); |
| return *feature_info_map; |
| } |
| |
| const DocumentPolicyNameFeatureMap& GetDocumentPolicyNameFeatureMap() { |
| static const base::NoDestructor<DocumentPolicyNameFeatureMap> name_feature_map([] { |
| DocumentPolicyNameFeatureMap map; |
| for (const auto& entry : GetDocumentPolicyFeatureInfoMap()) |
| map.emplace(entry.second.feature_name, entry.first); |
| return map; |
| }()); |
| return *name_feature_map; |
| } |
| |
| } // namespace blink |