Can I set extension policies locally from the registry?

霸气de小男生 提交于 2021-01-27 17:32:46

问题


I have a Chrome Extension and I added a managed_schema to define a property (SomeSetting) so I can set it via a policy.

manifest.json:
"storage": { "managed_schema": "schema.json" }

schema.json:
"properties": { "SomeSetting": { "type": "string" } }

I can see SomeSetting in chrome://policy/ but I have no idea how to set the value. Apparently I can do this at HKLM\SOFTWARE\Policies\Google\Chrome\3rdparty\extensions... but I tried and it never is shown as set in chrome://policy/.

Does anyone know if this is suppose to work? Does it have to be HKCU instead? Or do I need Active Directory because setting values locally via the registry is not supported?


回答1:


I had a hard time figuring this out. The documentation is not all that clear.

In order to get your schema to work you need to add a registry entry for "SomeSetting".

Go to the following item in your registry (create the necessary items):

Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\3rdparty\extensions\aaaaaaaaaaaaaa\policy

where aaaaaaaaaaaaaa is your extension ID from chrome://extensions

Right-click on "policy" and create a new string value:

Name: SomeSetting
Data: "some value"

Go back to Chrome and reload chrome://policy/

The new policy should appear.

From your extension, you can access the value like this:

chrome.storage.managed.get("SomeSetting", function(setting_val) {
   console.debug(setting_val);
});

I'm not sure if this requires Active Directory to work.




回答2:


It was mentioned in Alternative Extension Distribution Options that:

Google Chrome supports the following extension installation methods:

  • Using a preferences JSON file (for Mac OS X and Linux only)
  • Using the Windows registry (for Windows only)

More information regarding other mechanisms on extensions distribution options can be found in the documentation.



来源:https://stackoverflow.com/questions/37716682/can-i-set-extension-policies-locally-from-the-registry

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!