3

I have a chrome extension (intended to be used by companies internally) that needs to have user specific configurations but I want to avoid the user having to do all that and have a sysadmin configure those things for them via a script.

EDIT: Basically, I just need to read from a file that sysadmin can write.

Is this in any way possible?

Mental Zenga
  • 80
  • 1
  • 8
  • What kind of configurations do you want? – Moin Nov 23 '15 at 15:47
  • just reading any value from any file that can be accessed outside of the extension is fine – Mental Zenga Nov 23 '15 at 15:51
  • 1
    Add a in extension directory. After installation, sysadmin can locate the file and edit it in Chrome directory. Inside the extension, you can use `chrome.runtime.getURL` to get fill path. Read it via AJAX. https://developer.chrome.com/extensions/runtime#method-getURL – Moin Nov 23 '15 at 15:57
  • I've done that, but say in my mac osx El Capitan, I can not locate those files, from anywhere suggested on the internet. I don't even have a Google folder in my Application Support folder. Will the sysadmins be able to locate the file ? – Mental Zenga Nov 23 '15 at 16:09
  • Enable developer tools on you Chrome, `Load unpacked extension..` and load the folder where your extension is. – Moin Nov 23 '15 at 16:10
  • 1
    BTW, if you are going to install it via .zip or .crx then you can locate all the extensions in `~Library/Application Support/Google/Chrome/Default/Extensions` folder of mac. Just tried, works. Just find id of your extension from extensions page. – Moin Nov 23 '15 at 16:15

2 Answers2

1

You have two solutions.

First one is to ask your sysadmin to properly locate chrome's extension folder on all platforms, and edit a file in there. It might be a bit complicated if all computers at your company are not the same or use different platforms.

See: Where to find extensions installed folder for Google Chrome on Mac?

The second one, is simply to ask for the file:///* permission when you install the extension.

It will allow your extension to read files on the whole hard drive, and load the configuration file on a predetermined place.

Here is a related question: Chrome plugin reading text file on hard drive and replacing textbox content

edit: for the second solution to work, you need your users to enable "Allow access to file URLs" in chrome's config (not sure you can do that automatically)

Community
  • 1
  • 1
Eloims
  • 5,106
  • 4
  • 25
  • 41
  • The first solution will result in Chrome swiftly disabling the extension because it is "compromised" as the file checksums will fail to validate. The second solution requires manual steps from the user (it's not possible to check that automatically). – Xan Dec 22 '15 at 09:57
  • Can't delete the answer as it was accepted... even if wrong. Did not think of chrome checksuming the extension. I upvoted your answer – Eloims Dec 22 '15 at 12:49
  • It may not disable on all platforms, but it will in Windows and I think Google wanted to extend that to at least Macs. Also it does not apply to unpacked extensions. – Xan Dec 22 '15 at 12:50
1

Assuming you have an enterprise install, you can use chrome.storage.managed (which can be easily controlled from a central location) to hold those preferences.

See Configuring Apps and Extensions by Policy for a detailed, per-OS explanation.


If an enterprise managed storage is not an option, perhaps a better one would be to have a configuration file available somewhere on an internal web server. The extension can then retrieve that pre-defined URL and configure itself accordingly.

You can differentiate between computers automatically using IP/MAC address information accessible by the server processing the request, of you can pass some query parameters yourself.

Xan
  • 74,770
  • 16
  • 179
  • 206