blob: e0a465a4fe64fdc5a4e1fca92a94aabf40ec97d4 [file] [log] [blame] [view]
Owen Min326f43e2019-11-13 16:08:301# Policy Settings in Chrome
2
Owen Minf2127ad02019-12-17 19:59:493## Summary
Owen Min326f43e2019-11-13 16:08:304
Owen Minf2127ad02019-12-17 19:59:495Chrome exposes a different set of configurations to administrators. These
6configurations are called policy and they give administrators more advanced
7controls than the normal users. With different device management tools,
Owen Min650834a2023-06-12 13:08:378an administrator can deliver these policies to many users. Here is the
Owen Minf2127ad02019-12-17 19:59:499[help center article](https://support.google.com/chrome/a/answer/9037717?hl=en)
10that talks about Chrome policy and its deployment.
Owen Min326f43e2019-11-13 16:08:3011
Owen Minf2127ad02019-12-17 19:59:4912## Do I need a policy
Owen Min326f43e2019-11-13 16:08:3013
Owen Minf2127ad02019-12-17 19:59:4914Usually you need a policy when
15
16- Launching a new feature. Create a policy so that the admin can disable or
17 enable the feature for all users.
18
Jana Grill5fb69562020-03-09 15:01:1119- Deprecating an old feature. Create a policy to give enterprise users more
20 time to migrate away from the feature.
Owen Minf2127ad02019-12-17 19:59:4921
Owen Min9bdd16fe2023-08-18 14:59:2322**To read more about best practices for shipping enterprise friendly features,
23please read [this article](https://www.chromium.org/developers/enterprise-changes/).**
24
Owen Minf2127ad02019-12-17 19:59:4925## Adding a new policy
Owen Min326f43e2019-11-13 16:08:3026
Owen Min75fc6652025-01-27 17:23:57271. Design the policy, decide policy name, type, function, etc.
28 - Please read [policy_design.md](./policy_design.md) for more information.
29 - If you are adding support for a GenAI policy, please also read the
30 internal [instructions](http://go/genai-chrome-policy-instructions) for
31 new GenAI policies specifically.
Yann Dagocd66a342022-10-31 15:23:45322. Declare the policy in the [policies.yaml](https://cs.chromium.org/chromium/src/components/policy/resources/templates/policies.yaml) file.
Yann Dago90b71322022-10-19 20:56:2833 - This file contains the policy names and their ids.
343. If you need to add a new policy group, create a directory with the name of
Yann Dagocd66a342022-10-31 15:23:4535 that group under [policy group](https://cs.chromium.org/chromium/src/components/policy/resources/templates/policy_definitions/).
Yann Dago90b71322022-10-19 20:56:2836 - Inside the newly created directory, create a `.group.details.yaml` file
37 with the caption and description of the group. This group is used for
38 documentation and policy template generation, so it is recommended to
39 group policies in meaningful groups.
Yann Dagocd66a342022-10-31 15:23:4540 - Use [.group.details.yaml](https://cs.chromium.org/chromium/src/components/policy/resources/new_policy_templates/.group.details.yaml)
Yann Dago90b71322022-10-19 20:56:2841 as a templates for group definition.
Yann Dagocd66a342022-10-31 15:23:45424. Create a file named `PolicyName.yaml` under the appropriate [policy group](https://cs.chromium.org/chromium/src/components/policy/resources/templates/policy_definitions/).
Owen Min75fc6652025-01-27 17:23:5743 Please use [policy.yaml](https://cs.chromium.org/chromium/src/components/policy/resources/new_policy_templates/policy.yaml) to start off your policy.
Owen Minf2127ad02019-12-17 19:59:4944 - This file contains meta-level descriptions of all policies and is used
Owen Min75fc6652025-01-27 17:23:5745 to generate code, policy templates as well as documentation. Please make
46 sure you get the version and feature flags (such as `dynamic_refresh`
47 and `supported_on`) right. More details on the fields can be found in
48 [policy.yaml](https://cs.chromium.org/chromium/src/components/policy/resources/new_policy_templates/policy.yaml).
Johann48fbca92021-07-16 18:29:4149 - See [description_guidelines.md](description_guidelines.md)
Chris Sharp0f7626d2020-07-27 21:48:1650 for additional guidelines when creating a description, including how
51 various products should be referenced.
Owen Min75fc6652025-01-27 17:23:5752 - Optional fields can be skipped when they are set to the default value.
Shuran Huang0ac3d402022-10-25 18:07:21535. Create a policy atomic group.
54 - If you are adding multiple policies that are closely related and interact
Yann Dago90b71322022-10-19 20:56:2855 with each other, you should put them in policy atomic group. An atomic
56 policy group is used in the Chromium code and affects how policies are
57 applied. When enabled by the admin, this ensures that policies from an
58 atomic group get their values from the same source and are not a mix of
59 policies from multiple sources. This [feature](https://chromeenterprise.google/intl/en_ca/policies/atomic-groups/)
60 is controlled by the policy [PolicyAtomicGroupsEnabled](https://chromeenterprise.google/intl/en_ca/policies/#PolicyAtomicGroupsEnabled).
61
Yann Dagocd66a342022-10-31 15:23:4562 - Declare the atomic group in the [policies.yaml](https://cs.chromium.org/chromium/src/components/policy/resources/templates/policies.yaml) file.
Yann Dago90b71322022-10-19 20:56:2863 - Create a `policy_atomic_groups.yaml` file in the group where you added the
64 policies if it does not already exist.
Jonathan Haoc669fca2023-09-13 06:50:5865 You may use [policy_atomic_groups.yaml](https://cs.chromium.org/chromium/src/components/policy/resources/new_policy_templates/policy_atomic_groups.yaml) as reference.
Shuran Huang0ac3d402022-10-25 18:07:21666. Create a preference and map the policy value to it.
Owen Minf2127ad02019-12-17 19:59:4967 - All policy values need to be mapped into a prefs value before being used
68 unless the policy is needed before PrefService initialization.
69 - To map the policy:
Bob Beckb4025ba2023-03-17 16:40:0670 1. [Create a prefs and register the prefs in **Local State** or
71 **Profile Prefs**.](../../chrome/browser/prefs/README.md)
72 Please note that, this must match the `per_profile` attribute in the
73 `YourPolicyName.yaml`. We also strongly encourage developers to
74 register the prefs with **Profile Prefs** if possible, because
75 this gives admin more flexibility of policy setup.
Jana Grill5fb69562020-03-09 15:01:1176 2. Most policies can be mapped to prefs with `kSimplePolicyMap` in
Salma Elmahallawy1953a0f2024-10-30 15:28:1577 [configuration_policy_handler_list_factory.cc](https://cs.chromium.org/chromium/src/chrome/browser/policy/configuration_policy_handler_list_factory.cc?type=cs&q=kSimplePolicyMap&g=0&l=150). If the policy needs additional verification or processing, please
Owen Minf2127ad02019-12-17 19:59:4978 implement a `ConfigurationPolicyHandler` to do so.
Yann Dago5f65205c12023-10-31 14:53:0979 3. Test the mapping by adding PolicyName.json under
80 [policy/test/data/pref_mapping](https://cs.chromium.org/chromium/src/components/policy/test/data/pref_mapping) (see [instructions](https://cs.chromium.org/chromium/src/docs/enterprise/policy_pref_mapping_test.md)).
Owen Min90926fc2020-04-23 15:12:0481 4. iOS platform has its own
Scott Yoder1773eaf2025-04-10 12:36:5682 [configuration_policy_handler_list_factory.mm](https://source.chromium.org/chromium/chromium/src/+/main:ios/chrome/browser/policy/model/configuration_policy_handler_list_factory.mm)
Owen Min90926fc2020-04-23 15:12:0483 and
Yann Dago5f65205c12023-10-31 14:53:0984 [policy/pref_mapping](https://source.chromium.org/chromium/chromium/src/+/main:ios/chrome/test/data/policy/pref_mapping)
Owen Min90926fc2020-04-23 15:12:0485 file.
Shuran Huang0ac3d402022-10-25 18:07:21867. Disable the user setting UI when the policy is applied.
Owen Minf2127ad02019-12-17 19:59:4987 - If your feature can be controlled by GUI in `chrome://settings`, the
88 associated option should be disabled when the policy controlling it is
89 managed.
90 - `PrefService:Preference::IsManaged` reveals whether a prefs value
91 comes from policy or not.
92 - The setting needs an
93 [indicator](https://cs.chromium.org/chromium/src/ui/webui/resources/images/business.svg)
94 to tell users that the setting is enforced by the administrator.
Owen Min9bdd16fe2023-08-18 14:59:2395 - There are more information and util functions can be found [here](https://source.chromium.org/chromium/chromium/src/+/main:ui/webui/resources/cr_elements/policy/).
Shuran Huang0ac3d402022-10-25 18:07:21968. Support `dynamic_refresh` if possible.
Owen Minf2127ad02019-12-17 19:59:4997 - We strongly encourage developers to make their policies support this
Jana Grill5fb69562020-03-09 15:01:1198 attribute. It means the admin can change the policy value and Chrome
99 will honor the change at run-time without requiring a restart of the
Andrey Davydov32462d762022-07-15 08:48:30100 browser. ChromeOS does not always support non-dynamic profile policies.
101 Please verify with a ChromeOS policy owner if your profile policy does
102 not support dynamic refresh on ChromeOS.
Jana Grill5fb69562020-03-09 15:01:11103 - Most of the time, this requires a
Owen Minf2127ad02019-12-17 19:59:49104 [PrefChangeRegistrar](https://cs.chromium.org/chromium/src/components/prefs/pref_change_registrar.h)
Jana Grill5fb69562020-03-09 15:01:11105 to listen to the preference change notification and update UI or
106 browser behavior right away.
Shuran Huang0ac3d402022-10-25 18:07:211079. Adding a device policy for ChromeOS.
Jana Grill5fb69562020-03-09 15:01:11108 - Most policies that are used by the browser can be shared between desktop
Andrey Davydov32462d762022-07-15 08:48:30109 and ChromeOS. However, you need a few additional steps for a device
110 policy on ChromeOS.
Sparik Hayrapetyan5041f8d2023-09-26 09:49:43111 - Add a field for your policy in
Owen Minf2127ad02019-12-17 19:59:49112 `components/policy/proto/chrome_device_policy.proto`. Please note
113 that all proto fields are optional.
114 - Update
Yeunjoo Choi42f18f82021-07-26 02:18:10115 `chrome/browser/ash/policy/core/device_policy_decoder.{h,cc}`
Owen Minf2127ad02019-12-17 19:59:49116 for the new policy.
Ted Brandston00a7e112023-09-14 13:52:4611710. Test the policy.
Owen Minf2127ad02019-12-17 19:59:49118 - Add a test to verify the policy. You can add a test in
119 `chrome/browser/policy/<area>_policy_browsertest.cc` or with the policy
120 implementation. For example, a network policy test can be put into
121 `chrome/browser/net`. Ideally, your test would set the policy, fire up
122 the browser, and interact with the browser just as a user would do to
123 check whether the policy takes effect.
Ted Brandston00a7e112023-09-14 13:52:4612411. Manually testing your policy.
Owen Min75fc6652025-01-27 17:23:57125 - This [Internal Doc](go/chrome-with-policies) contains the most up to date
126 instructions for testing policies. However, the following docs are
127 still useful as public references.
Owen Min326f43e2019-11-13 16:08:30128 - Windows: The simplest way to test is to write the registry keys manually
129 to `Software\Policies\Chromium` (for Chromium builds) or
130 `Software\Policies\Google\Chrome` (for Google Chrome branded builds). If
131 you want to test policy refresh, you need to use group policy tools and
132 gpupdate; see
133 [Windows Quick Start](https://www.chromium.org/administrators/windows-quick-start).
134 - Mac: See
135 [Mac Quick Start](https://www.chromium.org/administrators/mac-quick-start)
136 (section "Debugging")
137 - Linux: See
138 [Linux Quick Start](https://www.chromium.org/administrators/linux-quick-start)
139 (section "Set Up Policies")
Andrey Davydov32462d762022-07-15 08:48:30140 - ChromeOS and Android are more complex to test, as a full end-to-end
Owen Min326f43e2019-11-13 16:08:30141 test requires network transactions to the policy test server.
Jana Grill5fb69562020-03-09 15:01:11142 Instructions on how to set up the policy test server and have the
Owen Min326f43e2019-11-13 16:08:30143 browser talk to it are here:
144 [Running the cloud policy test server](https://www.chromium.org/developers/how-tos/enterprise/running-the-cloud-policy-test-server).
Andrey Davydov32462d762022-07-15 08:48:30145 If you'd just like to do a quick test for ChromeOS, the Linux code is
Owen Min326f43e2019-11-13 16:08:30146 also functional on CrOS, see
147 [Linux Quick Start](https://www.chromium.org/administrators/linux-quick-start).
Ted Brandston00a7e112023-09-14 13:52:4614812. If you are adding a new policy that supersedes an older one, verify that the
Owen Min75fc6652025-01-27 17:23:57149 new policy works as expected even if the old policy is set. And if the new
150 policy has any interactions with the other policies, make sure to document
151 and test all the possible combinations.
Owen Min326f43e2019-11-13 16:08:30152
Owen Min75fc6652025-01-27 17:23:57153## Policy Launch, modification and deprecation
Owen Min5d685ceb2020-06-22 23:31:43154
Owen Min75fc6652025-01-27 17:23:57155Please read [life of a policy](./life_of_a_policy.md) for more information.
Chris Sharp4a429b02020-08-04 15:57:22156
Owen Min326f43e2019-11-13 16:08:30157## Examples
158
Julian Pastarmov7c5b6a052022-11-15 14:50:29159- Here is an example for adding a new policy. It's a good, simple place to
160 get started:
161 [https://chromium-review.googlesource.com/c/chromium/src/+/4004453](https://chromium-review.googlesource.com/c/chromium/src/+/4004453)
162- This is an example for the clean-up CL needed to remove a deprecated, escape
Owen Min75fc6652025-01-27 17:23:57163 hatch policy.
164 [https://chromium-review.googlesource.com/c/chromium/src/+/5483886](https://chromium-review.googlesource.com/c/chromium/src/+/5483886)
Julian Pastarmov7c5b6a052022-11-15 14:50:29165- This is an example of a CL that sets the expiration date of a policy in a
166 future milestone:
167 [https://chromium-review.googlesource.com/c/chromium/src/+/4022055](https://chromium-review.googlesource.com/c/chromium/src/+/4022055)
Owen Min326f43e2019-11-13 16:08:30168
Owen Mine6533d72019-12-19 03:55:21169## Cloud Policy
170
Jana Grill5fb69562020-03-09 15:01:11171**For Googlers only**: The Cloud Policy will be maintained by the Admin console
172team.
173[See instructions here](https://docs.google.com/document/d/1QgDTWISgOE8DVwQSSz8x5oKrI3O_qAvOmPryE5DQPcw/edit?usp=sharing)
174on how to update the Cloud Policy.
Owen Mine6533d72019-12-19 03:55:21175
Owen Minf2127ad02019-12-17 19:59:49176## Post policy update
Owen Min326f43e2019-11-13 16:08:30177
Jana Grill5fb69562020-03-09 15:01:11178Once the policy is added or modified, nothing else needs to be taken
179care of by the Chromium developers. However, there are a few things that will be
Owen Min75fc6652025-01-27 17:23:57180updated based on the yaml file. Please note that there is no ETA for
Owen Minf2127ad02019-12-17 19:59:49181everything listed below.
Owen Min326f43e2019-11-13 16:08:30182
Owen Minf2127ad02019-12-17 19:59:49183* [Policy templates](https://dl.google.com/dl/edgedl/chrome/policy/policy_templates.zip)
184 will be updated automatically.
185* [Policy documentation](https://cloud.google.com/docs/chrome-enterprise/policies/)
186 will be updated automatically.
Owen Min326f43e2019-11-13 16:08:30187
Owen Minf2127ad02019-12-17 19:59:49188------
Owen Min326f43e2019-11-13 16:08:30189
Owen Minf2127ad02019-12-17 19:59:49190### Additional Notes
Owen Min326f43e2019-11-13 16:08:30191
Yann Dago90b71322022-10-19 20:56:281921. The `future_on` flag can disable policy on Beta of Stable channel only if the
Owen Min5d685ceb2020-06-22 23:31:43193 policy value is copied to `PrefService` in Step 3 of **Adding a new policy**.