Closed Bug 564675 Opened 14 years ago Closed 7 years ago

Allow bootstrapped add-ons to have default preferences

Categories

(Toolkit :: Add-ons Manager, defect)

defect
Not set
normal

Tracking

()

RESOLVED WONTFIX

People

(Reporter: jwkbugzilla, Unassigned)

References

Details

(Whiteboard: [rewrite])

Requiring bootstrapped add-ons to have no default preferences is another issue for migration of existing add-ons. One solution would be nsIPrefServiceInternal interface to allow adding and removing default preferences files dynamically.
Whiteboard: [rewrite]
Depends on: 542385
Blocks: 597843
For now restartless add-ons can use the default branch to set these defaults, but note that these need to be re-set on each run, e.g.:

http://github.com/mozilla/prospector/commit/398e5d86935149c5531bd5ac38d6d1049d4def17
Nice trick, somehow I didn't expect the default branch to be writable. So there is a relatively simple work-around here. For an extension that needs to stay compatible with Firefox 3.6 one would probably load the default preferences file into a sandbox, with the pref() function on that sandbox looking very similar to your setDefaultPrefs() function. The only problem is reverting these changes since in theory different extensions might touch the same prefs - not an issue for your own extension but probably something to consider when adding this functionality to the add-on manager.
No longer blocks: 597843
Can you not use the reload-default-prefs observer notification to do this?
(In reply to comment #3)
> Can you not use the reload-default-prefs observer notification to do this?

Right now bootstrapped add-on pref directories don't appear in the directory service entries that the pref service loads from so that wouldn't work.
Blocks: 645207
For those that want to use defaults/preferences/* in restartless addon not using sdk - here is my workaround:

https://gist.github.com/oshybystyi/8cf882bc8b0c9a95a116
The existing example at MDN [1] accomplishes the same feat without relying on regular expressions to parse JavaScript function calls. The pref loader module in Firebug takes it a step further, ensuring that default preferences are cleaned up in the event that the extension is uninstalled. [2]

[1] https://developer.mozilla.org/en-US/Add-ons/How_to_convert_an_overlay_extension_to_restartless#Step_4.3A_Manually_handle_default_preferences
[2] https://github.com/firebug/firebug/blob/master/extension/modules/prefLoader.js
(In reply to Minh Nguyen from comment #7)
> The existing example at MDN [1] accomplishes the same feat without relying
> on regular expressions to parse JavaScript function calls. The pref loader
> module in Firebug takes it a step further, ensuring that default preferences
> are cleaned up in the event that the extension is uninstalled. [2]
> 
> [1]
> https://developer.mozilla.org/en-US/Add-ons/
> How_to_convert_an_overlay_extension_to_restartless#Step_4.
> 3A_Manually_handle_default_preferences
> [2]
> https://github.com/firebug/firebug/blob/master/extension/modules/prefLoader.
> js

Thanks for the review Minh. I introduced few changes into https://gist.github.com/oshybystyi/8cf882bc8b0c9a95a116#comment-1439795

In short: removed regex and added clearDefaultPrefs()
As bootstrapped add-ons will go away with Firefox 57, I assume this can be marked as WONTFIX, right?

Sebastian
Flags: needinfo?(amckay)
Yup.
Status: NEW → RESOLVED
Closed: 7 years ago
Flags: needinfo?(amckay)
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.