Is there a way to check whether google chrome extension is installed in the browser through C#?

1,094 views
Skip to first unread message

Jaliya roshen Jayarathne

unread,
Aug 2, 2022, 5:53:36 AM8/2/22
to Chromium Extensions
I want to check either user already install the chrome extension or not through some external C# code. Is there any way to check it and intall chrome extension programtically?

ExtensionNinja

unread,
Aug 2, 2022, 11:12:10 AM8/2/22
to Chromium Extensions, jaliya...@gmail.com

If you have access to run code/scripts on user's machine, then you can check browser extension folder in the local file system. Folder are named according to extension ID.

Jaliya roshen Jayarathne

unread,
Aug 2, 2022, 12:28:29 PM8/2/22
to Chromium Extensions, Extension.ninja, Jaliya roshen Jayarathne
Apart from that, isn't it possible to directly check the chrome and install the extension prpgramatically?

Simeon Vincent

unread,
Aug 2, 2022, 12:59:36 PM8/2/22
to Jaliya roshen Jayarathne, Chromium Extensions, Extension.ninja
I want to check either user already install the chrome extension or not through some external C# code

This sounds like it might be an XY problem. What are you trying to do?
 
isn't it possible to directly check the chrome and install the extension prpgramatically?

It sounds like you want to conditionally install the extension using an alternate installation method. Conditional installation shouldn't be necessary. If you feel it is, could you explain your use case?

Simeon - @dotproto
Chrome Extensions DevRel


--
You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/2788389e-9a45-4d90-9a6c-9426b49871a8n%40chromium.org.

Jaliya roshen Jayarathne

unread,
Aug 3, 2022, 12:23:28 AM8/3/22
to Chromium Extensions, Simeon Vincent, Chromium Extensions, Extension.ninja, Jaliya roshen Jayarathne
Let me tell you the complete scinario. I have a C# (standalone) app. At the same time, there is a chrome extesion that works with it. Here, the data capture through extesion is given to C# app through the webSocket Communication. The extesion must be available for the C# app to work. Therefore, when a user first installs the C# app, it is necessary to know whether the chrome extesion has been installed in the user's chrome browser. If not , it is necessary to introduce functionality of installing the extesion. That's what I meant by programatically installing. As the alternative installing method for the above does not fulfill my requirement, I would like to know if it can be installed through this method.

hrg...@gmail.com

unread,
Aug 3, 2022, 1:48:50 PM8/3/22
to Chromium Extensions, jaliya...@gmail.com, Simeon Vincent, Chromium Extensions, Extension.ninja
There's no reliable way to know if the extension is already installed. What if the user uses more than one Chromium-based browser?
My computer, for example, has Chrome, Edge, Opera and Vivaldi.
Are you going to check all Chromium browsers that you can find on the user's machine?
What if I use a portable or standalone browser whose install folder is a non-standand path?
What if my browser is in a standard install path but by profile directory is a custom one?

Like I said above, there's no reliable way to determine if an extension is already installed. There are too many possibilities.
All you can do is to trigger an installation by adding the extension ID to the Windows registry, as is documented here (or a preferences file on other OSs).

However, if the extension is already running you can detect that from your C# program by listening the for the socket connection. For that to work, the extension must try creating the websocket repeatedly every few seconds.

PhistucK

unread,
Aug 3, 2022, 6:37:13 PM8/3/22
to hrg...@gmail.com, Chromium Extensions, jaliya...@gmail.com, Simeon Vincent, Extension.ninja
I guess a nice on-demand and user-visible way to check if an extension is installed is to launch the default browser with a URL to an external page that your extension can access, run a content script that tells the extension to trigger the WebSocket connection. The page can show to the user, "Great, extension installed and connected to the application!", or "Install this extension to activate the application", depending on whether the content script tells the page that it exists.

Of course, this is a workaround because programmatically finding that out is not possible.

PhistucK


Jaliya roshen Jayarathne

