Refresh Chrome policies programmatically?
Asked Answered
S

1

6

I wrote a Chrome extension, that uses local storage.

When I open chrome://policy/ in the browser I can see my extension's data according to the its ID, however, when I change the value manually in the registry it DOES NOT get updated automatically. Instead I have to click on the "Reload policies" button.

My extension uses this data and has to be updated. How can I refresh chrome policies from my code? (As if the user would click on the "Reload policies" button.)

Thanks!

enter image description here

Strikebreaker answered 21/6, 2017 at 11:49 Comment(1)
I see chrome.send("reloadPolicies") in the page code, which is only available on built-in chrome:// pages, it's not exposed in API. So the only way is to run chrome locally with --extensions-on-chrome-urls command line switch, and inject/declare a content script on "chrome://policy" page (note, you can open it as a pinned inactive tab).Procreant
H
2

For Windows, even if you're just managing the information in the registry and not via GPO, you force the updates to be reflected in Chrome with:

gpupdate /force

Note that this only works with shortened result (up to 15m after gpupdate /force) for policies with the "Dynamic Policy Refresh" (dynamic_refresh) flag.

Other policies will require a manual restart of Chrome or use of the Reload policies button at chrome://policy/.

This doesn't have an immediate response and can take 15 minutes after gpupdate is run before the changes will be observed...for those policies that support it.

Harlan answered 15/2, 2018 at 0:7 Comment(6)
This does not seem to work. Tried with and without /force. I'm also using the registry.Singlebreasted
@MarcelKirsche I use this method on a daily basis and it continues to work without fail. I suspect it's your policies that are defective. You should create a new question with the specific policies that you're using.Harlan
I've explained my problem here: #60515454Singlebreasted
not working for me. Using windows home (without active directory or domain) with Google Chrome 81. Tried before chrome start, and while chrome running. I'm using the registry (No GPO)Pirbhai
gpupdate /force updates the underlying registry settings. Chrome needs to be triggered to consume them, as per the reload button in chrome://policiesVitta
actually @CJBS, gpupdate /force works fine with most policies, including Chrome policies. Some specific policies do not work, but it is dependent on the specific policy and not on the application. Chromium docs indicate this with the "Dynamic Policy Refresh" flag - currently at line 420.Harlan

© 2022 - 2024 — McMap. All rights reserved.