static nsresult GetChromeLocale(PRUnichar** localeName);  static nsresult GetCurrentProcessDirectory(nsILocalFile** aFile);        static NS_DEFINE_CID(kChromeRegistryCID,    NS_CHROMEREGISTRY_CID);          #if XP_MAC  #define DEFAULTS_DIR_NAME           "Defaults"  #define DEFAULTS_PREF_DIR_NAME      "Pref"  #define DEFAULTS_PROFILE_DIR_NAME   "Profile"  #define RES_DIR_NAME                "Res"  #define CHROME_DIR_NAME             "Chrome"  #define PLUGINS_DIR_NAME            "Plugins"  #define SEARCH_DIR_NAME             "Search Plugins"  #else  #define DEFAULTS_DIR_NAME           "defaults"  #define DEFAULTS_PREF_DIR_NAME      "pref"  #define DEFAULTS_PROFILE_DIR_NAME   "profile"  #define RES_DIR_NAME                "res"  #define CHROME_DIR_NAME             "chrome"  #define PLUGINS_DIR_NAME            "plugins"  #define SEARCH_DIR_NAME             "searchplugins"  #endif            PRInt32 nsAppFileLocationProvider::sInstanceCount = 0;    nsIAtom* nsAppFileLocationProvider::sApp_DefaultsFolder50        = nsnull;  nsIAtom* nsAppFileLocationProvider::sApp_PrefDefaultsFolder50    = nsnull;  nsIAtom* nsAppFileLocationProvider::sApp_ProfileDefaultsFolder50 = nsnull;  nsIAtom* nsAppFileLocationProvider::sApp_ProfileDefaultsNoLocFolder50 = nsnull;    nsIAtom* nsAppFileLocationProvider::sApp_DefaultUserProfileRoot50 = nsnull;    nsIAtom* nsAppFileLocationProvider::sApp_ResDirectory            = nsnull;  nsIAtom* nsAppFileLocationProvider::sApp_ChromeDirectory         = nsnull;  nsIAtom* nsAppFileLocationProvider::sApp_PluginsDirectory        = nsnull;    nsIAtom* nsAppFileLocationProvider::sApp_SearchDirectory50       = nsnull;            nsAppFileLocationProvider::nsAppFileLocationProvider()
static nsresult GetChromeLocale(PRUnichar** localeName)
static nsresult GetChromeLocale(PRUnichar** localeName);static nsresult GetCurrentProcessDirectory(nsILocalFile** aFile); // IDsstatic NS_DEFINE_CID(kChromeRegistryCID,    NS_CHROMEREGISTRY_CID); // WARNING: These hard coded names need to go away. They need to// come from localizable resources#if XP_MAC#define DEFAULTS_DIR_NAME           "Defaults"#define DEFAULTS_PREF_DIR_NAME      "Pref"#define DEFAULTS_PROFILE_DIR_NAME   "Profile"#define RES_DIR_NAME                "Res"#define CHROME_DIR_NAME             "Chrome"#define PLUGINS_DIR_NAME            "Plugins"#define SEARCH_DIR_NAME             "Search Plugins" #else#define DEFAULTS_DIR_NAME           "defaults"#define DEFAULTS_PREF_DIR_NAME      "pref"#define DEFAULTS_PROFILE_DIR_NAME   "profile"#define RES_DIR_NAME                "res"#define CHROME_DIR_NAME             "chrome"#define PLUGINS_DIR_NAME            "plugins"#define SEARCH_DIR_NAME             "searchplugins" #endif//*****************************************************************************// nsAppFileLocationProvider::Static Variables//*****************************************************************************   PRInt32 nsAppFileLocationProvider::sInstanceCount = 0; nsIAtom* nsAppFileLocationProvider::sApp_DefaultsFolder50        = nsnull;nsIAtom* nsAppFileLocationProvider::sApp_PrefDefaultsFolder50    = nsnull;nsIAtom* nsAppFileLocationProvider::sApp_ProfileDefaultsFolder50 = nsnull;nsIAtom* nsAppFileLocationProvider::sApp_ProfileDefaultsNoLocFolder50 = nsnull;nsIAtom* nsAppFileLocationProvider::sApp_DefaultUserProfileRoot50 = nsnull;nsIAtom* nsAppFileLocationProvider::sApp_ResDirectory            = nsnull;nsIAtom* nsAppFileLocationProvider::sApp_ChromeDirectory         = nsnull;nsIAtom* nsAppFileLocationProvider::sApp_PluginsDirectory        = nsnull;nsIAtom* nsAppFileLocationProvider::sApp_SearchDirectory50       = nsnull;//*****************************************************************************// nsAppFileLocationProvider::Constructor/Destructor//*****************************************************************************   nsAppFileLocationProvider::nsAppFileLocationProvider(){    NS_INIT_ISUPPORTS();        if (sInstanceCount++ == 0) {          // Defaults        sApp_DefaultsFolder50        = NS_NewAtom("app.defaults.directory");        sApp_PrefDefaultsFolder50    = NS_NewAtom("app.pref.default.directory.5");        sApp_ProfileDefaultsFolder50 = NS_NewAtom("app.profile.default.directory.5");        sApp_ProfileDefaultsNoLocFolder50 = NS_NewAtom("app.profile.default_no_locale.directory.5");       // Profile Root        sApp_DefaultUserProfileRoot50 = NS_NewAtom("app.profile.default.user.directory.5");                  // Application Directories        sApp_ResDirectory            = NS_NewAtom("app.res.directory");        sApp_ChromeDirectory         = NS_NewAtom("app.chrome.directory");        sApp_PluginsDirectory        = NS_NewAtom("app.plugins.directory");            // Search        sApp_SearchDirectory50       = NS_NewAtom("app.search.directory.5");    }        nsresult rv;        // Get the mozilla bin directory    // 1. Check the directory service first for xpcom.currentProcessDirectory    //    This will be set if a directory was passed to NS_InitXPCOM    // 2. If that doesn't work, set it to be the current process directory        NS_WITH_SERVICE(nsIProperties, directoryService, NS_DIRECTORY_SERVICE_PROGID, &rv);    if (NS_SUCCEEDED(rv))        rv = directoryService->Get("xpcom.currentProcessDirectory", NS_GET_IID(nsIFile), getter_AddRefs(mMozBinDirectory));    if (NS_FAILED(rv)) {        nsCOMPtr<nsILocalFile> aLocalFile;        rv = GetCurrentProcessDirectory(getter_AddRefs(aLocalFile));        if (NS_SUCCEEDED(rv))            mMozBinDirectory = do_QueryInterface(aLocalFile);    }}nsAppFileLocationProvider::~nsAppFileLocationProvider(){    if (--sInstanceCount == 0) {        NS_IF_RELEASE(sApp_DefaultsFolder50);                NS_IF_RELEASE(sApp_PrefDefaultsFolder50);        NS_IF_RELEASE(sApp_ProfileDefaultsFolder50);        NS_IF_RELEASE(sApp_ProfileDefaultsNoLocFolder50);        NS_IF_RELEASE(sApp_DefaultUserProfileRoot50);                      NS_IF_RELEASE(sApp_ResDirectory);        NS_IF_RELEASE(sApp_ChromeDirectory);        NS_IF_RELEASE(sApp_PluginsDirectory);        NS_IF_RELEASE(sApp_SearchDirectory50);    }}//*****************************************************************************// nsAppFileLocationProvider::nsISupports//*****************************************************************************   NS_IMPL_ISUPPORTS1(nsAppFileLocationProvider, nsIDirectoryServiceProvider)//*****************************************************************************// nsAppFileLocationProvider::nsIDirectoryServiceProvider//*****************************************************************************   NS_IMETHODIMPnsAppFileLocationProvider::GetFile(const char *prop, PRBool *persistant, nsIFile **_retval){    	nsCOMPtr<nsILocalFile>  localFile;	nsresult rv = NS_ERROR_FAILURE;	*_retval = nsnull;	*persistant = PR_TRUE;	    nsIAtom* inAtom = NS_NewAtom(prop);    NS_ENSURE_TRUE(inAtom, NS_ERROR_OUT_OF_MEMORY);    if (inAtom == sApp_DefaultsFolder50)    {        rv = CloneMozBinDirectory(getter_AddRefs(localFile));        if (NS_SUCCEEDED(rv))            rv = localFile->AppendRelativePath(DEFAULTS_DIR_NAME);    }    else if (inAtom == sApp_PrefDefaultsFolder50)    {        rv = CloneMozBinDirectory(getter_AddRefs(localFile));        if (NS_SUCCEEDED(rv)) {            rv = localFile->AppendRelativePath(DEFAULTS_DIR_NAME);            if (NS_SUCCEEDED(rv))                rv = localFile->AppendRelativePath(DEFAULTS_PREF_DIR_NAME);        }    }    else if (inAtom == sApp_ProfileDefaultsFolder50)    {        rv = CloneMozBinDirectory(getter_AddRefs(localFile));        if (NS_SUCCEEDED(rv)) {            rv = localFile->AppendRelativePath(DEFAULTS_DIR_NAME);            if (NS_SUCCEEDED(rv)) {                rv = localFile->AppendRelativePath(DEFAULTS_PROFILE_DIR_NAME);                if (NS_SUCCEEDED(rv)) {                    nsXPIDLString localeName;                    rv = GetChromeLocale(getter_Copies(localeName));                    if (NS_SUCCEEDED(rv))                        rv = localFile->AppendRelativeUnicodePath(localeName);                }            }        }    }    else if (inAtom == sApp_ProfileDefaultsNoLocFolder50)    {        rv = CloneMozBinDirectory(getter_AddRefs(localFile));        if (NS_SUCCEEDED(rv)) {            rv = localFile->AppendRelativePath(DEFAULTS_DIR_NAME);            if (NS_SUCCEEDED(rv))                rv = localFile->AppendRelativePath(DEFAULTS_PROFILE_DIR_NAME);        }    }    else if (inAtom == sApp_DefaultUserProfileRoot50)    {        rv = GetDefaultUserProfileRoot(getter_AddRefs(localFile));       }    else if (inAtom == sApp_ResDirectory)    {        rv = CloneMozBinDirectory(getter_AddRefs(localFile));        if (NS_SUCCEEDED(rv))            rv = localFile->AppendRelativePath(RES_DIR_NAME);    }    else if (inAtom == sApp_ChromeDirectory)    {        rv = CloneMozBinDirectory(getter_AddRefs(localFile));        if (NS_SUCCEEDED(rv))            rv = localFile->AppendRelativePath(CHROME_DIR_NAME);    }    else if (inAtom == sApp_PluginsDirectory)    {        rv = CloneMozBinDirectory(getter_AddRefs(localFile));        if (NS_SUCCEEDED(rv))            rv = localFile->AppendRelativePath(PLUGINS_DIR_NAME);    }    else if (inAtom == sApp_SearchDirectory50)    {        rv = CloneMozBinDirectory(getter_AddRefs(localFile));        if (NS_SUCCEEDED(rv))            rv = localFile->AppendRelativePath(SEARCH_DIR_NAME);    }        NS_RELEASE(inAtom);	if (localFile && NS_SUCCEEDED(rv))		return localFile->QueryInterface(NS_GET_IID(nsIFile), (void**)_retval);			return rv;}NS_METHOD nsAppFileLocationProvider::CloneMozBinDirectory(nsILocalFile **aLocalFile){    NS_ENSURE_TRUE(mMozBinDirectory, NS_ERROR_FAILURE);    NS_ENSURE_ARG_POINTER(aLocalFile);        nsCOMPtr<nsIFile> aFile;    nsresult rv = mMozBinDirectory->Clone(getter_AddRefs(aFile));    if (NS_SUCCEEDED(rv))        rv = aFile->QueryInterface(NS_GET_IID(nsILocalFile), aLocalFile);        return rv;}//****************************************************************************************// Static Routines//****************************************************************************************static nsresult GetChromeLocale(PRUnichar** localeName){    NS_ENSURE_ARG_POINTER(localeName);    nsresult rv;        *localeName = nsnull;    nsCOMPtr<nsIChromeRegistry> chromeRegistry = do_GetService(kChromeRegistryCID, &rv);    if (NS_SUCCEEDED(rv)) {        nsString tmpstr; tmpstr.AssignWithConversion("navigator");        rv = chromeRegistry->GetSelectedLocale(tmpstr.GetUnicode(), localeName);    }    return rv;}