unread,
Aug 4, 2022, 12:44:05 AM8/4/22
to Chromium Extensions, PhistucK, Chromium Extensions, Jaliya roshen Jayarathne, Simeon Vincent, Extension.ninja, hrg...@gmail.com
Therefore, it seems like that at leat the workaround cannot be implemented without websocket, and the simple answer to this question is that the chrome extension cannot be installed programatically in that way (Assuming I am trying to implement this without using websocket).

PhistucK

unread,
Aug 4, 2022, 5:50:34 AM8/4/22
to Jaliya roshen Jayarathne, Chromium Extensions, Simeon Vincent, Extension.ninja, hrg...@gmail.com
WebSockets are just one way, you can also just send a request to a temporary server created by the C# application for that purpose, or the application can-be/also-have a native messaging host that the extension can communicate with. You can also open a URL with a unique identifier that will be sent to an external server that communicates with your C# application. There are a myriad of ways and they depend on your architecture and infrastructure.

Note that you asked if you can programmatically find out if something is installed, not if you can install programmatically, which is a different question.
I believe installing programmatically (or sort of) is possible for enterprises/domain-joined devices, if this is your audience. I believe it involves setting some registry keys, but I am not familiar with it in depth.
Detecting whether it is installed is not possible programmatically, as far as I know.

PhistucK

Darbid

unread,
Aug 4, 2022, 5:53:44 AM8/4/22
to Chromium Extensions, jaliya...@gmail.com, PhistucK, Chromium Extensions, Simeon Vincent, Extension.ninja, hrg...@gmail.com
The hack way, as you have native code running is to just find the preferences file of Chrome. You then know if they have it installed and also whether it is enabled or not.

Jaliya roshen Jayarathne

unread,
Aug 4, 2022, 6:10:08 AM8/4/22
to Darbid, Chromium Extensions, PhistucK, Simeon Vincent, Extension.ninja, hrg...@gmail.com
Thanks for all your comments. Really appreciate it and it helps me a lot.👍

Jackie Han

unread,
Aug 4, 2022, 2:04:02 PM8/4/22
to Jaliya roshen Jayarathne, Chromium Extensions
Is there any way to check it and install chrome extension programmatically?

Yes, I just read a blog :)

On Tue, Aug 2, 2022 at 5:53 PM Jaliya roshen Jayarathne <jaliya...@gmail.com> wrote:
I want to check either user already install the chrome extension or not through some external C# code. Is there any way to check it and intall chrome extension programtically?

--
You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.

Jaliya roshen Jayarathne

unread,
Aug 4, 2022, 11:33:05 PM8/4/22
to Chromium Extensions, Jackie Han, Chromium Extensions, Jaliya roshen Jayarathne
But installing it this way is feels like creating a vulnerability in both extension and the application. 

Simeon Vincent

unread,
Aug 4, 2022, 11:50:26 PM8/4/22
to Jaliya roshen Jayarathne, Chromium Extensions, Jackie Han
Therefore, when a user first installs the C# app, it is necessary to know whether the chrome extesion has been installed in the user's chrome browser. 

This is exactly the use case that the alternate installation methods are meant for: installing a Chrome extension during the installation flow of a desktop application. You don't need to worry whether or not the extension is already installed. If the extension isn't installed, Chrome will install the appropriate extension from the Chrome Web Store. If the externsion't is installed then, well, our work here is done ;)

But installing it this way is feels like creating a vulnerability in both extension and the application.

I'm pretty sure Jackie was joking. That article is explicitly talking about malware forcing itself into the user's browser. Definitely don't do that.

Simeon Vincent
Developer Relations Engineer

Jaliya roshen Jayarathne

unread,
Aug 5, 2022, 3:02:54 AM8/5/22
to Chromium Extensions, Simeon Vincent, Chromium Extensions, Jackie Han, Jaliya roshen Jayarathne
Finally, the solution is to develop a C# application to install through the windows registry.

Darbid

