Question:
Is there a simple programmatic way to create new Firefox profiles?
nsIToolkitProfileService
looks like it might do the trick but the docs say:
Starting in Gecko 18 (Firefox 18.0 / Thunderbird 18.0 / SeaMonkey 2.15 / Firefox OS 1.0.1), you should no longer use either this service or nsIToolkitProfile
Why:
I am interested to do this because I think it could be used to get independent executables of Firefox running pretty easily (e.g., so one can have a wholly separate icon in the task bar for each app) without the need for the now defunct Prism/Chromeless/WebRunner projects.
My approach would be to create a Firefox add-on which allowed the user to specify a web app URL and then would auto-create for them a namespaced profile like "Executable1", "Executable2", etc. for the app as well as a batch file which would invoke the command line "-no-remote" argument against that profile and app (since -no-remote seems to require a profile to create a new instance (the "-new-instance" argument I have seen mentioned in a bug does not seem to work for me).
Firefox can be started on the command line with a path to a profile directory: firefox --profile path/to/directory . If the directory does not exist it will be created. A profile created like this will not be picked up by the Profile Manager.
The file location is "%APPDATA%\Mozilla\Firefox\Profiles". Simply copy that, throw it on a flash drive, and then move it to the same location on the new machine.
To start the Profile Manager, type firefox.exe -P into a command window.
My guess is that people either wanted to avoid main-thread I/O. Or there were talks to remove the profile manager from the app to make startup faster and simplify startup code in general, so that might be the reason. Seems like wiki user "victorporof" did make this edit, so you probably should ping him for an explanation (IIRC, he's got an @mozilla.com address you could easily google ;)
Anyway, a new profile isn't much more than an empty directory. The application will actually copy/create missing files as soon as it starts. So your add-on could just:
-no-remote -profile $dir
I regularly do stuff like this from command line, e.g.
mkdir -p central.profile && path/to/firefox -no-remote -profile $PWD/central.profile
Or just continue using nsITOolkitProfileService
until it is actually removed. (That's what I would probably do). FWIW, there is even newish code still using it, like the (remote) debugger.
Also, might worth having a look at the standalone profile manager they coded up.
So according to Neil from ask.m.o he said that the message saying not to use this service was auto put there when they made OS.File. It added that message falsely to this page. The service is available but OS.File is the prefered way. So I created some functions to do it with OS.File
LINK TO TOPIC: ask.m.o: OS.File instead of nsiToolkitProfileService?
Here it is: https://gist.github.com/yajd/9791029
It's still a work in progress needs much more fine tuning which I did in my addon Profilist, I'll release that soon and then post it here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With