Refactor fake services so it's easier to add more [r=Mardak]

Created a FakeSvc object to put fake services into.
This commit is contained in:
Paul O’Shannessy 2010-03-02 11:07:30 -08:00
Родитель e61f767c9c
Коммит 25fc7e8e9e
1 изменённых файлов: 13 добавлений и 12 удалений

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

@ -325,24 +325,17 @@ let Utils = {
// Try creating a fake service if we can handle that
if (!Cc[cid]) {
switch (cid) {
case "@mozilla.org/privatebrowsing;1":
svc = {
autoStarted: false,
privateBrowsingEnabled: false
};
break;
}
svc = FakeSvc[cid];
let log = Log4Moz.repository.getLogger("Service.Util");
if (svc == null)
log.warn("Component " + cid + " doesn't exist on this platform.");
else
if (svc)
log.debug("Using a fake svc object for " + cid);
else
log.warn("Component " + cid + " doesn't exist on this platform.");
}
else
svc = Cc[cid].getService(iface);
return dest[prop] = svc;
};
dest.__defineGetter__(prop, getter);
@ -789,6 +782,14 @@ let Utils = {
}
};
let FakeSvc = {
// Private Browsing
"@mozilla.org/privatebrowsing;1": {
autoStarted: false,
privateBrowsingEnabled: false
}
};
/*
* Commonly-used services
*/