chrome: Support configuration of Chrome policy management (fixes #3581)

Disable Chrome policy management by default. Add CefSettings.chrome_policy_id
which, when configured, enables Chrome policy management. See
https://support.google.com/chrome/a/answer/9037717 for background.

To test:
- Start with a machine where Google Chrome is managed.
- Run `cefclient --enable-chrome-runtime --url=chrome://policy/`
  There should be no configured policies.
- Run `cefclient --enable-chrome-runtime --url=chrome://policy/
       --enable-chrome-policy`
  Configured Platform properties should match Google Chrome.
- Run `cefclient --enable-chrome-runtime --url=chrome://policy/
       --enable-chrome-policy --enable-chrome-browser-cloud-management`
  Configured Platform and Cloud properties should match Google Chrome.
This commit is contained in:
Marshall Greenblatt
2023-10-10 19:26:37 -04:00
parent 8d7001adc3
commit a2a1b66ea5
7 changed files with 483 additions and 5 deletions

View File

@@ -214,6 +214,23 @@ void MainContextImpl::PopulateSettings(CefSettings* settings) {
CefString(&settings->accept_language_list) =
command_line_->GetSwitchValue("lang");
}
if (command_line_->HasSwitch("enable-chrome-policy")) {
// Enable Chrome policy management via Platform and OS-user policies.
// Use the same configuration ID as Google Chrome for testing purposes.
// If Google Chrome is managed on this machine we'll show the same
// configured policies in chrome://policy/.
CefString(&settings->chrome_policy_id) =
#if defined(OS_WIN)
"SOFTWARE\\Policies\\Google\\Chrome";
#elif defined(OS_MAC)
"com.google.Chrome";
#elif defined(OS_LINUX)
"/etc/opt/chrome/policies";
#else
"";
#endif
}
}
void MainContextImpl::PopulateBrowserSettings(CefBrowserSettings* settings) {