Bug 572436 - Get rid of app-specific hacks (switch (Svc.AppInfo.ID)) in sync library [r=mconnor]

Set relevant default preferences programmatically in app specific overlays, making app-specific code paths in the sync library unnecessary.
This commit is contained in:
Philipp von Weitershausen 2010-06-16 23:11:40 +01:00
parent fc5e76f590
commit 6a68634cbf
4 changed files with 14 additions and 35 deletions

View File

@ -139,21 +139,7 @@ ClientEngine.prototype = {
},
set localName(value) Svc.Prefs.set("client.name", value),
get localType() {
// Figure out if we have a type previously set
let localType = Svc.Prefs.get("client.type", "");
if (localType == "") {
// Assume we're desktop-like unless the app is for mobiles
localType = "desktop";
switch (Svc.AppInfo.ID) {
case FENNEC_ID:
localType = "mobile";
break;
}
this.localType = localType;
}
return localType;
},
get localType() Svc.Prefs.get("client.type", "desktop"),
set localType(value) Svc.Prefs.set("client.type", value),
isMobile: function isMobile(id) {

View File

@ -55,6 +55,8 @@ function Preferences(args) {
if (isObject(args)) {
if (args.branch)
this._prefBranch = args.branch;
if (args.defaultBranch)
this._defaultBranch = args.defaultBranch;
if (args.site)
this._site = args.site;
}
@ -429,10 +431,15 @@ Preferences.prototype = {
* @private
*/
get _prefSvc() {
let prefSvc = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefService).
getBranch(this._prefBranch).
QueryInterface(Ci.nsIPrefBranch2);
let prefSvc = Cc["@mozilla.org/preferences-service;1"]
.getService(Ci.nsIPrefService);
if (this._defaultBranch) {
prefSvc = prefSvc.getDefaultBranch(this._prefBranch);
} else {
prefSvc = prefSvc.getBranch(this._prefBranch)
.QueryInterface(Ci.nsIPrefBranch2);
}
this.__defineGetter__("_prefSvc", function() prefSvc);
return this._prefSvc;
},

View File

@ -394,24 +394,9 @@ WeaveSvc.prototype = {
let pref = Svc.Prefs.get("registerEngines");
if (pref) {
engines = pref.split(",");
} else {
// Fallback for the add-on case
switch (Svc.AppInfo.ID) {
case FENNEC_ID:
engines = ["Tab", "Bookmarks", "Form", "History", "Password"];
break;
case FIREFOX_ID:
engines = ["Bookmarks", "Form", "History", "Password", "Prefs", "Tab"];
break;
case SEAMONKEY_ID:
engines = ["Form", "History", "Password", "Tab"];
break;
}
}
// Grab the actual engine and register them
// Grab the actual engines and register them
Engines.register(engines.map(function(name) Weave[name + "Engine"]));
},

View File

@ -899,6 +899,7 @@ Utils.lazySvc(FakeSvc, "@labs.mozilla.com/Weave/Crypto;2",
*/
let Svc = {};
Svc.Prefs = new Preferences(PREFS_BRANCH);
Svc.DefaultPrefs = new Preferences({branch: PREFS_BRANCH, defaultBranch: true});
Svc.Obs = Observers;
[["Annos", "@mozilla.org/browser/annotation-service;1", "nsIAnnotationService"],
["AppInfo", "@mozilla.org/xre/app-info;1", "nsIXULAppInfo"],