Bug 562824 - Add Services.jsm goodness to form manager. r=gavin

This commit is contained in:
Justin Dolske 2010-04-29 18:47:06 -07:00
Родитель ebe0e6a599
Коммит 88727def9f
2 изменённых файлов: 14 добавлений и 40 удалений

Просмотреть файл

@ -2822,6 +2822,7 @@ pref("signon.debug", false);
// Satchel (Form Manager) prefs
pref("browser.formfill.debug", false);
pref("browser.formfill.enable", true);
pref("browser.formfill.expire_days", 180);
pref("browser.formfill.saveHttpsForms", true);
pref("browser.formfill.agedWeight", 2);
pref("browser.formfill.bucketSize", 1);

Просмотреть файл

@ -39,27 +39,18 @@ const Cc = Components.classes;
const Ci = Components.interfaces;
const Cr = Components.results;
const DEFAULT_EXPIRE_DAYS = 180;
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
Components.utils.import("resource://gre/modules/Services.jsm");
function FormAutoComplete() {
this.init();
}
FormAutoComplete.prototype = {
classDescription: "FormAutoComplete",
contractID: "@mozilla.org/satchel/form-autocomplete;1",
classID: Components.ID("{c11c21b2-71c9-4f87-a0f8-5e13f50495fd}"),
QueryInterface : XPCOMUtils.generateQI([Ci.nsIFormAutoComplete, Ci.nsISupportsWeakReference]),
__logService : null, // Console logging service, used for debugging.
get _logService() {
if (!this.__logService)
this.__logService = Cc["@mozilla.org/consoleservice;1"].
getService(Ci.nsIConsoleService);
return this.__logService;
},
classDescription : "FormAutoComplete",
contractID : "@mozilla.org/satchel/form-autocomplete;1",
classID : Components.ID("{c11c21b2-71c9-4f87-a0f8-5e13f50495fd}"),
QueryInterface : XPCOMUtils.generateQI([Ci.nsIFormAutoComplete, Ci.nsISupportsWeakReference]),
__formHistory : null,
get _formHistory() {
@ -69,14 +60,6 @@ FormAutoComplete.prototype = {
return this.__formHistory;
},
__observerService : null, // Observer Service, for notifications
get _observerService() {
if (!this.__observerService)
this.__observerService = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
return this.__observerService;
},
_prefBranch : null,
_debug : false, // mirrors browser.formfill.debug
_enabled : true, // mirrors browser.formfill.enable preference
@ -90,23 +73,22 @@ FormAutoComplete.prototype = {
init : function() {
// Preferences. Add observer so we get notified of changes.
this._prefBranch = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefService).getBranch("browser.formfill.");
this._prefBranch = Services.prefs.getBranch("browser.formfill.");
this._prefBranch.QueryInterface(Ci.nsIPrefBranch2);
this._prefBranch.addObserver("", this.observer, false);
this.observer._self = this;
this._debug = this._prefBranch.getBoolPref("debug");
this._enabled = this._prefBranch.getBoolPref("enable");
this._agedWeight = this._prefBranch.getIntPref("agedWeight");
this._bucketSize = this._prefBranch.getIntPref("bucketSize");
this._debug = this._prefBranch.getBoolPref("debug");
this._enabled = this._prefBranch.getBoolPref("enable");
this._agedWeight = this._prefBranch.getIntPref("agedWeight");
this._bucketSize = this._prefBranch.getIntPref("bucketSize");
this._maxTimeGroupings = this._prefBranch.getIntPref("maxTimeGroupings");
this._timeGroupingSize = this._prefBranch.getIntPref("timeGroupingSize") * 1000 * 1000;
this._expireDays = this._getFormExpiryDays();
this._expireDays = this._prefBranch.getIntPref("expire_days");
this._dbStmts = [];
this._observerService.addObserver(this.observer, "xpcom-shutdown", false);
Services.obs.addObserver(this.observer, "xpcom-shutdown", false);
},
observer : {
@ -166,7 +148,7 @@ FormAutoComplete.prototype = {
if (!this._debug)
return;
dump("FormAutoComplete: " + message + "\n");
this._logService.logStringMessage("FormAutoComplete: " + message);
Services.console.logStringMessage("FormAutoComplete: " + message);
},
@ -359,15 +341,6 @@ FormAutoComplete.prototype = {
return stmt;
},
_getFormExpiryDays : function () {
let prefsBranch = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch);
if (prefsBranch.prefHasUserValue("browser.formfill.expire_days"))
return prefsBranch.getIntPref("browser.formfill.expire_days");
else
return DEFAULT_EXPIRE_DAYS;
},
/*
* _calculateScore
*