Enable Disable Chrome Extensions while Running

1,302 views
Skip to first unread message

Marian Lungu

unread,
Jun 28, 2013, 2:42:47 AM6/28/13
to chromi...@chromium.org
Hello,
I want to make a program that can Enable and Disable Extensions in Google Chrome .I want to make it using c++(win api -just for windows) .
I have experimented with the Preferences file found in the chrome user data folder ,seen that it works(modifying that 'state' property) ..but only when chrome is closed.
My question is,does Chrome synchronizes that Preferences file with all Processes running ,or with the Google Account(in which I don't think I can do anything) .
Can I modify that Preferences file in some way while Chrome is Running?(by accessing it's shared memory zone,or obtaining a named mutex to the file ? )
Thank you.

Joao da Silva

unread,
Jun 28, 2013, 2:52:20 AM6/28/13
to marian...@gmail.com, Chromium-dev
Manipulating the Preferences file from another process is extremely hacky and can fail in many ways (e.g. the keys used by Chrome can change at any time). FWIW Chrome only reads that file once at startup, so modifying it at runtime won't trigger any changes on the running Chrome process.

There are other ways to enable or disable extensions:

- the command line flag --disable-extensions (can't change at runtime)

- you can write an extension that enables/disables other extensions using the management API (see https://developer.chrome.com/extensions/management.html#method-setEnabled). This extension can then communicate with a C++ program over another channel (e.g. XHR to a local HTTP server)

- Chrome can be configured by an administrator using Group Policy on Windows, and some of the policies control the extensions that can be installed (see http://www.chromium.org/administrators/policy-list-3#ExtensionInstallBlacklist and others).

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
 
 
 

Georgel And

unread,
Jun 28, 2013, 3:13:14 AM6/28/13
to chromi...@chromium.org


I am asking because you can open the Preferences file,write in it,save ..but Chrome rewrites it while it's running ,so there must be a way of synchronizing with that file to write in it.

Joao da Silva

unread,
Jun 28, 2013, 3:16:41 AM6/28/13
to marian...@gmail.com, Chromium-dev
Writing the Preferences file is not a good idea and I strongly discourage it.

Chrome writes that file at shutdown, so it will override whatever is written there during runtime. If you want to modify it externally then you have to do it while Chrome is not running.

If you want to enable and disable extensions at runtime then using the management API is probably the way to go.


On Fri, Jun 28, 2013 at 9:13 AM, Georgel And <marian...@gmail.com> wrote:


I am asking because you can open the Preferences file,write in it,save ..but Chrome rewrites it while it's running ,so there must be a way of synchronizing with that file to write in it.

--

Georgel And

unread,
Jun 28, 2013, 3:22:43 AM6/28/13
to chromi...@chromium.org
Do you know how Chrome stores it's preferences and other data while it's running?With cookies ,or using session variable,or it syncs with the google account online.
And another thing,the Preferences file is modified instantly when you disable an extension (seems with that data in the browser)

Fred Akalin

unread,
Jun 28, 2013, 3:50:02 AM6/28/13
to marian...@gmail.com, chromium-dev
It's stored in memory.


On Fri, Jun 28, 2013 at 12:22 AM, Georgel And <marian...@gmail.com> wrote:
Do you know how Chrome stores it's preferences and other data while it's running?With cookies ,or using session variable,or it syncs with the google account online.
And another thing,the Preferences file is modified instantly when you disable an extension (seems with that data in the browser)

--

Georgel And

unread,
Jun 28, 2013, 4:44:01 AM6/28/13
to chromi...@chromium.org
Thank you,I guess it's using a FileMapping of some sort ,if I only knew the name of the mapping

Fred Akalin

unread,
Jun 28, 2013, 4:56:20 AM6/28/13
to marian...@gmail.com, chromium-dev
There's no "FileMapping". Preferences are stored in an in-memory data structure, i.e. not stored in memory as JSON. When the in-memory data structure is changed, it's serialized (i.e. converted to JSON) and written to disk.


On Fri, Jun 28, 2013 at 1:44 AM, Georgel And <marian...@gmail.com> wrote:
Thank you,I guess it's using a FileMapping of some sort ,if I only knew the name of the mapping

--
Message has been deleted

Georgel And

unread,
Jun 28, 2013, 5:16:46 AM6/28/13
to chromi...@chromium.org
Is there any way to see the contents of the in-memory data structure?


Joao da Silva

unread,
Jun 28, 2013, 5:19:22 AM6/28/13
to Marian Lungu, Chromium-dev
A debugger can inspect the memory of a debug build. It's also possible to analyze a release build but it's much harder, and unreliable.

What are you trying to do? Maybe there's a better way.


On Fri, Jun 28, 2013 at 11:16 AM, Georgel And <marian...@gmail.com> wrote:
Is there any way to see the contents of the in-memory data structure?

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
 
 
 



--
Google Germany GmbH
Dienerstr. 12, 80331 München
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
Geschäftsführer: Graham Law, Katherine Stephens

Georgel And

unread,
Jun 28, 2013, 5:24:22 AM6/28/13
to chromi...@chromium.org, Marian Lungu
If I could access that structure from another process/program ,maybe I could change something in it,via memory writing  

Finnur Thorarinsson

unread,
Jun 28, 2013, 6:28:29 AM6/28/13
to marian...@gmail.com, Chromium-dev
Joao was asking you to take a step back, look at the bigger picture and describe *why* you are trying to use the least reliable -- and the most malware-like -- method to accomplish something that is readily available using much better official methods (ie. the Management Extensions API).

Can you take a moment to describe what your overall goal is and why the methods he pointed you at don't accomplish those goals?

Modifying the Preferences file in-memory directly is not supported.


On Fri, Jun 28, 2013 at 9:24 AM, Georgel And <marian...@gmail.com> wrote:
If I could access that structure from another process/program ,maybe I could change something in it,via memory writing  

Georgel And

unread,
Jun 28, 2013, 6:35:07 AM6/28/13
to chromi...@chromium.org
I want to make a program from which I can modify Externally the properties of extensions ,Outside of Chrome .That is why I don't want to create an extension using the management api to do this,it has to be Externally from another program to monitor what the user does with extensions and interfere without using Chrome,or any api that chrome delivers.


PhistucK

unread,
Jun 28, 2013, 9:26:12 AM6/28/13
to marian...@gmail.com, Chromium-dev
So why does the Group Policy seem inappropriate here?


PhistucK


On Fri, Jun 28, 2013 at 1:35 PM, Georgel And <marian...@gmail.com> wrote:
I want to make a program from which I can modify Externally the properties of extensions ,Outside of Chrome .That is why I don't want to create an extension using the management api to do this,it has to be Externally from another program to monitor what the user does with extensions and interfere without using Chrome,or any api that chrome delivers.

Justin Schuh

unread,
Jun 30, 2013, 9:53:24 AM6/30/13
to marian...@gmail.com, Chromium-dev
It sounds like you can do what you want using the extension management API to control the extensions, and the native messaging API to communicate with your external application. As others have already mentioned, mucking with the preferences file or manipulating Chrome through other undocumented means is a very, very bad idea and will not do what you want.

-j



On Fri, Jun 28, 2013 at 3:35 AM, Georgel And <marian...@gmail.com> wrote:
I want to make a program from which I can modify Externally the properties of extensions ,Outside of Chrome .That is why I don't want to create an extension using the management api to do this,it has to be Externally from another program to monitor what the user does with extensions and interfere without using Chrome,or any api that chrome delivers.
Reply all
Reply to author
Forward
0 new messages