This page describes the steps to add a new group policy setting to Chromium. Administrator documentation about using Group Policy is here if you're looking for information on how to use group policies. - Make the feature you want to be controlled by policy use a bool/int/string/string list property that it fetches from the PrefService to determine its desired behavior.
- For existing command line switches that are being turned into policy, you will want to modify the CommandLinePrefStore in chrome/browser/prefs/command_line_pref_store.cc to set the property appropriately from the command line switch (the managed policy will override this value from the command line automagically when policy is set if you do it this way).
- Add a policy to control the property in:
- chrome/app/policy/policy_templates.json - This file contains meta-level descriptions of all policies and is used to generated code, policy templates (ADM/ADMX for windows and the application manifest for Mac), as well as documentation. When adding your policy, please make sure you get the version and features flags (such as dynamic_refresh and supported_on) right, since this is what will later appear on http://dev.chromium.org/administrators/policy-list-3. The textual policy description should include the following:
- What features of Chrome are affected
- Which behavior and/or UI/UX changes the policy triggers
- How the policy behaves if it's left unset or set to invalid/default values. This may seem obvious to you, and it probably is. However, this information seems to be provided for Windows Group Policy traditionally, and we've seen requests from organizations to explicitly spell out the behavior for all possible values and for when the policy is unset.
- chrome/browser/policy/configuration_policy_handler_list.cc - for mapping the policy to the right pref
- chrome/browser/policy/configuration_policy_pref_store_unittest.cc - contains boiler-plate tests organized by type. You should at the very least add a minimal test case for your policy as a one-liner in this file.
- If your feature can be controlled by GUI in chrome://settings, then you will want chrome://settings to disable the GUI for the feature when the policy controlling it is managed.
- There is a method on PrefService::Preference to ask if it's managed.
- You will also want chrome://settings to display the "some settings on this page have been overridden by an administrator" banner. If you use the pref attribute to connect your pref to the UI, this should happen automagically. NB: There is work underway to replace the banner with setting-level indicators. Once that's done, we'll update instructions here.
- Wherever possible, we would like to support dynamic policy refresh, that is, the ability for an admin to change policy and Chrome to honor the change without relaunch.
- This means that you should listen for preference change notifications for your preference.
- Don't forget to update chrome://settings when the preference changes. Note that for standard elements like checkboxes, this works out of the box when you use the pref attribute.
- Build the policy_templates target to check that the ADM/ADMX, Mac app manifests, and documentation are generated correctly.
- The generated files are placed in out/Debug/gen/chrome/app/policy/ (on Linux, adjust for other build types/platforms)
- Add an entry for the new policy in chrome/test/data/policy/policy_test_cases.json
- Add a test that verifies that the policy is being enforced in chrome/browser/policy/policy_browsertest.cc.
- Manually testing your policy
- Windows: The simplest way to test is to write the registry keys manually to Software\Policies\Chromium (for Chromium builds) or Software\Policies\Google\Chrome (for Google Chrome branded builds). If you want to test policy refresh, you need to use group policy tools and gpupdate; see Windows Quick Start.
- Mac: See Mac Quick Start (section "Debugging")
- Linux: See Linux Quick Start (section "Set Up Policies")
- Chrome OS is more complex to test, as a full end-to-end test requires network transactions to the policy test server.
Examples
Here's a recent CL that has the basic infrastructure work required to add a policy for an already existing preference. It's a good, simple place to get started: http://codereview.chromium.org/8395007 |
|