Default Preferences in a Firefox Bootstrapped Addon -


firefox bootstrapped addons not read default preferences overlay addons.
understand need of manually setting default preferences when bootstrapped addon installed.

after initial installation, guess benefit of setting default preferences enable reset preferences (unless ff keeps track of elsewhere).

question is, default preference have read , set on each startup()?
if so, going saved (ie getdefaultbranch() data from)?

reference:
how convert overlay extension restartless
a brief guide mozilla preferences
restartless add-ons default preferences
preferences

i have been given answer via email posting here verbatim benefit of users.

from dave garrett, developer of flagfox , author of how convert overlay extension restartless

default prefs set during runtime saved nowhere. there no on disk cache of default prefs.

on firefox start, default prefs read various locations preferences system. (firefox has own in omni.ja & addons have theirs in install folders/files) copy of branch maintained user prefs read prefs.js overwritten it. setting of (user) prefs changes state in prefs system, (eventually) recorded in prefs.js (again, non-default pref values saved). setting of default prefs changes state in prefs system, not saved anywhere. need loaded on every start. old standard default prefs system, firefox loaded them on every start you. restartless extensions need yourself. every addon startup needs load default prefs.

you can of course use prefs without having default @ all, you'd have hardcode default values in code on place. implementing default prefs system restartless addons far cleaner solution avoids mistakes otherwise make.

as prefs system stores non-default prefs disk, can improve efficiency in saving prefs once they're put default reason. example, i've got json blob in string pref. (as of v5.0 it's compacted now) if user alters needs saved there changing in options dialog, json blob stored in prefs.js in full. if user reverts change, json blob reverted prior value. if equivalent whatever default value is, prefs.js stores no value , default used. reduces needs loaded on start prefs.js in default case. in fact, can use prefs api detect if value set default , entirely bypass loading packed json user pref , go directly full json file, in case don't need load prefs system. it's optimization applicable in cases this, it's example why using defaults can useful.

regarding removal of default preferences on shutdown()

generally no, don't need remove default preferences on shutdown, though there's legitimate argument might correct (but maybe bad idea). clear, there's few separate cases of shutdown take account:

1) firefox shutdown + addon shutdown: in case should not doing shutdown isn't needed preserve data. no need unload stuff app shutdown in progress , it'll you.

2) addon shutdown due addon update: in case need unload you've loaded next version can load cleanly. however, there's no need worry default preferences here, generally. new version's loaded , overwrite old. (unless default has been removed, in case linger in memory doing nothing)

3) addon shutdown due addon disable: leaving default prefs loaded here hurts nothing other tiny amount of memory take up. if have lot of prefs guess unloading them might warranted, not use case going come often. wouldn't worry unloading prefs @ unless either have way many prefs or prefs large you're getting warnings in browser error console them being big. (in case should fix that)

even if might idea clean default prefs on shutdown, deleting default pref has user pref might break things. suggest leaving them alone.


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -