Site-Specific Preferences: Difference between revisions

Jump to navigation Jump to search
formatting fixes, some additional info
(define setting and preference; make purpose statement crisper)
(formatting fixes, some additional info)
Line 160: Line 160:
=== Core Methods ===
=== Core Methods ===


The service's core API comprises the following four methods:
The service's core API comprises the following four methods for accessing prefs:
   
   
   nsIVariant getPref(in nsIURI uri, in AString name);
   nsIVariant getPref(in nsIURI uri, in AString name);
Line 167: Line 167:
   void removePref(in nsIURI uri, in AString name);
   void removePref(in nsIURI uri, in AString name);


All four methods take as input a URI belonging to the site in question and a name for the preference.  The service is responsible for extracting the name of the site from the URI.
All four methods take as input a URI belonging to the site in question and a name for the preference.  The service is responsible for extracting the name of the site from the URI.  The service defines a site as an effective domain (ETLD+1).


Question: should we make the consumer responsible for extracting site names from URIs so consumers can set preferences for non-standard groupings?
<b>Should the consumer be responsible for extracting site names from URIs so that consumers can set preferences for non-standard site groupings? Or should it be possible for consumers to register a grouper with the service that handles non-standard groupings for certain prefs/URIs?</b>


The name of the preference is an arbitrary string.  Preference namespacing is the responsibility of the consumer, as it is with the application-wide preferences accessed via nsIPrefBranch.
The name of the preference is an arbitrary string.  Preference namespacing is the responsibility of the consumer, as it is with application-wide preferences accessed via nsIPrefBranch.


The setPref method also takes as input an nsIVariant representing the value of the preference, while the getPref method returns such an nsIVariant.  Consumers can set the value of a preference to null (nsIVariant::VTYPE_EMPTY), and the service distinguishes between preferences set to null and those that have not been set by representing the latter as the undefined value (nsIVariant::VTYPE_VOID).
The setPref method also takes as input an nsIVariant representing the value of the preference, while the getPref method returns such an nsIVariant.  Consumers can set the value of a preference to <var>null</var> (nsIVariant::VTYPE_EMPTY), and the service distinguishes between preferences set to <var>null</var> and those that have not been set at all by representing the latter with the <var>undefined</var> value (nsIVariant::VTYPE_VOID).


Consumers can pass null as the value of the uri parameter to access a global preference (one which does not belong to any specific group), which they can use when a site-specific pref is not available.
Consumers can pass <var>null</var> as the value of the uri parameter to access a global preference.


=== Getting All Prefs ===
=== Getting All Prefs ===
canmove, Confirmed users
2,056

edits

Navigation menu