Manage Google Chrome

malonso
New Contributor II

I am trying to manage Google Chrome browser the last post on this that I have been able to find is from March 2014. Can anyone point me to any direction were I can commence this. Thank you

7 REPLIES 7

seraphina
Contributor II

Manage it how? Enable Auto Updates without needing an admin password, disabling updates completely, restricting certain settings?

If you are wanting auto updates without an admin prompt, we have been using this script without issues

#!/usr/bin/env python
# encoding: utf-8
"""
chrome-enable-autoupdates.py

This script enables system wide automatic updates for Google Chrome.
It should work for Chrome versions 18 and later. No configuration needed
as this is originally intended as a munki postinstall script.

Created by Hannes Juutilainen, hjuutilainen@mac.com

History:

2017-09-01, Hannes Juutilainen - Ignore errors when installing keystone 2015-09-25, Niklas Blomdalen - Modifications to include old KeystoneRegistration installation (python version) 2014-11-20, Hannes Juutilainen - Modifications for Chrome 39 2012-08-31, Hannes Juutilainen - Added --force flag to keystone install as suggested by Riley Shott 2012-05-29, Hannes Juutilainen - Added more error checking 2012-05-25, Hannes Juutilainen - Added some error checking in main 2012-05-24, Hannes Juutilainen - First version """ import sys import os import subprocess import plistlib chrome_path = "/Applications/Google Chrome.app" info_plist_path = os.path.realpath(os.path.join(chrome_path, 'Contents/Info.plist')) brand_path = "/Library/Google/Google Chrome Brand.plist" brand_key = "KSBrandID" tag_path = info_plist_path tag_key = "KSChannelID" version_path = info_plist_path version_key = "KSVersion" class Usage(Exception): def __init__(self, msg): self.msg = msg def chrome_installed(): """Check if Chrome is installed""" if os.path.exists(chrome_path): return True else: return False def chrome_version(): """Returns Chrome version""" info_plist = plistlib.readPlist(info_plist_path) bundle_short_version = info_plist["CFBundleShortVersionString"] return bundle_short_version def chrome_update_url(): """Returns KSUpdateURL from Chrome Info.plist""" info_plist = plistlib.readPlist(info_plist_path) update_url = info_plist["KSUpdateURL"] return update_url def chrome_product_id(): """Returns KSProductID from Chrome Info.plist""" info_plist = plistlib.readPlist(info_plist_path) product_id = info_plist["KSProductID"] return product_id def keystone_registration_framework_path(): """Returns KeystoneRegistration.framework path""" keystone_registration = os.path.join(chrome_path, 'Contents/Versions') keystone_registration = os.path.join(keystone_registration, chrome_version()) keystone_registration = os.path.join(keystone_registration, 'Google Chrome Framework.framework') keystone_registration = os.path.join(keystone_registration, 'Frameworks/KeystoneRegistration.framework') return keystone_registration def keystone_install(): """Install the current Keystone""" install_script = os.path.join(keystone_registration_framework_path(), 'Resources/ksinstall') if not os.path.exists(install_script): install_script = os.path.join(keystone_registration_framework_path(), 'Resources/install.py') keystone_payload = os.path.join(keystone_registration_framework_path(), 'Resources/Keystone.tbz') if os.path.exists(install_script) and os.path.exists(keystone_payload): ksinstall_process = [ install_script, '--install', keystone_payload, '--force' ] p = subprocess.Popen(ksinstall_process, stdout=subprocess.PIPE, stderr=subprocess.PIPE) (results, error) = p.communicate() if results: print results if p.returncode != 0: if error: print >> sys.stderr, "%s" % error print >> sys.stderr, "Keystone install exited with code %i" % p.returncode # Since we used --force argument, succeed no matter what the exit code was. return True else: print >> sys.stderr, "Error: KeystoneRegistration.framework not found" return False def register_chrome_with_keystone(): """Registers Chrome with Keystone""" ksadmin = "/Library/Google/GoogleSoftwareUpdate/GoogleSoftwareUpdate.bundle/Contents/MacOS/ksadmin" if os.path.exists(ksadmin): ksadmin_process = [ ksadmin, '--register', '--productid', chrome_product_id(), '--version', chrome_version(), '--xcpath', chrome_path, '--url', chrome_update_url(), '--tag-path', tag_path, '--tag-key', tag_key, '--brand-path', brand_path, '--brand-key', brand_key, '--version-path', version_path, '--version-key', version_key ] p = subprocess.Popen(ksadmin_process, stdout=subprocess.PIPE, stderr=subprocess.PIPE) (results, error) = p.communicate() if error: print >> sys.stderr, "%s" % error if results: print results if p.returncode == 0: return True else: return False else: print >> sys.stderr, "Error: %s doesn't exist" % ksadmin return False def main(argv=None): if argv is None: argv = sys.argv try: # Check for root if os.geteuid() != 0: print >> sys.stderr, "This script must be run as root" return 1 if not chrome_installed(): print >> sys.stderr, "Error: Chrome is not installed on this computer" return 1 if keystone_install(): print "Keystone installed" else: print >> sys.stderr, "Error: Keystone install failed" return 1 if register_chrome_with_keystone(): print "Registered Chrome with Keystone" return 0 else: print >> sys.stderr, "Error: Failed to register Chrome with Keystone" return 1 except Usage, err: print >> sys.stderr, err.msg print >> sys.stderr, "for help use --help" return 2 if __name__ == "__main__": sys.exit(main())

