Comment 4 for bug 288236

Revision history for this message
In , John-p-baker (john-p-baker) wrote :

There is already a privacy.item.siteprefs preference (bug 274712) it looks as if an alternate way would be to add |siteprefs: {...}| to 'items' and add the preference to the 'Clear Private Data' Dialog and Options. This would allow removing to be optional.

+ try {
+ var cps = Components.classes["@mozilla.org/content-pref/service;1"].
+ getService(Components.interfaces.nsIContentPrefService);
+ var dbConnection = cps.DBConnection;
+
+ try {
+ dbConnection.beginTransaction();
+ // Group records are the ones that contain hostnames, but we must
+ // remove pref records as well, since they depend on group records.
+ dbConnection.executeSimpleSQL("DELETE FROM prefs");
+ dbConnection.executeSimpleSQL("DELETE FROM groups");
+ dbConnection.commitTransaction();
+ }
+ catch(e) {
+ dbConnection.rollbackTransaction();
+ throw e;
+ }
+ }
+ catch (e) { Components.utils.reportError(e); }

I am not sure that I like sanatize.js to have to know about the database; I think that I would prefer this to be in nsIContentPrefService.

Applying both would give something like:

   siteprefs: {
     clear: function ()
       {
         var cps = Components.classes["@mozilla.org/content-pref/service;1"].
                   getService(Components.interfaces.nsIContentPrefService);
         cps.clear();
       },

     get canClear()
       {
         return true;
       }
     },

[Presumably bug 380852 could then add more calls into the clear function.]