backing out last change -- was intended for branch bug got checked into trunk by accident

This commit is contained in:
morse%netscape.com 2001-06-30 00:32:42 +00:00
Родитель db9eb4088f
Коммит f41f7dacbf
1 изменённых файлов: 39 добавлений и 24 удалений

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

@ -27,7 +27,6 @@
#include "nsIURI.h"
#include "nsNetUtil.h"
#include "nsIPref.h"
#include "nsIPrefService.h"
#include "plevent.h"
#include "prmem.h"
#include "prnetdb.h"
@ -104,7 +103,6 @@ extern "C" void ShowOSAlert(char* aMessage);
#define HELP_SPACER_1 "\t"
#define HELP_SPACER_2 "\t\t"
#define HELP_SPACER_4 "\t\t\t\t"
#define PREF_HOMEPAGE_OVERRIDE "browser.startup.homepage_override.1"
#ifdef DEBUG
#include "prlog.h"
@ -399,29 +397,7 @@ nsresult LaunchApplication(const char *aParam, PRInt32 height, PRInt32 width)
rv = handler->GetHandlesArgs(&handlesArgs);
if (handlesArgs) {
nsXPIDLString defaultArgs;
/* GetDefaultArgs will always set the override pref to false but we don't want that
to happen yet (otherwise the setup page won't get displayed when a new
profile is used for the first time). So we will fetch the override pref
before calling GetDefaultArgs and, if it is true, we will restore it to back
to true after calling GetDefaultArgs
*/
PRBool override = PR_FALSE;
nsCOMPtr<nsIPrefBranch> prefBranch;
nsCOMPtr<nsIPrefService> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
if (prefs) {
rv = prefs->GetBranch(nsnull, getter_AddRefs(prefBranch));
if (NS_SUCCEEDED(rv)) {
prefBranch->GetBoolPref(PREF_HOMEPAGE_OVERRIDE, &override);
}
}
rv = handler->GetDefaultArgs(getter_Copies(defaultArgs));
if (override) {
prefBranch->SetBoolPref(PREF_HOMEPAGE_OVERRIDE, PR_TRUE);
}
if (NS_FAILED(rv)) return rv;
rv = OpenWindow(chromeUrlForTask, defaultArgs);
}
@ -710,6 +686,43 @@ static nsresult OpenBrowserWindow(PRInt32 height, PRInt32 width)
}
static void InitCachePrefs()
{
const char * const CACHE_DIR_PREF = "browser.cache.directory";
nsresult rv;
PRBool isDir = PR_FALSE;
nsCOMPtr<nsIPref> prefs(do_GetService(NS_PREF_CONTRACTID, &rv));
if (NS_FAILED(rv)) return;
// If the pref is already set don't do anything
nsCOMPtr<nsILocalFile> cacheDir;
rv = prefs->GetFileXPref(CACHE_DIR_PREF, getter_AddRefs(cacheDir));
if (NS_SUCCEEDED(rv) && cacheDir.get()) {
rv = cacheDir->IsDirectory(&isDir);
if (NS_SUCCEEDED(rv) && isDir)
return;
}
// Set up the new pref
nsCOMPtr<nsIFile> profileDir;
rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(profileDir));
NS_ASSERTION(profileDir, "NS_APP_USER_PROFILE_50_DIR is not defined");
if (NS_FAILED(rv)) return;
cacheDir = do_QueryInterface(profileDir);
NS_ASSERTION(cacheDir, "Cannot get nsILocalFile from cache dir");
PRBool exists;
cacheDir->Append("Cache");
rv = cacheDir->Exists(&exists);
if (NS_SUCCEEDED(rv) && !exists)
rv = cacheDir->Create(nsIFile::DIRECTORY_TYPE, 0775);
if (NS_FAILED(rv)) return;
prefs->SetFileXPref(CACHE_DIR_PREF, cacheDir);
}
static nsresult Ensure1Window( nsICmdLineService* cmdLineArgs)
{
nsresult rv;
@ -1191,6 +1204,8 @@ static nsresult main1(int argc, char* argv[], nsISupports *nativeApp )
// Startup wallet service so it registers for notifications
nsCOMPtr<nsIWalletService> walletService(do_GetService(NS_WALLETSERVICE_CONTRACTID, &rv));
InitCachePrefs();
// From this point on, should be true
appShell->SetQuitOnLastWindowClosing(PR_TRUE);