Owen Min | 326f43e | 2019-11-13 16:08:30 | [diff] [blame] | 1 | # Policy Settings in Chrome |
| 2 | |
Owen Min | f2127ad0 | 2019-12-17 19:59:49 | [diff] [blame] | 3 | ## Summary |
Owen Min | 326f43e | 2019-11-13 16:08:30 | [diff] [blame] | 4 | |
Owen Min | f2127ad0 | 2019-12-17 19:59:49 | [diff] [blame] | 5 | Chrome exposes a different set of configurations to administrators. These |
| 6 | configurations are called policy and they give administrators more advanced |
| 7 | controls than the normal users. With different device management tools, |
Owen Min | 650834a | 2023-06-12 13:08:37 | [diff] [blame] | 8 | an administrator can deliver these policies to many users. Here is the |
Owen Min | f2127ad0 | 2019-12-17 19:59:49 | [diff] [blame] | 9 | [help center article](https://support.google.com/chrome/a/answer/9037717?hl=en) |
| 10 | that talks about Chrome policy and its deployment. |
Owen Min | 326f43e | 2019-11-13 16:08:30 | [diff] [blame] | 11 | |
Owen Min | f2127ad0 | 2019-12-17 19:59:49 | [diff] [blame] | 12 | ## Do I need a policy |
Owen Min | 326f43e | 2019-11-13 16:08:30 | [diff] [blame] | 13 | |
Owen Min | f2127ad0 | 2019-12-17 19:59:49 | [diff] [blame] | 14 | Usually 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 Grill | 5fb6956 | 2020-03-09 15:01:11 | [diff] [blame] | 19 | - Deprecating an old feature. Create a policy to give enterprise users more |
| 20 | time to migrate away from the feature. |
Owen Min | f2127ad0 | 2019-12-17 19:59:49 | [diff] [blame] | 21 | |
Owen Min | 9bdd16fe | 2023-08-18 14:59:23 | [diff] [blame] | 22 | **To read more about best practices for shipping enterprise friendly features, |
| 23 | please read [this article](https://www.chromium.org/developers/enterprise-changes/).** |
| 24 | |
Owen Min | f2127ad0 | 2019-12-17 19:59:49 | [diff] [blame] | 25 | ## Adding a new policy |
Owen Min | 326f43e | 2019-11-13 16:08:30 | [diff] [blame] | 26 | |
Owen Min | 75fc665 | 2025-01-27 17:23:57 | [diff] [blame] | 27 | 1. 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 Dago | cd66a34 | 2022-10-31 15:23:45 | [diff] [blame] | 32 | 2. Declare the policy in the [policies.yaml](https://cs.chromium.org/chromium/src/components/policy/resources/templates/policies.yaml) file. |
Yann Dago | 90b7132 | 2022-10-19 20:56:28 | [diff] [blame] | 33 | - This file contains the policy names and their ids. |
| 34 | 3. If you need to add a new policy group, create a directory with the name of |
Yann Dago | cd66a34 | 2022-10-31 15:23:45 | [diff] [blame] | 35 | that group under [policy group](https://cs.chromium.org/chromium/src/components/policy/resources/templates/policy_definitions/). |
Yann Dago | 90b7132 | 2022-10-19 20:56:28 | [diff] [blame] | 36 | - 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 Dago | cd66a34 | 2022-10-31 15:23:45 | [diff] [blame] | 40 | - Use [.group.details.yaml](https://cs.chromium.org/chromium/src/components/policy/resources/new_policy_templates/.group.details.yaml) |
Yann Dago | 90b7132 | 2022-10-19 20:56:28 | [diff] [blame] | 41 | as a templates for group definition. |
Yann Dago | cd66a34 | 2022-10-31 15:23:45 | [diff] [blame] | 42 | 4. Create a file named `PolicyName.yaml` under the appropriate [policy group](https://cs.chromium.org/chromium/src/components/policy/resources/templates/policy_definitions/). |
Owen Min | 75fc665 | 2025-01-27 17:23:57 | [diff] [blame] | 43 | Please use [policy.yaml](https://cs.chromium.org/chromium/src/components/policy/resources/new_policy_templates/policy.yaml) to start off your policy. |
Owen Min | f2127ad0 | 2019-12-17 19:59:49 | [diff] [blame] | 44 | - This file contains meta-level descriptions of all policies and is used |
Owen Min | 75fc665 | 2025-01-27 17:23:57 | [diff] [blame] | 45 | 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). |
Johann | 48fbca9 | 2021-07-16 18:29:41 | [diff] [blame] | 49 | - See [description_guidelines.md](description_guidelines.md) |
Chris Sharp | 0f7626d | 2020-07-27 21:48:16 | [diff] [blame] | 50 | for additional guidelines when creating a description, including how |
| 51 | various products should be referenced. |
Owen Min | 75fc665 | 2025-01-27 17:23:57 | [diff] [blame] | 52 | - Optional fields can be skipped when they are set to the default value. |
Shuran Huang | 0ac3d40 | 2022-10-25 18:07:21 | [diff] [blame] | 53 | 5. Create a policy atomic group. |
| 54 | - If you are adding multiple policies that are closely related and interact |
Yann Dago | 90b7132 | 2022-10-19 20:56:28 | [diff] [blame] | 55 | 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 Dago | cd66a34 | 2022-10-31 15:23:45 | [diff] [blame] | 62 | - Declare the atomic group in the [policies.yaml](https://cs.chromium.org/chromium/src/components/policy/resources/templates/policies.yaml) file. |
Yann Dago | 90b7132 | 2022-10-19 20:56:28 | [diff] [blame] | 63 | - Create a `policy_atomic_groups.yaml` file in the group where you added the |
| 64 | policies if it does not already exist. |
Jonathan Hao | c669fca | 2023-09-13 06:50:58 | [diff] [blame] | 65 | 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 Huang | 0ac3d40 | 2022-10-25 18:07:21 | [diff] [blame] | 66 | 6. Create a preference and map the policy value to it. |
Owen Min | f2127ad0 | 2019-12-17 19:59:49 | [diff] [blame] | 67 | - 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 Beck | b4025ba | 2023-03-17 16:40:06 | [diff] [blame] | 70 | 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 Grill | 5fb6956 | 2020-03-09 15:01:11 | [diff] [blame] | 76 | 2. Most policies can be mapped to prefs with `kSimplePolicyMap` in |
Salma Elmahallawy | 1953a0f | 2024-10-30 15:28:15 | [diff] [blame] | 77 | [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 Min | f2127ad0 | 2019-12-17 19:59:49 | [diff] [blame] | 78 | implement a `ConfigurationPolicyHandler` to do so. |
Yann Dago | 5f65205c1 | 2023-10-31 14:53:09 | [diff] [blame] | 79 | 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 Min | 90926fc | 2020-04-23 15:12:04 | [diff] [blame] | 81 | 4. iOS platform has its own |
Scott Yoder | 1773eaf | 2025-04-10 12:36:56 | [diff] [blame] | 82 | [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 Min | 90926fc | 2020-04-23 15:12:04 | [diff] [blame] | 83 | and |
Yann Dago | 5f65205c1 | 2023-10-31 14:53:09 | [diff] [blame] | 84 | [policy/pref_mapping](https://source.chromium.org/chromium/chromium/src/+/main:ios/chrome/test/data/policy/pref_mapping) |
Owen Min | 90926fc | 2020-04-23 15:12:04 | [diff] [blame] | 85 | file. |
Shuran Huang | 0ac3d40 | 2022-10-25 18:07:21 | [diff] [blame] | 86 | 7. Disable the user setting UI when the policy is applied. |
Owen Min | f2127ad0 | 2019-12-17 19:59:49 | [diff] [blame] | 87 | - 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 Min | 9bdd16fe | 2023-08-18 14:59:23 | [diff] [blame] | 95 | - 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 Huang | 0ac3d40 | 2022-10-25 18:07:21 | [diff] [blame] | 96 | 8. Support `dynamic_refresh` if possible. |
Owen Min | f2127ad0 | 2019-12-17 19:59:49 | [diff] [blame] | 97 | - We strongly encourage developers to make their policies support this |
Jana Grill | 5fb6956 | 2020-03-09 15:01:11 | [diff] [blame] | 98 | 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 Davydov | 32462d76 | 2022-07-15 08:48:30 | [diff] [blame] | 100 | 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 Grill | 5fb6956 | 2020-03-09 15:01:11 | [diff] [blame] | 103 | - Most of the time, this requires a |
Owen Min | f2127ad0 | 2019-12-17 19:59:49 | [diff] [blame] | 104 | [PrefChangeRegistrar](https://cs.chromium.org/chromium/src/components/prefs/pref_change_registrar.h) |
Jana Grill | 5fb6956 | 2020-03-09 15:01:11 | [diff] [blame] | 105 | to listen to the preference change notification and update UI or |
| 106 | browser behavior right away. |
Shuran Huang | 0ac3d40 | 2022-10-25 18:07:21 | [diff] [blame] | 107 | 9. Adding a device policy for ChromeOS. |
Jana Grill | 5fb6956 | 2020-03-09 15:01:11 | [diff] [blame] | 108 | - Most policies that are used by the browser can be shared between desktop |
Andrey Davydov | 32462d76 | 2022-07-15 08:48:30 | [diff] [blame] | 109 | and ChromeOS. However, you need a few additional steps for a device |
| 110 | policy on ChromeOS. |
Sparik Hayrapetyan | 5041f8d | 2023-09-26 09:49:43 | [diff] [blame] | 111 | - Add a field for your policy in |
Owen Min | f2127ad0 | 2019-12-17 19:59:49 | [diff] [blame] | 112 | `components/policy/proto/chrome_device_policy.proto`. Please note |
| 113 | that all proto fields are optional. |
| 114 | - Update |
Yeunjoo Choi | 42f18f8 | 2021-07-26 02:18:10 | [diff] [blame] | 115 | `chrome/browser/ash/policy/core/device_policy_decoder.{h,cc}` |
Owen Min | f2127ad0 | 2019-12-17 19:59:49 | [diff] [blame] | 116 | for the new policy. |
Ted Brandston | 00a7e11 | 2023-09-14 13:52:46 | [diff] [blame] | 117 | 10. Test the policy. |
Owen Min | f2127ad0 | 2019-12-17 19:59:49 | [diff] [blame] | 118 | - 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 Brandston | 00a7e11 | 2023-09-14 13:52:46 | [diff] [blame] | 124 | 11. Manually testing your policy. |
Owen Min | 75fc665 | 2025-01-27 17:23:57 | [diff] [blame] | 125 | - 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 Min | 326f43e | 2019-11-13 16:08:30 | [diff] [blame] | 128 | - 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 Davydov | 32462d76 | 2022-07-15 08:48:30 | [diff] [blame] | 140 | - ChromeOS and Android are more complex to test, as a full end-to-end |
Owen Min | 326f43e | 2019-11-13 16:08:30 | [diff] [blame] | 141 | test requires network transactions to the policy test server. |
Jana Grill | 5fb6956 | 2020-03-09 15:01:11 | [diff] [blame] | 142 | Instructions on how to set up the policy test server and have the |
Owen Min | 326f43e | 2019-11-13 16:08:30 | [diff] [blame] | 143 | 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 Davydov | 32462d76 | 2022-07-15 08:48:30 | [diff] [blame] | 145 | If you'd just like to do a quick test for ChromeOS, the Linux code is |
Owen Min | 326f43e | 2019-11-13 16:08:30 | [diff] [blame] | 146 | also functional on CrOS, see |
| 147 | [Linux Quick Start](https://www.chromium.org/administrators/linux-quick-start). |
Ted Brandston | 00a7e11 | 2023-09-14 13:52:46 | [diff] [blame] | 148 | 12. If you are adding a new policy that supersedes an older one, verify that the |
Owen Min | 75fc665 | 2025-01-27 17:23:57 | [diff] [blame] | 149 | 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 Min | 326f43e | 2019-11-13 16:08:30 | [diff] [blame] | 152 | |
Owen Min | 75fc665 | 2025-01-27 17:23:57 | [diff] [blame] | 153 | ## Policy Launch, modification and deprecation |
Owen Min | 5d685ceb | 2020-06-22 23:31:43 | [diff] [blame] | 154 | |
Owen Min | 75fc665 | 2025-01-27 17:23:57 | [diff] [blame] | 155 | Please read [life of a policy](./life_of_a_policy.md) for more information. |
Chris Sharp | 4a429b0 | 2020-08-04 15:57:22 | [diff] [blame] | 156 | |
Owen Min | 326f43e | 2019-11-13 16:08:30 | [diff] [blame] | 157 | ## Examples |
| 158 | |
Julian Pastarmov | 7c5b6a05 | 2022-11-15 14:50:29 | [diff] [blame] | 159 | - 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 Min | 75fc665 | 2025-01-27 17:23:57 | [diff] [blame] | 163 | hatch policy. |
| 164 | [https://chromium-review.googlesource.com/c/chromium/src/+/5483886](https://chromium-review.googlesource.com/c/chromium/src/+/5483886) |
Julian Pastarmov | 7c5b6a05 | 2022-11-15 14:50:29 | [diff] [blame] | 165 | - 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 Min | 326f43e | 2019-11-13 16:08:30 | [diff] [blame] | 168 | |
Owen Min | e6533d7 | 2019-12-19 03:55:21 | [diff] [blame] | 169 | ## Cloud Policy |
| 170 | |
Jana Grill | 5fb6956 | 2020-03-09 15:01:11 | [diff] [blame] | 171 | **For Googlers only**: The Cloud Policy will be maintained by the Admin console |
| 172 | team. |
| 173 | [See instructions here](https://docs.google.com/document/d/1QgDTWISgOE8DVwQSSz8x5oKrI3O_qAvOmPryE5DQPcw/edit?usp=sharing) |
| 174 | on how to update the Cloud Policy. |
Owen Min | e6533d7 | 2019-12-19 03:55:21 | [diff] [blame] | 175 | |
Owen Min | f2127ad0 | 2019-12-17 19:59:49 | [diff] [blame] | 176 | ## Post policy update |
Owen Min | 326f43e | 2019-11-13 16:08:30 | [diff] [blame] | 177 | |
Jana Grill | 5fb6956 | 2020-03-09 15:01:11 | [diff] [blame] | 178 | Once the policy is added or modified, nothing else needs to be taken |
| 179 | care of by the Chromium developers. However, there are a few things that will be |
Owen Min | 75fc665 | 2025-01-27 17:23:57 | [diff] [blame] | 180 | updated based on the yaml file. Please note that there is no ETA for |
Owen Min | f2127ad0 | 2019-12-17 19:59:49 | [diff] [blame] | 181 | everything listed below. |
Owen Min | 326f43e | 2019-11-13 16:08:30 | [diff] [blame] | 182 | |
Owen Min | f2127ad0 | 2019-12-17 19:59:49 | [diff] [blame] | 183 | * [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 Min | 326f43e | 2019-11-13 16:08:30 | [diff] [blame] | 187 | |
Owen Min | f2127ad0 | 2019-12-17 19:59:49 | [diff] [blame] | 188 | ------ |
Owen Min | 326f43e | 2019-11-13 16:08:30 | [diff] [blame] | 189 | |
Owen Min | f2127ad0 | 2019-12-17 19:59:49 | [diff] [blame] | 190 | ### Additional Notes |
Owen Min | 326f43e | 2019-11-13 16:08:30 | [diff] [blame] | 191 | |
Yann Dago | 90b7132 | 2022-10-19 20:56:28 | [diff] [blame] | 192 | 1. The `future_on` flag can disable policy on Beta of Stable channel only if the |
Owen Min | 5d685ceb | 2020-06-22 23:31:43 | [diff] [blame] | 193 | policy value is copied to `PrefService` in Step 3 of **Adding a new policy**. |