malonso
New Contributor II

Thank and sorry for the vague details. We are looking into adding a startup url and some standard bookmark tabs and remove ability to change download location.

patgmac
Contributor III

Take a look at https://github.com/ProfileCreator/ProfileCreator

Quite a bit of Chrome settings available in there.

Hugonaut
Valued Contributor II

@malonso

Haven't done this in a very long time so please correct me if I'm wrong &/or missing a step - hope this helps

I believe by adding these lines to the users com.apple.launchservices.secure.plist (Located -> '/Users/$USERNAME/Library/Preferences/com.apple.LaunchServices/com.apple.launchservices.secure.plist ') chrome will be the default application called when opening the following prefix for urls

    <key>LSHandlerRoleAll</key>
                <string>-</string>
            </dict>
            <key>LSHandlerRoleAll</key>
            <string>com.google.Chrome</string>
            <key>LSHandlerURLScheme</key>
            <string>http</string>
        </dict>
        <dict>
            <key>LSHandlerPreferredVersions</key>
            <dict>
                <key>LSHandlerRoleAll</key>
                <string>-</string>
            </dict>
            <key>LSHandlerRoleAll</key>
            <string>com.google.Chrome</string>
            <key>LSHandlerURLScheme</key>
            <string>https</string>
        </dict>
        <dict>
            <key>LSHandlerPreferredVersions</key>
            <dict>
                <key>LSHandlerRoleAll</key>
                <string>-</string>
            </dict>
            <key>LSHandlerRoleAll</key>
            <string>com.google.Chrome</string>
            <key>LSHandlerURLScheme</key>
            <string>ftp</string>
        </dict>
        <dict>
            <key>LSHandlerContentType</key>
            <string>public.html</string>
            <key>LSHandlerPreferredVersions</key>
            <dict>
                <key>LSHandlerRoleAll</key>
                <string>-</string>
            </dict>
            <key>LSHandlerRoleAll</key>
            <string>com.google.Chrome</string>
        </dict>

& then deploying a plist (i did it with a config profile -> "Custom Settings" with the plist passed as is displayed in secure plist above ie "com.google.Chrome" - you want to save the plist displayed BELOW as "com.google.chrome.plist" before uploading it.

Image Example Below - "Upload_Field_Custom_Settings_Filename" is where you upload the plist.

acb196f171164f34963b42651e5cb3a5

You can upload the following plist & config it how you see fit,

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>DefaultBrowserSettingEnabled</key>
    <false/>
    <key>HomepageIsNewTabPage</key>
    <false/>
    <key>HomepageLocation</key>
    <string>www.Website Homepage.com</string>
    <key>RestoreOnStartupURLs</key>
    <array>
        <string>www.Website 1.com</string>
        <string>www.Website 2.com</string>
        <string>www.Website 3.com</string>
    </array>
    <key>RestoreOnStartup</key>
    <integer>4</integer>
    <key>ShowHomeButton</key>
    <true/>
    <key>IncognitoModeAvailability</key>
    <integer>1</integer>
</dict>
</plist>

i dont manage chrome anymore, but this is almost everything you need. i dont know the key for setting default download location for the plist but hopefully this helps.

________________
Looking for a Jamf Managed Service Provider? Look no further than Rocketman
________________


Virtual MacAdmins Monthly Meetup - First Friday, Every Month

malonso
New Contributor II

@Hugonaut will test and report

sdagley
Esteemed Contributor II

@mlizbeth Be aware that the chrome-enable-autoupdates.py script has been updated to handle changes to the keystone framework path introduced in Chrome v75. It's not shown in the History section of the script, but the keystone_registration_framework_path() definition has changed.

CorpIT_eB
Contributor II

@malonso There is also the BASH variation that works very well as well, and was recently tweaked for the changes made by Google with the release of v75.

Located here: How to update Chrome automatically

@ryan.ball 's Script <-- lol can be located here: http://chrome-enable-autoupdates.sh/