Bug 445753 - "Rewrite" <nsSidebar.js> |function srGetStrBundle()|; Bv2-FF; r=gavin.sharp

This commit is contained in:
Serge Gautherie 2008-09-06 18:56:23 +02:00
Родитель 2c2734e433
Коммит 08abed87fb
1 изменённых файлов: 27 добавлений и 34 удалений

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

@ -98,11 +98,11 @@ function (aTitle, aContentURL, aCustomizeURL)
{
debug("addPanel(" + aTitle + ", " + aContentURL + ", " +
aCustomizeURL + ")");
return this.addPanelInternal(aTitle, aContentURL, aCustomizeURL, false);
}
nsSidebar.prototype.addPersistentPanel =
nsSidebar.prototype.addPersistentPanel =
function(aTitle, aContentURL, aCustomizeURL)
{
debug("addPersistentPanel(" + aTitle + ", " + aContentURL + ", " +
@ -272,12 +272,13 @@ nsSidebar.prototype.getHelperForLanguage = function(count) {return null;}
nsSidebar.prototype.QueryInterface =
function (iid) {
if (!iid.equals(nsISidebar) &&
!iid.equals(nsISidebarExternal) &&
!iid.equals(nsIClassInfo) &&
!iid.equals(nsISupports))
throw Components.results.NS_ERROR_NO_INTERFACE;
return this;
if (iid.equals(nsISidebar) ||
iid.equals(nsISidebarExternal) ||
iid.equals(nsIClassInfo) ||
iid.equals(nsISupports))
return this;
throw Components.results.NS_ERROR_NO_INTERFACE;
}
var sidebarModule = new Object();
@ -288,24 +289,25 @@ function (compMgr, fileSpec, location, type)
debug("registering (all right -- a JavaScript module!)");
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
compMgr.registerFactoryLocation(SIDEBAR_CID,
compMgr.registerFactoryLocation(SIDEBAR_CID,
"Sidebar JS Component",
SIDEBAR_CONTRACTID,
fileSpec,
SIDEBAR_CONTRACTID,
fileSpec,
location,
type);
const CATMAN_CONTRACTID = "@mozilla.org/categorymanager;1";
const nsICategoryManager = Components.interfaces.nsICategoryManager;
var catman = Components.classes[CATMAN_CONTRACTID].
getService(nsICategoryManager);
const JAVASCRIPT_GLOBAL_PROPERTY_CATEGORY = "JavaScript global property";
catman.addCategoryEntry(JAVASCRIPT_GLOBAL_PROPERTY_CATEGORY,
"sidebar",
SIDEBAR_CONTRACTID,
true,
true);
catman.addCategoryEntry(JAVASCRIPT_GLOBAL_PROPERTY_CATEGORY,
"external",
SIDEBAR_CONTRACTID,
@ -317,10 +319,10 @@ sidebarModule.getClassObject =
function (compMgr, cid, iid) {
if (!cid.equals(SIDEBAR_CID))
throw Components.results.NS_ERROR_NO_INTERFACE;
if (!iid.equals(Components.interfaces.nsIFactory))
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
return sidebarFactory;
}
@ -330,7 +332,7 @@ function(compMgr)
debug("Unloading component.");
return true;
}
/* factory object */
var sidebarFactory = new Object();
@ -354,24 +356,15 @@ if (DEBUG)
else
debug = function (s) {}
var strBundleService = null;
// String bundle service
var gStrBundleService = null;
function srGetStrBundle(path)
{
var strBundle = null;
if (!strBundleService) {
try {
strBundleService =
Components.classes["@mozilla.org/intl/stringbundle;1"].getService();
strBundleService =
strBundleService.QueryInterface(Components.interfaces.nsIStringBundleService);
} catch (ex) {
dump("\n--** strBundleService failed: " + ex + "\n");
return null;
}
}
strBundle = strBundleService.createBundle(path);
if (!strBundle) {
dump("\n--** strBundle createInstance failed **--\n");
}
return strBundle;
if (!gStrBundleService)
gStrBundleService =
Components.classes["@mozilla.org/intl/stringbundle;1"]
.getService(Components.interfaces.nsIStringBundleService);
return gStrBundleService.createBundle(path);
}