Hey @mk2000 take a look at this. I was experimenting with Chrome Preferences with the latest version and they now have “Preferences” and “Secure Preferences”. The idea is if malware found a way to modify your chrome preferences (homepage etc) it’ll revert the changes.
Hopefully you’ll find a way around this or you can also look at using a Config Profile with the com.google.Chrome plist that you can use to force some preferences and extensions. Guide on creating that Config Profile here.
If you are a jamf customer you can upload the configured plist as a “custom” setting in a macOS Config Profile. Be sure to convert it to the right format with
plutil -convert xml1 /path/to/com.google.Chrome.plist
before you upload it.
@ssrussell thanks for taking the time to respond.
So in the end I managed to figure it out using the Google Chrome Master Preferences.
The key is to not try to manually code all the JSON and instead configure Google Chrome as you want it with all the settings and extensions that need to be configured. Then, as you mentioned, two key files are the “Preferences” and “Secure Preferences” located in ~/Library/Application Support/Google/Chrome/Default. While some values in Secure Preferences are encrypted or machine ID specific, all the values in the "Preferences" file are clear text and not machine specific and also already in the proper JSON format.
So rather than trying to look at the developer documentation for Chrome to figure out which JSON name/values correspond to a GUI setting simply take the "Preferences" file and rename it to Google Chrome Master Preferences.
If your Chrome settings are highly customized this literally takes care of 75% of everything. And the file just works!
As for the “Secure Preferences” you can also take a giant chunk out of it to make it useable for your Google Chrome Master Preferences file.
In Chrome's case “Secure Preferences” is what keeps all the configuration syntax for the Extensions including their state (enabled/disabled).
This section is not machine ID specific. So I copied the entire Extension array inside of “Secure Preferences” and pasted into my Google Chrome Master Preferences file.
I then used the super simple instructions on how to add External Extensions from the link below:
https://developer.chrome.com/extensions/external_extensions
Summary instructions for External Extensions:
Place the json file named using the ID of the extension you want in:
/Library/Application Support/Google/Chrome/External Extensions
Example:
/Library/Application Support/Google/Chrome/External Extensions/ipkjmjaledkapilfdigkgfmpekpfnkih.json
The actual JSON files all have the same content so the only unique thing about them is the actual name of the file:
{
"external_update_url": "https://clients2.google.com/service/update2/crx"
}
As Chrome starts up it installs the Extensions but configures them per your Google Chrome Master Preferences file. Including whether they are Enabled or Disabled!
Secure Preferences also contains the object names you need for Homepage and Startup tabs but their values are encrypted so you cannot simply paste those. But simply looking at the object names sends you in the right direction. For that I mainly used Google's "Google Chrome Master Preferences" sample template file to create the Distribution array etc and pasted that in.
Actually another file that contains values you can copy and paste in the "Google Chrome Master Preferences" file is ~/Library/Application Support/Google/Chrome/Local State.
So while the Preferences file can just be renamed to Google Chrome Master Preferences as is once you start merging things from Secure Preferences or Local State you need to make sure that all your sections, brackets and comas are properly notated.
I used an online JavaScript Beautifier to convert single line JSON code to multi line for editing:
https://beautifier.io
And this JSON script verifier to validate my code format:
http://jslint.com
Everything worked after that!