File: README.md

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (36 lines) | stat: -rw-r--r-- 2,615 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# About //components/policy/proto

This directory contains proto definitions for communication with the device management server.

## User policies

There are two protocol buffers defining the messages for user policies - `chrome_settings.proto` and `cloud_policy.proto`. Both files are auto-generated by the [generate_policy_source.py](https://source.chromium.org/chromium/chromium/src/+/main:components/policy/tools/generate_policy_source.py) script from policy_templates.json, which in turn is auto-generated from the individual policy yaml files in [policy_definitions](https://source.chromium.org/chromium/chromium/src/+/main:components/policy/resources/templates/policy_definitions/). This is all done as part of [building Chrome](https://source.chromium.org/chromium/chromium/src/+/main:components/policy/BUILD.gn?q=action%5C(%5C%22policy_code_generate%5C%22%5C)%20).

The reason there are two files is a compromise between readability and performance.

* `chrome_settings.proto`

  This file lists all non-device policies including comments containing their detailed descriptions. Additionally every policy in this file has a distinct message type. For example, this is the message for the `HomepageLocation` policy:


  ```
  message HomepageLocationProto {
    optional PolicyOptions policy_options = 1;
    optional string HomepageLocation = 2;
  }
   ```

* `cloud_policy.proto`

  This file is generated for each target platform and it therefore contains only the policy messages that a certain platform supports. Additionally each field uses a generic type defined in [policy_common_definitions.proto](https://source.chromium.org/chromium/chromium/src/+/main:components/policy/proto/policy_common_definitions.proto). For example this is the message for any string policy:

  ```
  message StringPolicyProto {
    optional PolicyOptions policy_options = 1;
    optional string value = 2;
  }
  ```

The client code for each platform uses the more compact `cloud_policy.proto` to parse the policy blobs it receives from the device management server. On the other hand, the device management server needs to know of all the policies that exist for all the platforms, therefore `chrome_settings.proto` is what the server code uses.

The two files are compatible and when the messages are serialized their binary content is equivalent. [CloudPolicyProtoTest.VerifyProtobufEquivalence](https://source.chromium.org/chromium/chromium/src/+/2d4ccc5062a5314b89973a2d53159f431a0ecfd3:chrome/browser/policy/cloud/cloud_policy_browsertest.cc;l=530) browser test makes sure that no regressions are introduced here.