Bug 561005 - Use FakeSvc to grab binary crypto if js-ctypes doesn't work [r=zpao r=mconnor]

Lazily load the binary component service onto FakeSvc if ;2 fails to register on Svc.
This commit is contained in:
Edward Lee 2010-04-28 16:36:41 -07:00
Родитель 2a8342da17
Коммит 29159af867
1 изменённых файлов: 6 добавлений и 19 удалений

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

@ -857,34 +857,21 @@ let FakeSvc = {
}
};
// Use the binary WeaveCrypto (;1) if the js-ctypes version (;2) fails to load
// by adding an alias on FakeSvc from ;2 to ;1
Utils.lazySvc(FakeSvc, "@labs.mozilla.com/Weave/Crypto;2",
"@labs.mozilla.com/Weave/Crypto;1", "IWeaveCrypto");
/*
* Commonly-used services
*/
let cryptoContractID = "@labs.mozilla.com/Weave/Crypto";
{
let versSvc = Cc["@mozilla.org/xpcom/version-comparator;1"].
getService(Ci.nsIVersionComparator);
let appinfo = Cc["@mozilla.org/xre/app-info;1"].
getService(Ci.nsIXULAppInfo);
let platVers = appinfo.platformVersion;
if (versSvc.compare(platVers, "1.9.3a3") < 0) {
// use old binary component
cryptoContractID += ";1";
} else {
// use new JS-CTypes component
cryptoContractID += ";2";
}
}
let Svc = {};
Svc.Prefs = new Preferences(PREFS_BRANCH);
Svc.Obs = Observers;
[["Annos", "@mozilla.org/browser/annotation-service;1", "nsIAnnotationService"],
["AppInfo", "@mozilla.org/xre/app-info;1", "nsIXULAppInfo"],
["Bookmark", "@mozilla.org/browser/nav-bookmarks-service;1", "nsINavBookmarksService"],
["Crypto", cryptoContractID, "IWeaveCrypto"],
["Crypto", "@labs.mozilla.com/Weave/Crypto;2", "IWeaveCrypto"],
["Directory", "@mozilla.org/file/directory_service;1", "nsIProperties"],
["Env", "@mozilla.org/process/environment;1", "nsIEnvironment"],
["Favicon", "@mozilla.org/browser/favicon-service;1", "nsIFaviconService"],