mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
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:
parent
e61f767c9c
commit
25fc7e8e9e
@ -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
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user