unread,
Aug 5, 2022, 3:14:15 AM8/5/22
to Chromium Extensions, jaliya...@gmail.com, Simeon Vincent, Chromium Extensions, Jackie Han
I am not an experienced developer but please understand what the above marketing person is saying as far as I understand it.

Adding something to the registry is ONLY that, adding something to the registry. It does NOT install the extension. You need Chrome to read that registry entry and then chrome if it wants will install it.  Secondly the user needs to interact with Chrome for the installation to go ahead, in some cases (depends on focus of Chrome at the time I think) this means they need to know that a button on the top right which is now a different color needs to be clicked (most user feedback I have had is they do not do this). Next step is any permissions need to be agreed to. Only after all these things are done can it be ASSUMED that it is installed.

This is the reason why if you have native code running C# the only way to know that the extension is actually running is to hack the preferences file. Everything else is Google marketing that all is good.

Simeon Vincent

unread,
Aug 5, 2022, 8:07:34 PM8/5/22
to Darbid, Chromium Extensions, jaliya...@gmail.com, Jackie Han
While I tend to try to be through in my answers, I glossed over some nuance in my last email. There's only so much time in the day.

1. Adding an item to the Windows registry or preferences JSON does not in-and-of-itself install an extension. Rather, it signals to Chrome that another application on the user's computer wants to install an extension. Think of this as the first step of an installation flow design for this use case. 

2. Extensions installed using this flow are automatically disabled until the user chooses to enable them. The next time the user interacts with Chrome, it will prompt them with a message saying "Another program on your computer added an extension that may change the way Chrome works." Be aware that the user may not approve this request.

image.png
An example of the user prompt that appears when another application installs an extension in Chrome.

You may want to consider ways to help onboard users and troubleshoot extension installation. PhistucK's suggestion to "launch the default browser with a URL to an external page that your extension can access" is a good strategy. In the same vein, at the end of the desktop application's installation flow you can open an onboarding page on your website in Chrome. This page can then use message passing to check whether the extension is installed (if it doesn't respond it's effectively not installed) and conditionally load a support article that walks the user through the extension installation process. A similar flow can also be triggered in the desktop application if it detects that it cannot connect to the extension.

FWIW, Dabrid, "developer relations" and "developer marketing" are different roles. This article has a good breakdown of their relative responsibilities.

Simeon - @dotproto
Chrome Extensions DevRel

Darbid

unread,
Aug 6, 2022, 1:59:48 AM8/6/22
to Chromium Extensions, Simeon Vincent, Chromium Extensions, jaliya...@gmail.com, Jackie Han, Darbid
And if you go down that track referring to the above numbering

1. Chrome will ignore your registry entries if other registry keys prevent it from moving forward with the installation - for example group policy or otherwise where all extensions are not allowed, there is a whitelist of extensions or in your case native clients are not allowed. Further I am sure it is timed exactly in code but when Chrome actually reads the registry appears in practice to be pretty random. The reg entry is only a reference to the chrome store as well. I only have 10 or 20 people (in a corporate world) for a reference so a micro/micro sample but sometimes Chrome installs it straight away, other times we give up waiting and I tell the user I will come back later.

2. As I said that dialog shown above is possible but it is my experience that some users only see that little yellow icon you can see in the top right. I do not know if they have seen the dialog shown or not, but no user has ever thought to click on that little yellow icon at a later stage.

...after that I believe you then have permission to get through.

Further if you have the extra requirement of for example "allow access to file urls" which you need to hold the user by the hand to activate, they will get no prompts from Chrome.

Finally the extension can be installed but disabled.

So whilst the options given above are the right and compliant way, of checking, in practice the above methods will only be a boolean response, extension works, extension does. not. If you really want to know, is it installed, is it enabled, have the permissions been given etc etc reading the preferences file and knowing the real status of the extension is the only way.

FWIW: it is not personal. It is the position and the effect or lack of that I comment about.

Reply all
Reply to author
Forward
0 new messages