Closed
Bug 756131
Opened 12 years ago
Closed 12 years ago
API for creating default profiles for webapps
Categories
(Toolkit :: General, defect)
Tracking
()
RESOLVED
FIXED
People
(Reporter: smaug, Assigned: smaug)
References
Details
Attachments
(1 file, 7 obsolete files)
27.83 KB,
patch
|
benjamin
:
review+
|
Details | Diff | Splinter Review |
To be able to pre-populate webapps appcache, we need to be able to create the profile during installation. If the following is run in FF, FF's default profile ends up to $HOME/.mozilla/foobarapp/{salt}.default If "Mozilla" is not use, it will be in $HOME/.foobarapp/{salt}.default var currentDefaultProfile = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).get("profDef", Components.interfaces.nsIFile); var ts = Components.classes["@mozilla.org/toolkit/profile-service;1"].getService(Components.interfaces.nsIToolkitProfileService); ts.createDefaultProfileForApp("FooBarApp", "Mozilla", currentDefaultProfile); I just realized I'm missing still profile.ini handling.
Attachment #624783 -
Flags: feedback?(benjamin)
Assignee | ||
Comment 1•12 years ago
|
||
Attachment #624783 -
Attachment is obsolete: true
Attachment #624783 -
Flags: feedback?(benjamin)
Attachment #624823 -
Flags: feedback?(benjamin)
Assignee | ||
Comment 2•12 years ago
|
||
https://tbpl.mozilla.org/?tree=Try&rev=e8ba9b56835d Hopefully it compiles on Windows so that I can try creating profile for a web app before launching it.
Assignee | ||
Comment 3•12 years ago
|
||
Ah, webapps do something a bit strange. profiles.ini is in directory Foo, but profile in Foo/Profiles/salt.default
Assignee | ||
Comment 4•12 years ago
|
||
Er, my mistake. Doesn't help that I can use only linux for development :)
Assignee | ||
Comment 5•12 years ago
|
||
Attachment #624823 -
Attachment is obsolete: true
Attachment #624823 -
Flags: feedback?(benjamin)
Attachment #624926 -
Flags: feedback?(felipc)
Assignee | ||
Comment 6•12 years ago
|
||
Attachment #624926 -
Attachment is obsolete: true
Attachment #624926 -
Flags: feedback?(felipc)
Attachment #624946 -
Flags: feedback?(felipc)
Assignee | ||
Comment 7•12 years ago
|
||
https://tbpl.mozilla.org/?tree=Try&rev=b332f63d0ea5
Comment 8•12 years ago
|
||
Comment on attachment 624946 [details] [diff] [review] v4 I tested v4 of the patch using that try build. It created the Path=Profiles/asfda.default correctly in the .ini file, and created the folder at appname/Profiles/asfda.default as expected, however the folder it created is empty
Attachment #624946 -
Flags: feedback?(felipc)
Assignee | ||
Comment 9•12 years ago
|
||
did you pass the 3rd parameter to the method?
Assignee | ||
Comment 10•12 years ago
|
||
(Since I thought the v3 did copy the default profile files even on Windows, and v4 shouldn't change that, only profiles.ini handling.)
Assignee | ||
Comment 11•12 years ago
|
||
Ok, I get the same problem :(
Assignee | ||
Comment 12•12 years ago
|
||
How strange. If I change the #ifdef which creates Profiles directory, I still get the right profile on Linux.
Assignee | ||
Comment 13•12 years ago
|
||
Somewhat random guess. Ensure that Profiles directory exists before copying anything under it. https://tbpl.mozilla.org/?tree=Try&rev=6c6d1e49f9b9
Attachment #624946 -
Attachment is obsolete: true
Assignee | ||
Updated•12 years ago
|
Attachment #624946 -
Attachment is obsolete: false
Assignee | ||
Comment 14•12 years ago
|
||
Comment on attachment 625115 [details] [diff] [review] v5 this doesn't help. So v4 is still the best one. Need to figure out why right files aren't copied. Is rv = profileDefaultsDir->CopyTo(profileDirParent, profileDirName); in nsToolkitProfileService not executed or does it fail
Attachment #625115 -
Attachment is obsolete: true
Assignee | ||
Comment 15•12 years ago
|
||
Felipe, or anyone with Windows dev environment, I could need some help here.
Blocks: 756620
Comment 16•12 years ago
|
||
Smaug: does this seem like a timing issue and the patch v3 when I tried just worked by luck? or is there something that changed between v3 and v4 that could have caused it to fail? I'll debug it soon
Comment 17•12 years ago
|
||
ooh wait I second, when I build the patch myself (v4) it works.. when I use the try build it didn't (I'll try it again).. maybe this is a packaging issue
Comment 18•12 years ago
|
||
indeed, currentDefaultProfile.exists() is false on a packaged build
Assignee | ||
Comment 19•12 years ago
|
||
Bizarre. But ok, so Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).get("profDef", Components.interfaces.nsIFile); is wrong.
Assignee | ||
Comment 20•12 years ago
|
||
Does default profile handling work with packaged builds at all? Need to test.
Assignee | ||
Comment 21•12 years ago
|
||
That is indeed true, at least on linux. Files don't get created when profile is created. When using own build, the files are created when the profile is.
Assignee | ||
Comment 22•12 years ago
|
||
Comment on attachment 624946 [details] [diff] [review] v4 I'm not going to fix that behavior in this bug. This should give similar to current webapp profiles when the 2 latter parameters are omitted.
Attachment #624946 -
Flags: review?(benjamin)
Assignee | ||
Comment 23•12 years ago
|
||
...and if webapps need a default profile, some new, non-packaged stuff can be added to Firefox installation.
Assignee | ||
Comment 24•12 years ago
|
||
Comment on attachment 624946 [details] [diff] [review] v4 But I want to change the API :/ The method should give two nsIFiles out, the rootdir and localdir. I believe appCache stores data in localDir
Attachment #624946 -
Flags: review?(benjamin)
Assignee | ||
Comment 25•12 years ago
|
||
This is pretty flexible. The appname and optional vendor name are passed to nsXREDirProvider so that right kind of directory hierarchy can be created. aProfileDefaultsDir lets one to define where the "template" for the profile is. https://tbpl.mozilla.org/?tree=Try&rev=b0097709a637
Attachment #624946 -
Attachment is obsolete: true
Attachment #625426 -
Flags: review?(benjamin)
Comment 26•12 years ago
|
||
Comment on attachment 625426 [details] [diff] [review] v6, reuse nsIToolkitProfile Since webrt overrides the normal system in nsXREAppData: http://mxr.mozilla.org/mozilla-central/source/webapprt/win/webapprt.cpp#289 So in order to do this with the same logic as nsXREDirProvider::AppendProfilePath you really need appname, vendor, and "profile" from nsXREAppData, and vendor name really shouldn't be optional in the IDL. I think the rest of the patch is fine, but I'd like some comments in nsXREDirProvider.h explaining why we need to pass in directories to the methods like GetUserDataDirectory and such.
Attachment #625426 -
Flags: review?(benjamin) → review-
Assignee | ||
Comment 27•12 years ago
|
||
(In reply to Benjamin Smedberg [:bsmedberg] from comment #26) > Comment on attachment 625426 [details] [diff] [review] > v6, reuse nsIToolkitProfile > > Since webrt overrides the normal system in nsXREAppData: > http://mxr.mozilla.org/mozilla-central/source/webapprt/win/webapprt.cpp#289 > > So in order to do this with the same logic as > nsXREDirProvider::AppendProfilePath you really need appname, vendor, and > "profile" from nsXREAppData, and vendor name really shouldn't be optional in > the IDL. Vendor is optional in the other cases. Why not here?
Comment 28•12 years ago
|
||
I think that the caller should specify it, whether it is null or a value.
Assignee | ||
Comment 29•12 years ago
|
||
https://tbpl.mozilla.org/?tree=Try&rev=2a0484aab586
Attachment #625426 -
Attachment is obsolete: true
Attachment #626166 -
Flags: review?(benjamin)
Assignee | ||
Comment 30•12 years ago
|
||
Maybe this even compiles on platforms I can't build on. https://tbpl.mozilla.org/?tree=Try&rev=03b29673813f
Attachment #626166 -
Attachment is obsolete: true
Attachment #626166 -
Flags: review?(benjamin)
Attachment #626192 -
Flags: review?(benjamin)
Comment 31•12 years ago
|
||
Comment on attachment 626192 [details] [diff] [review] +compilation fixes + nsresult rv = GetUserDataDirectory((nsILocalFile**)(nsIFile**) + getter_AddRefs(file), Darktrojan is fixing most of this in bug 749930, but if you can just change GetUserDataDirectory to nsIFile while you're here this will avoid the terrible terrible casting.
Attachment #626192 -
Flags: review?(benjamin) → review+
Assignee | ||
Comment 32•12 years ago
|
||
IIRC I tried that but I would have had to change plenty of other code too.
Assignee | ||
Comment 33•12 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/4f66e59eaa77
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•