mozilla

Compare Revisions

Preferences

Change Revisions

Revision 44029:

Revision 44029 by leuqarte on

Revision 44030:

Revision 44030 by ericjung on

Title:
Preferences
Preferences
Slug:
Code_snippets/Preferences
Code_snippets/Preferences
Tags:
Extensions, Add-ons, "Code snippets"
Extensions, Add-ons, "Code snippets"
Content:

Revision 44029
Revision 44030
n281      <strong>Note:</strong> During Gecko 1.8 development, <code>n281      <strong>Note:</strong> During Gecko 1.8 development, <code>
>nsIPrefBranchInternal</code> was renamed to <code>nsIPrefBranch2<>nsIPrefBranchInternal</code> was renamed to <code>nsIPrefBranch2<
>/code> <a class="link-https" href="https://bugzilla.mozilla.org/s>/code> <a class="link-https" href="https://bugzilla.mozilla.org/s
>how_bug.cgi?id=281414">and was frozen. <code>nsIPrefBranchInterna>how_bug.cgi?id=281414"></a> and was frozen. <code>nsIPrefBranchIn
>l</code> name is still supported in Gecko 1.8, so this is what yo>ternal</code> name is still supported in Gecko 1.8, so this is wh
>u should use in extensions that need to be compatible with Gecko >at you should use in extensions that need to be compatible with G
>1.7 <em>and</em> Gecko 1.8 (Firefox 1.0/1.5). For newer extension>ecko 1.7 <em>and</em> Gecko 1.8 (Firefox 1.0/1.5). For newer exte
>s use</a> <a class="external" href="http://xulplanet.com/referenc>nsions use <a class="external" href="http://xulplanet.com/referen
>es/xpcomref/ifaces/nsIPrefBranch2.html"><code>nsIPrefBranch2</cod>ces/xpcomref/ifaces/nsIPrefBranch2.html"><code>nsIPrefBranch2</co
>e></a>.>de></a>.
tt329    <div class="warning">
330      You need to keep a reference to the preference branch you a
 >re observing (unless it is the root branch) or it will get garbag
 >e collected and never notify you. After it's garbage collected, y
 >ou won't receive notifications anymore. So, <u><strong>don't writ
 >e something like this</strong></u>:<code><br></code>
331    </div>
332    <pre>
333<code>Components.classes["@mozilla.org/preferences-service;1"].ge
 >tService(Components.interfaces.nsIPrefService).getBranch("myexten
 >sion.prefs.")   .QueryInterface(Components.interfaces.nsIPrefBran
 >ch2).addObserver("", this, false);</code>
334</pre>

Back to History