Policy creation

From chromium/chromium · View interactive version

Policy creation is an AI agent skill from the GitHub repository chromium/chromium. Guide for adding new enterprise policies to Chromium. Complete guide for policy definitions, pref mapping, and writing tests.

How to use this skill

Skill file

Chrome Enterprise Policy Development

This skill provides guidance for adding and testing new enterprise policies

within the Chromium codebase.

0. Gather Information

Before you start writing the policy, make sure you have the information needed

to completely write the policy YAML. Do not make assumptions.

this for the supported_on field.

You MUST confirm this information with the user before making sure change. You

MUST ask the user for:

be a combination of:

file://components/policy/OWNERS.

supported platform.

(ready for release).

You MUST NOT proceed with writing the YAML file until you have gathered all this

information.

You MAY additionally ask the user:

1. Policy Definition & Declaration

All policies must be defined in the Chromium codebase.

Declaration

components/policy/resources/templates/policies.yaml.

Metadata and Grouping

file indicating caption and description.

appropriate group directory in policy_definitions/.

correctly.

Set`.

name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph>`).

python3 tools/metrics/histograms/update_policies.py --yes to sync with

enums.xml.

2. Naming Conventions

(e.g., Use FooEnabled instead of FooDisabled, even if the default is

true).

of API).

3. Supported Data Types

Policies fall into 6 main types:

  1. Boolean: 3 states (enabled, disabled, not set).
  2. Enum: Multiple states. Use string-enum-list if multiple options can be

chosen concurrently.

  1. Integer: Non-negative integers. Choose a sensible unit (e.g., hours

instead of milliseconds if precision isn't necessary) and interval.

  1. String: Empty strings must be treated as not setting the policy.

Consider partial invalidity and error handling.

  1. List: List of strings. Empty lists must be treated as not set.

Validate user input and set bounds for performance (e.g., max 1000 URLs).

  1. Dictionary: JSON encoded strings containing a complex object. (Refer to

standard complex policy guidelines).

4. Atomic Policy Groups

If multiple policies are closely related and must be applied together from a

single source, define an atomic group.

5. Preference Mapping

Policy values map to internal browser preferences.

  1. Registration: Register prefs in Local State or Profile Prefs

(preferably Profile Prefs for admin flexibility). This must match

per_profile in your PolicyName.yaml.

  1. Mapping:

chrome/browser/policy/configuration_policy_handler_list_factory.cc (or

ios/chrome/browser/policy/model/configuration_policy_handler_list_factory.mm

for iOS) for 1-to-1 mappings.

You MAY use an #if BUILDFLAG(...) guard based on target platforms.

ConfigurationPolicyHandler.

6. ChromeOS Device Policies

If the policy affects the hardware or login screen:

7. Preference Mapping Tests

Policy preference mappings must be tested to ensure the policy translates to the

correct setting.

"simple_policy_pref_mapping_test": { "pref_name": "your.pref.path",

"default_value": false, "values_to_test": [true, false] } } ]`

ios/chrome/test/data/policy/pref_mapping/<PolicyName>.json.

android, fuchsia) requires at least one meaningful test case.

policies/prefs.

set it to true to test both mandatory and recommended values.

external download), use reason_for_missing_test_case.

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.