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 | |
| 25 | **This article covers lots of technical details. More information about policy |
| 26 | design can be found at [policy_design.md](./policy_design.md).** |
Julian Pastarmov | 5aeefb9 | 2022-06-27 16:23:36 | [diff] [blame] | 27 | |
Owen Min | f2127ad0 | 2019-12-17 19:59:49 | [diff] [blame] | 28 | ## Adding a new policy |
Owen Min | 326f43e | 2019-11-13 16:08:30 | [diff] [blame] | 29 | |
| 30 | 1. Think carefully about the name and the desired semantics of the new policy: |
Jana Grill | 5fb6956 | 2020-03-09 15:01:11 | [diff] [blame] | 31 | - Choose a name that is consistent with the existing naming scheme. Prefer |
Owen Min | 326f43e | 2019-11-13 16:08:30 | [diff] [blame] | 32 | "XXXEnabled" over "EnableXXX" because the former is more glanceable and |
| 33 | sorts better. |
| 34 | - Consider the foreseeable future and try to avoid conflicts with possible |
| 35 | future extensions or use cases. |
| 36 | - Negative policies (*Disable*, *Disallow*) are verboten because setting |
| 37 | something to "true" to disable it confuses people. |
Yann Dago | cd66a34 | 2022-10-31 15:23:45 | [diff] [blame] | 38 | 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] | 39 | - This file contains the policy names and their ids. |
| 40 | 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] | 41 | 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] | 42 | - Inside the newly created directory, create a `.group.details.yaml` file |
| 43 | with the caption and description of the group. This group is used for |
| 44 | documentation and policy template generation, so it is recommended to |
| 45 | group policies in meaningful groups. |
Yann Dago | cd66a34 | 2022-10-31 15:23:45 | [diff] [blame] | 46 | - 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] | 47 | as a templates for group definition. |
Yann Dago | cd66a34 | 2022-10-31 15:23:45 | [diff] [blame] | 48 | 4. Create a file named `PolicyName.yaml` under the appropriate [policy group](https://cs.chromium.org/chromium/src/components/policy/resources/templates/policy_definitions/). |
| 49 | You may 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] | 50 | - This file contains meta-level descriptions of all policies and is used |
Jana Grill | 5fb6956 | 2020-03-09 15:01:11 | [diff] [blame] | 51 | to generate code, policy templates (ADM/ADMX for Windows and the |
| 52 | application manifest for Mac), as well as documentation. Please make |
| 53 | sure you get the version and feature flags (such as dynamic_refresh and |
Owen Min | f2127ad0 | 2019-12-17 19:59:49 | [diff] [blame] | 54 | supported_on) right. |
| 55 | - Here are the most used attributes. Please note that, all attributes |
Bohdan Tyshchenko | 80394f7 | 2022-06-08 20:34:03 | [diff] [blame] | 56 | below other than `supported_on`, `future_on` do not change the code |
| 57 | behavior. |
Owen Min | 5d685ceb | 2020-06-22 23:31:43 | [diff] [blame] | 58 | - `supported_on` and `future_on`: They control the platforms that the |
| 59 | policy supports. `supported_on` is used for released platforms with |
| 60 | milestone range while `future_on` is used for unreleased platforms. |
| 61 | See **Launch a policy** below for more information. |
Victor-Gabriel Savu | 42dcd42 | 2020-05-05 12:26:21 | [diff] [blame] | 62 | - `default_for_enterprise_users`: Its value is applied as a mandatory |
Bohdan Tyshchenko | 80394f7 | 2022-06-08 20:34:03 | [diff] [blame] | 63 | (unless `default_policy_level` is set) policy for managed users on |
Andrey Davydov | 32462d76 | 2022-07-15 08:48:30 | [diff] [blame] | 64 | ChromeOS unless a different setting is explicitly set. |
Bohdan Tyshchenko | 80394f7 | 2022-06-08 20:34:03 | [diff] [blame] | 65 | - `default_policy_level`: If set to "recommended" the |
| 66 | `default_for_enterprise_users` is applied as a recommended policy. |
Jana Grill | 5fb6956 | 2020-03-09 15:01:11 | [diff] [blame] | 67 | - `dynamic_refresh`: It tells the admin whether the policy value can |
| 68 | be changed and take effect without re-launching Chrome. |
| 69 | - `per_profile`: It tells the admin whether different policy values |
| 70 | can be assigned to different profiles. |
| 71 | - `can_be_recommended`: It tells the admin whether they can mark the |
| 72 | policy as recommended and allow the user to override it in the UI, |
| 73 | using a command line switch or an extension. |
Owen Min | f2127ad0 | 2019-12-17 19:59:49 | [diff] [blame] | 74 | - The complete list of attributes and their expected values can be found in |
Yann Dago | cd66a34 | 2022-10-31 15:23:45 | [diff] [blame] | 75 | the [policy.yaml](https://cs.chromium.org/chromium/src/components/policy/resources/new_policy_templates/policy.yaml) file. |
Owen Min | f2127ad0 | 2019-12-17 19:59:49 | [diff] [blame] | 76 | - The textual policy description should include the following: |
Owen Min | 326f43e | 2019-11-13 16:08:30 | [diff] [blame] | 77 | - What features of Chrome are affected. |
| 78 | - Which behavior and/or UI/UX changes the policy triggers. |
| 79 | - How the policy behaves if it's left unset or set to invalid/default |
| 80 | values. This may seem obvious to you, and it probably is. However, |
| 81 | this information seems to be provided for Windows Group Policy |
| 82 | traditionally, and we've seen requests from organizations to |
| 83 | explicitly spell out the behavior for all possible values and for |
| 84 | when the policy is unset. |
Johann | 48fbca9 | 2021-07-16 18:29:41 | [diff] [blame] | 85 | - See [description_guidelines.md](description_guidelines.md) |
Chris Sharp | 0f7626d | 2020-07-27 21:48:16 | [diff] [blame] | 86 | for additional guidelines when creating a description, including how |
| 87 | various products should be referenced. |
Shuran Huang | 0ac3d40 | 2022-10-25 18:07:21 | [diff] [blame] | 88 | 5. Create a policy atomic group. |
| 89 | - If you are adding multiple policies that are closely related and interact |
Yann Dago | 90b7132 | 2022-10-19 20:56:28 | [diff] [blame] | 90 | with each other, you should put them in policy atomic group. An atomic |
| 91 | policy group is used in the Chromium code and affects how policies are |
| 92 | applied. When enabled by the admin, this ensures that policies from an |
| 93 | atomic group get their values from the same source and are not a mix of |
| 94 | policies from multiple sources. This [feature](https://chromeenterprise.google/intl/en_ca/policies/atomic-groups/) |
| 95 | is controlled by the policy [PolicyAtomicGroupsEnabled](https://chromeenterprise.google/intl/en_ca/policies/#PolicyAtomicGroupsEnabled). |
| 96 | |
Yann Dago | cd66a34 | 2022-10-31 15:23:45 | [diff] [blame] | 97 | - 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] | 98 | - Create a `policy_atomic_groups.yaml` file in the group where you added the |
| 99 | policies if it does not already exist. |
Jonathan Hao | c669fca | 2023-09-13 06:50:58 | [diff] [blame^] | 100 | 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] | 101 | 6. Create a preference and map the policy value to it. |
Owen Min | f2127ad0 | 2019-12-17 19:59:49 | [diff] [blame] | 102 | - All policy values need to be mapped into a prefs value before being used |
| 103 | unless the policy is needed before PrefService initialization. |
| 104 | - To map the policy: |
Bob Beck | b4025ba | 2023-03-17 16:40:06 | [diff] [blame] | 105 | 1. [Create a prefs and register the prefs in **Local State** or |
| 106 | **Profile Prefs**.](../../chrome/browser/prefs/README.md) |
| 107 | Please note that, this must match the `per_profile` attribute in the |
| 108 | `YourPolicyName.yaml`. We also strongly encourage developers to |
| 109 | register the prefs with **Profile Prefs** if possible, because |
| 110 | this gives admin more flexibility of policy setup. |
Jana Grill | 5fb6956 | 2020-03-09 15:01:11 | [diff] [blame] | 111 | 2. Most policies can be mapped to prefs with `kSimplePolicyMap` in |
Owen Min | f2127ad0 | 2019-12-17 19:59:49 | [diff] [blame] | 112 | [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). |
| 113 | If the policy needs additional verification or processing, please |
| 114 | implement a `ConfigurationPolicyHandler` to do so. |
| 115 | 3. Test the mapping by adding policy to |
Roman Sorokin | bc15cfa | 2023-02-27 01:08:37 | [diff] [blame] | 116 | [policy_test_cases.json](https://cs.chromium.org/chromium/src/components/policy/test/data/policy_test_cases.json?q=policy_test_case) (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] | 117 | 4. iOS platform has its own |
John Palmer | 046f987 | 2021-05-24 01:24:56 | [diff] [blame] | 118 | [configuration_policy_handler_list_factory.mm](https://source.chromium.org/chromium/chromium/src/+/main:ios/chrome/browser/policy/configuration_policy_handler_list_factory.mm) |
Owen Min | 90926fc | 2020-04-23 15:12:04 | [diff] [blame] | 119 | and |
John Palmer | 046f987 | 2021-05-24 01:24:56 | [diff] [blame] | 120 | [policy_test_cases.json](https://source.chromium.org/chromium/chromium/src/+/main:ios/chrome/test/data/policy/policy_test_cases.json) |
Owen Min | 90926fc | 2020-04-23 15:12:04 | [diff] [blame] | 121 | file. |
Shuran Huang | 0ac3d40 | 2022-10-25 18:07:21 | [diff] [blame] | 122 | 7. Disable the user setting UI when the policy is applied. |
Owen Min | f2127ad0 | 2019-12-17 19:59:49 | [diff] [blame] | 123 | - If your feature can be controlled by GUI in `chrome://settings`, the |
| 124 | associated option should be disabled when the policy controlling it is |
| 125 | managed. |
| 126 | - `PrefService:Preference::IsManaged` reveals whether a prefs value |
| 127 | comes from policy or not. |
| 128 | - The setting needs an |
| 129 | [indicator](https://cs.chromium.org/chromium/src/ui/webui/resources/images/business.svg) |
| 130 | to tell users that the setting is enforced by the administrator. |
Owen Min | 9bdd16fe | 2023-08-18 14:59:23 | [diff] [blame] | 131 | - 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] | 132 | 8. Support `dynamic_refresh` if possible. |
Owen Min | f2127ad0 | 2019-12-17 19:59:49 | [diff] [blame] | 133 | - We strongly encourage developers to make their policies support this |
Jana Grill | 5fb6956 | 2020-03-09 15:01:11 | [diff] [blame] | 134 | attribute. It means the admin can change the policy value and Chrome |
| 135 | will honor the change at run-time without requiring a restart of the |
Andrey Davydov | 32462d76 | 2022-07-15 08:48:30 | [diff] [blame] | 136 | browser. ChromeOS does not always support non-dynamic profile policies. |
| 137 | Please verify with a ChromeOS policy owner if your profile policy does |
| 138 | not support dynamic refresh on ChromeOS. |
Jana Grill | 5fb6956 | 2020-03-09 15:01:11 | [diff] [blame] | 139 | - Most of the time, this requires a |
Owen Min | f2127ad0 | 2019-12-17 19:59:49 | [diff] [blame] | 140 | [PrefChangeRegistrar](https://cs.chromium.org/chromium/src/components/prefs/pref_change_registrar.h) |
Jana Grill | 5fb6956 | 2020-03-09 15:01:11 | [diff] [blame] | 141 | to listen to the preference change notification and update UI or |
| 142 | browser behavior right away. |
Shuran Huang | 0ac3d40 | 2022-10-25 18:07:21 | [diff] [blame] | 143 | 9. Adding a device policy for ChromeOS. |
Jana Grill | 5fb6956 | 2020-03-09 15:01:11 | [diff] [blame] | 144 | - Most policies that are used by the browser can be shared between desktop |
Andrey Davydov | 32462d76 | 2022-07-15 08:48:30 | [diff] [blame] | 145 | and ChromeOS. However, you need a few additional steps for a device |
| 146 | policy on ChromeOS. |
Owen Min | f2127ad0 | 2019-12-17 19:59:49 | [diff] [blame] | 147 | - Add a message for your policy in |
| 148 | `components/policy/proto/chrome_device_policy.proto`. Please note |
| 149 | that all proto fields are optional. |
| 150 | - Update |
Yeunjoo Choi | 42f18f8 | 2021-07-26 02:18:10 | [diff] [blame] | 151 | `chrome/browser/ash/policy/core/device_policy_decoder.{h,cc}` |
Owen Min | f2127ad0 | 2019-12-17 19:59:49 | [diff] [blame] | 152 | for the new policy. |
Shuran Huang | 0ac3d40 | 2022-10-25 18:07:21 | [diff] [blame] | 153 | 10. Test the policy. |
Owen Min | f2127ad0 | 2019-12-17 19:59:49 | [diff] [blame] | 154 | - Add a test to verify the policy. You can add a test in |
| 155 | `chrome/browser/policy/<area>_policy_browsertest.cc` or with the policy |
| 156 | implementation. For example, a network policy test can be put into |
| 157 | `chrome/browser/net`. Ideally, your test would set the policy, fire up |
| 158 | the browser, and interact with the browser just as a user would do to |
| 159 | check whether the policy takes effect. |
Shuran Huang | 0ac3d40 | 2022-10-25 18:07:21 | [diff] [blame] | 160 | 11. Manually testing your policy. |
Owen Min | 326f43e | 2019-11-13 16:08:30 | [diff] [blame] | 161 | - Windows: The simplest way to test is to write the registry keys manually |
| 162 | to `Software\Policies\Chromium` (for Chromium builds) or |
| 163 | `Software\Policies\Google\Chrome` (for Google Chrome branded builds). If |
| 164 | you want to test policy refresh, you need to use group policy tools and |
| 165 | gpupdate; see |
| 166 | [Windows Quick Start](https://www.chromium.org/administrators/windows-quick-start). |
| 167 | - Mac: See |
| 168 | [Mac Quick Start](https://www.chromium.org/administrators/mac-quick-start) |
| 169 | (section "Debugging") |
| 170 | - Linux: See |
| 171 | [Linux Quick Start](https://www.chromium.org/administrators/linux-quick-start) |
| 172 | (section "Set Up Policies") |
Andrey Davydov | 32462d76 | 2022-07-15 08:48:30 | [diff] [blame] | 173 | - 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] | 174 | test requires network transactions to the policy test server. |
Jana Grill | 5fb6956 | 2020-03-09 15:01:11 | [diff] [blame] | 175 | Instructions on how to set up the policy test server and have the |
Owen Min | 326f43e | 2019-11-13 16:08:30 | [diff] [blame] | 176 | browser talk to it are here: |
| 177 | [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] | 178 | 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] | 179 | also functional on CrOS, see |
| 180 | [Linux Quick Start](https://www.chromium.org/administrators/linux-quick-start). |
Shuran Huang | 0ac3d40 | 2022-10-25 18:07:21 | [diff] [blame] | 181 | 12. If you are adding a new policy that supersedes an older one, verify that the |
Owen Min | 326f43e | 2019-11-13 16:08:30 | [diff] [blame] | 182 | new policy works as expected even if the old policy is set (allowing us to |
| 183 | set both during the transition time when Chrome versions honoring the old |
| 184 | and the new policies coexist). |
Shuran Huang | 0ac3d40 | 2022-10-25 18:07:21 | [diff] [blame] | 185 | 13. If your policy has interactions with other policies, make sure to document, |
Owen Min | 326f43e | 2019-11-13 16:08:30 | [diff] [blame] | 186 | test and cover these by automated tests. |
| 187 | |
Owen Min | 5d685ceb | 2020-06-22 23:31:43 | [diff] [blame] | 188 | ## Launch a policy |
| 189 | 1. When adding a new policy, put the platforms it will be supported in the |
| 190 | `future_on` list. |
| 191 | - The policy is hidden from any auto-generated template or documentation on |
| 192 | those platforms. |
| 193 | - The policy will also be unavailable on Beta and Stable channel unless it's |
| 194 | enabled specifically by |
| 195 | [EnableExperimentalPolicies](https://cloud.google.com/docs/chrome-enterprise/policies/?policy=EnableExperimentalPolicies) |
| 196 | policy. |
| 197 | 2. Implement the policy, get launch approval if necessary. |
| 198 | 3. If the policy needs to be tested with small set of users first, keep the |
| 199 | platforms in the `future_on` list and running the tester program with the |
| 200 | [EnableExperimentalPolicies](https://cloud.google.com/docs/chrome-enterprise/policies/?policy=EnableExperimentalPolicies) |
| 201 | policy. |
| 202 | 4. Move the launched platforms from `future_on` to `supported_on` and set the |
| 203 | 'since_version' of those platforms to the milestone for which the launch |
| 204 | approval was granted. |
| 205 | 5. If the 'since_version' is set to a earlier milestone, you need to merge |
| 206 | back all necessary commits. |
| 207 | |
Andreea Costinas | d9b4dac | 2022-11-10 09:09:19 | [diff] [blame] | 208 | ### Kill switch |
Owen Min | 5d685ceb | 2020-06-22 23:31:43 | [diff] [blame] | 209 | |
Andreea Costinas | d9b4dac | 2022-11-10 09:09:19 | [diff] [blame] | 210 | New browser features guarded by policy should also be behind a Finch based |
| 211 | kill switch. This is a Finch configuration that allows to quickly disable a |
| 212 | feature. **Do not use normal Finch experimentation and rollout process to |
| 213 | control the policy launch process**. |
| 214 | |
| 215 | 1. Create a base::Feature flag. |
| 216 | 2. Add the new feature and new policy handling behind the flag check. |
| 217 | 3. After the feature launch, remove the flag (after 2-3 releases). In some |
| 218 | cases, you may want to wait for the next Long Term Stable (LTS) release before |
| 219 | removing the flag (see [go/chromeos-commercial-lts-chrome](http://go/chromeos-commercial-lts-chrome)). |
| 220 | |
| 221 | If you need to launch an emergency kill switch config due to a bug, |
| 222 | please contact your TPM and the release owner (see |
| 223 | [https://chromiumdash.appspot.com/schedule](https://chromiumdash.appspot.com/schedule)). |
| 224 | |
| 225 | For more information see [go/chrome-flag-guarding](http://go/chrome-flag-guarding) |
| 226 | (internal doc, Googlers only). |
| 227 | |
| 228 | Kill switches are not required for **ChromeOS-specific** features. |
Owen Min | 5d685ceb | 2020-06-22 23:31:43 | [diff] [blame] | 229 | |
Chris Sharp | 4a429b0 | 2020-08-04 15:57:22 | [diff] [blame] | 230 | ## Deprecating a policy |
| 231 | |
| 232 | A policy is deprecated when admins should stop using it. This is often because |
| 233 | a new policy was been released that should be used instead. |
| 234 | |
| 235 | When marking a policy as deprecated, it still needs to work the same as before |
| 236 | in Chrome. If you wish to remove the functionality, you'll need to changed the |
| 237 | supported_on field. See "Removing support for a policy" below for more details. |
| 238 | |
| 239 | ### Steps |
Yann Dago | 90b7132 | 2022-10-19 20:56:28 | [diff] [blame] | 240 | 1. Update `YourPolicyName.yaml`, marking the policy as deprecated and updating |
Chris Sharp | 4a429b0 | 2020-08-04 15:57:22 | [diff] [blame] | 241 | the description to describe when and why the policy as deprecated and what |
| 242 | admins should be doing instead. |
| 243 | 1. Update the policy handling code. This is generally ensuring that if the old |
| 244 | policy is set, the values are propagated to the new policies if they were |
| 245 | unset. |
| 246 | 1. Notify [email protected] to ensure this deprecation is |
| 247 | mentioned in the enterprise release notes. |
| 248 | |
| 249 | ## Removing support for a policy |
| 250 | |
| 251 | Generally speaking, policies shouldn't be removed from Chrome. Although they can |
| 252 | be deprecated fairly easily, removing support for a policy is a much bigger |
| 253 | issue, because admins might be relying on that functionality. |
| 254 | |
| 255 | The two main reasons for removing support for a policy are: |
| 256 | 1. It was a policy that was always documented as having a limited lifespan, |
| 257 | such as an escape hatch policy. |
| 258 | 1. The feature this policy impacts was removed from Chrome. |
| 259 | |
Yann Dago | 90b7132 | 2022-10-19 20:56:28 | [diff] [blame] | 260 | If the policy was never launched, `YourPolicyName.yaml` can be deleted and you may |
| 261 | replace the policy name in `policies.yaml` by an empty string. |
Chris Sharp | 4a429b0 | 2020-08-04 15:57:22 | [diff] [blame] | 262 | |
Owen Min | f18a1ae | 2021-07-06 20:30:17 | [diff] [blame] | 263 | If you want to remove support for another reason, please reach out to someone in |
Yann Dago | 90b7132 | 2022-10-19 20:56:28 | [diff] [blame] | 264 | [ENTERPRISE_POLICY_OWNERS](https://cs.chromium.org/chromium/src/components/policy/ENTERPRISE_POLICY_OWNERS) |
Chris Sharp | 4a429b0 | 2020-08-04 15:57:22 | [diff] [blame] | 265 | to ensure this is okay. The general preference is to leave policies as |
| 266 | deprecated, but still supported. |
| 267 | |
Julian Pastarmov | 7c5b6a05 | 2022-11-15 14:50:29 | [diff] [blame] | 268 | When removing support for a policy: |
| 269 | 1. Update `YourPolicyName.yaml` to mark the poilcy as no longer supported. |
| 270 | - Update `supported_on` to correctly list the last milestone the policy is |
| 271 | supported on. |
| 272 | - Set 'deprecated' to True if the policy skipped past the deprecation state. |
| 273 | 1. If the last milestone lies in the future file a bug to clean up the policy |
| 274 | supporting code as soon as the milestone has been reached. Set its next action |
| 275 | date to a date shortly after the expected branch date for that version. Add a |
| 276 | comment in the yaml file with the bug number for reference. |
| 277 | 1. Lastly after the last supported version has been branched: |
| 278 | - remove all the code that implements the policy behavior as shown in the |
| 279 | [Examples](#examples) section below after the milestone has been reached. |
| 280 | - Update the related test in the `policy_test_cases.json` by clearing the |
| 281 | the test for that policy. |
Chris Sharp | 4a429b0 | 2020-08-04 15:57:22 | [diff] [blame] | 282 | 1. Notify [email protected] to ensure this removal of support is |
| 283 | mentioned in the enterprise release notes. |
| 284 | |
Owen Min | 326f43e | 2019-11-13 16:08:30 | [diff] [blame] | 285 | ## Examples |
| 286 | |
Julian Pastarmov | 7c5b6a05 | 2022-11-15 14:50:29 | [diff] [blame] | 287 | - Here is an example for adding a new policy. It's a good, simple place to |
| 288 | get started: |
| 289 | [https://chromium-review.googlesource.com/c/chromium/src/+/4004453](https://chromium-review.googlesource.com/c/chromium/src/+/4004453) |
| 290 | - This is an example for the clean-up CL needed to remove a deprecated, escape |
| 291 | hatch policy. As mentioned in the section |
| 292 | [Removing support for a policy](#removing-support-for-a-policy). |
| 293 | [https://chromium-review.googlesource.com/c/chromium/src/+/3551442](https://chromium-review.googlesource.com/c/chromium/src/+/3551442) |
| 294 | (Note: The example above has been created prior to the policy_templates.json |
| 295 | to individual yaml files but it still shows clearly how to modify the policy |
| 296 | definition. We will update the document again as soon as we have a good clean |
| 297 | sample containing yaml file policy removal.) |
| 298 | - This is an example of a CL that sets the expiration date of a policy in a |
| 299 | future milestone: |
| 300 | [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] | 301 | |
| 302 | ## Modifying existing policies |
| 303 | |
| 304 | If you are planning to modify an existing policy, please send out a one-pager to |
| 305 | client- and server-side stakeholders explaining the planned change. |
| 306 | |
| 307 | There are a few noteworthy pitfalls that you should be aware of when updating |
Jana Grill | 5fb6956 | 2020-03-09 15:01:11 | [diff] [blame] | 308 | the code that handles existing policy settings, in particular: |
Owen Min | 326f43e | 2019-11-13 16:08:30 | [diff] [blame] | 309 | |
Jana Grill | 5fb6956 | 2020-03-09 15:01:11 | [diff] [blame] | 310 | - Make sure the policy metadata is up-to-date, in particular `supported_on`, and |
Owen Min | 326f43e | 2019-11-13 16:08:30 | [diff] [blame] | 311 | the feature flags. |
Owen Min | f2127ad0 | 2019-12-17 19:59:49 | [diff] [blame] | 312 | - In general, don't change policy semantics in a way that is incompatible |
Roman Sorokin | d9adffc | 2023-01-30 09:19:17 | [diff] [blame] | 313 | (as determined by user/admin-visible behavior) with previous semantics. |
| 314 | - **In particular, consider that existing policy deployments may affect** |
| 315 | **both old and new browser versions, and both should behave according to** |
| 316 | **the admin's intentions.** |
| 317 | - **Do not modify the behavior when the policy is not set**. To be more |
| 318 | specific: values `default`, `default_for_enterprise_users` and |
| 319 | `default_policy_level` must (likely) never change after the launch. Contact |
| 320 | [email protected] for guidance if you need to make such |
| 321 | changes. |
Owen Min | 326f43e | 2019-11-13 16:08:30 | [diff] [blame] | 322 | - **An important pitfall is that adding an additional allowed |
| 323 | value to an enum policy may cause compatibility issues.** Specifically, an |
| 324 | administrator may use the new policy value, which makes older Chrome versions |
Jana Grill | 5fb6956 | 2020-03-09 15:01:11 | [diff] [blame] | 325 | that may still be deployed (and don't understand the new value) fall back to |
Owen Min | 326f43e | 2019-11-13 16:08:30 | [diff] [blame] | 326 | the default behavior. Carefully consider if this is OK in your case. Usually, |
| 327 | it is preferred to create a new policy with the additional value and deprecate |
| 328 | the old one. |
| 329 | - Don't rely on the cloud policy server for policy migrations because |
| 330 | this has been proven to be error prone. To the extent possible, all |
| 331 | compatibility and migration code should be contained in the client. |
| 332 | - It is OK to expand semantics of policy values as long as the previous policy |
| 333 | description is compatible with the new behavior (see the "extending enum" |
| 334 | pitfall above however). |
| 335 | - It is OK to update feature implementations and the policy |
| 336 | description when Chrome changes as long as the intended effect of the policy |
| 337 | remains intact. |
| 338 | - The process for removing policies is to deprecate them first, |
| 339 | wait a few releases (if possible) and then drop support for them. Make sure you |
| 340 | put the deprecated flag if you deprecate a policy. |
| 341 | |
Tien Mai | ad5a9ab | 2019-11-28 16:02:35 | [diff] [blame] | 342 | ### Presubmit Checks when Modifying Existing Policies |
| 343 | |
| 344 | To enforce the above rules concerning policy modification and ensure no |
Jana Grill | 5fb6956 | 2020-03-09 15:01:11 | [diff] [blame] | 345 | backwards incompatible changes are introduced, presubmit checks |
| 346 | will be performed on every change to |
Yann Dago | cd66a34 | 2022-10-31 15:23:45 | [diff] [blame] | 347 | [templates](https://cs.chromium.org/chromium/src/components/policy/resources/templates/policy_definitions/). |
Tien Mai | ad5a9ab | 2019-11-28 16:02:35 | [diff] [blame] | 348 | |
| 349 | The presubmit checks perform the following verifications: |
| 350 | |
Jana Grill | 5fb6956 | 2020-03-09 15:01:11 | [diff] [blame] | 351 | 1. It verifies whether a policy is considered **unreleased** before allowing a |
| 352 | change. A policy is considered unreleased if **any** of the following |
Tien Mai | ad5a9ab | 2019-11-28 16:02:35 | [diff] [blame] | 353 | conditions are true: |
| 354 | |
Jana Grill | 5fb6956 | 2020-03-09 15:01:11 | [diff] [blame] | 355 | 1. It is an unchanged policy marked as `future: true`. |
Owen Min | f2127ad0 | 2019-12-17 19:59:49 | [diff] [blame] | 356 | 2. All the `supported_versions` of the policy satisfy **any** of the |
Tien Mai | ad5a9ab | 2019-11-28 16:02:35 | [diff] [blame] | 357 | following conditions |
| 358 | 1. The unchanged supported major version is >= the current major |
| 359 | version stored in the VERSION file at tip of tree. This covers the |
Jana Grill | 5fb6956 | 2020-03-09 15:01:11 | [diff] [blame] | 360 | case of a policy that has just recently been added, but has not yet |
Tien Mai | ad5a9ab | 2019-11-28 16:02:35 | [diff] [blame] | 361 | been released to a stable branch. |
| 362 | 2. The changed supported version == unchanged supported version + 1 and |
| 363 | the changed supported version is equal to the version stored in the |
| 364 | VERSION file at tip of tree. This check covers the case of |
Jana Grill | 5fb6956 | 2020-03-09 15:01:11 | [diff] [blame] | 365 | "unreleasing" a policy after a new stable branch has been cut, but |
Tien Mai | ad5a9ab | 2019-11-28 16:02:35 | [diff] [blame] | 366 | before a new stable release has rolled out. Normally such a change |
| 367 | should eventually be merged into the stable branch before the |
| 368 | release. |
Owen Min | 5d685ceb | 2020-06-22 23:31:43 | [diff] [blame] | 369 | 3. `supported_on` list is empty. |
Tien Mai | ad5a9ab | 2019-11-28 16:02:35 | [diff] [blame] | 370 | |
Jana Grill | 5fb6956 | 2020-03-09 15:01:11 | [diff] [blame] | 371 | 2. If the policy is considered **unreleased**, all changes to it are allowed. |
Tien Mai | ad5a9ab | 2019-11-28 16:02:35 | [diff] [blame] | 372 | |
Jana Grill | 5fb6956 | 2020-03-09 15:01:11 | [diff] [blame] | 373 | 3. However if the policy is released then the following verifications |
Tien Mai | ad5a9ab | 2019-11-28 16:02:35 | [diff] [blame] | 374 | are performed on the delta between the original policy and the changed |
| 375 | policy. |
| 376 | |
| 377 | 1. Released policies cannot be removed. |
Owen Min | f2127ad0 | 2019-12-17 19:59:49 | [diff] [blame] | 378 | 2. Released policies cannot have their type changed (e.g. from bool to |
Tien Mai | ad5a9ab | 2019-11-28 16:02:35 | [diff] [blame] | 379 | Enum). |
Owen Min | f2127ad0 | 2019-12-17 19:59:49 | [diff] [blame] | 380 | 3. Released policies cannot have the `future: true` flag added to it. This |
Tien Mai | ad5a9ab | 2019-11-28 16:02:35 | [diff] [blame] | 381 | flag can only be set on a new policy. |
Owen Min | f2127ad0 | 2019-12-17 19:59:49 | [diff] [blame] | 382 | 4. Released policies can only add additional `supported_on` versions. They |
Tien Mai | ad5a9ab | 2019-11-28 16:02:35 | [diff] [blame] | 383 | cannot remove or modify existing values for this field except for the |
| 384 | special case above for determining if a policy is released. Policy |
Owen Min | f2127ad0 | 2019-12-17 19:59:49 | [diff] [blame] | 385 | support end version (adding "-xx" ) can however be added to the |
Tien Mai | ad5a9ab | 2019-11-28 16:02:35 | [diff] [blame] | 386 | supported_on version to specify that a policy will no longer be |
Owen Min | f2127ad0 | 2019-12-17 19:59:49 | [diff] [blame] | 387 | supported going forward (as long as the initial `supported_on` version |
| 388 | is not changed). |
Tien Mai | ad5a9ab | 2019-11-28 16:02:35 | [diff] [blame] | 389 | 5. Released policies cannot be renamed (this is the equivalent of a |
Owen Min | f2127ad0 | 2019-12-17 19:59:49 | [diff] [blame] | 390 | delete + add). |
| 391 | 6. Released policies cannot change their `device_only` flag. This flag can |
Tien Mai | ad5a9ab | 2019-11-28 16:02:35 | [diff] [blame] | 392 | only be set on a new policy. |
| 393 | 7. Released policies with non dict types cannot have their schema changed. |
| 394 | 1. For enum types this means values cannot be renamed or removed (these |
| 395 | should be marked as deprecated instead). |
| 396 | 2. For int types, we will allow making the minimum and maximum values |
| 397 | less restrictive than the existing values. |
Owen Min | f2127ad0 | 2019-12-17 19:59:49 | [diff] [blame] | 398 | 3. For string types, we will allow the removal of the "pattern" |
Tien Mai | ad5a9ab | 2019-11-28 16:02:35 | [diff] [blame] | 399 | property to allow the validation to be less restrictive. |
| 400 | 4. We will allow addition to any list type values only at the end of |
| 401 | the list of values and not in the middle or at the beginning (this |
| 402 | restriction will cover the list of valid enum values as well). |
| 403 | 5. These same restrictions will apply recursively to all property |
| 404 | schema definitions listed in a dictionary type policy. |
Jana Grill | 5fb6956 | 2020-03-09 15:01:11 | [diff] [blame] | 405 | 8. Released dict policies cannot remove or modify any existing keys in |
Tien Mai | ad5a9ab | 2019-11-28 16:02:35 | [diff] [blame] | 406 | their schema. They can only add new keys to the schema. |
Owen Min | f2127ad0 | 2019-12-17 19:59:49 | [diff] [blame] | 407 | 1. Dictionary policies can have some of their "required" fields removed |
Tien Mai | ad5a9ab | 2019-11-28 16:02:35 | [diff] [blame] | 408 | in order to be less restrictive. |
| 409 | |
Owen Min | 5d685ceb | 2020-06-22 23:31:43 | [diff] [blame] | 410 | 4. A policy is **partially released** if both `supported_on` and |
| 411 | `future_on` list are not empty. |
| 412 | |
| 413 | 5. The **partially released** policy is considered as a **released** policy |
| 414 | and only the `future_on` list can be modified freely. However, any |
| 415 | platform in the `supported_on` list cannot be moved back to the `future_on` |
| 416 | list. |
| 417 | |
| 418 | |
Owen Min | e6533d7 | 2019-12-19 03:55:21 | [diff] [blame] | 419 | ## Cloud Policy |
| 420 | |
Jana Grill | 5fb6956 | 2020-03-09 15:01:11 | [diff] [blame] | 421 | **For Googlers only**: The Cloud Policy will be maintained by the Admin console |
| 422 | team. |
| 423 | [See instructions here](https://docs.google.com/document/d/1QgDTWISgOE8DVwQSSz8x5oKrI3O_qAvOmPryE5DQPcw/edit?usp=sharing) |
| 424 | on how to update the Cloud Policy. |
Owen Min | e6533d7 | 2019-12-19 03:55:21 | [diff] [blame] | 425 | |
Owen Min | f2127ad0 | 2019-12-17 19:59:49 | [diff] [blame] | 426 | ## Post policy update |
Owen Min | 326f43e | 2019-11-13 16:08:30 | [diff] [blame] | 427 | |
Jana Grill | 5fb6956 | 2020-03-09 15:01:11 | [diff] [blame] | 428 | Once the policy is added or modified, nothing else needs to be taken |
| 429 | care of by the Chromium developers. However, there are a few things that will be |
| 430 | updated based on the json file. Please note that there is no ETA for |
Owen Min | f2127ad0 | 2019-12-17 19:59:49 | [diff] [blame] | 431 | everything listed below. |
Owen Min | 326f43e | 2019-11-13 16:08:30 | [diff] [blame] | 432 | |
Owen Min | f2127ad0 | 2019-12-17 19:59:49 | [diff] [blame] | 433 | * [Policy templates](https://dl.google.com/dl/edgedl/chrome/policy/policy_templates.zip) |
| 434 | will be updated automatically. |
| 435 | * [Policy documentation](https://cloud.google.com/docs/chrome-enterprise/policies/) |
| 436 | will be updated automatically. |
Owen Min | 326f43e | 2019-11-13 16:08:30 | [diff] [blame] | 437 | |
Victor-Gabriel Savu | 42dcd42 | 2020-05-05 12:26:21 | [diff] [blame] | 438 | ## Targeting features at commercial users |
| 439 | |
| 440 | The recommended method to target commercial users is to create a policy to |
| 441 | control the behavior of a feature. You can for example create a feature only |
| 442 | for consumer users by setting `default_for_enterprise_users` to false; however, |
| 443 | it should only be used when the default enterprise behavior should be different |
| 444 | than regular consumer behavior. |
| 445 | |
Owen Min | f2127ad0 | 2019-12-17 19:59:49 | [diff] [blame] | 446 | ------ |
Owen Min | 326f43e | 2019-11-13 16:08:30 | [diff] [blame] | 447 | |
Owen Min | f2127ad0 | 2019-12-17 19:59:49 | [diff] [blame] | 448 | ### Additional Notes |
Owen Min | 326f43e | 2019-11-13 16:08:30 | [diff] [blame] | 449 | |
Yann Dago | 90b7132 | 2022-10-19 20:56:28 | [diff] [blame] | 450 | 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] | 451 | policy value is copied to `PrefService` in Step 3 of **Adding a new policy**. |