mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-13 05:15:45 +00:00
Add some error dialogs for various fatal errors that can happen during launch of Camino. Addresses bug 201506.
This commit is contained in:
parent
d50e01de2f
commit
459daf10ff
Binary file not shown.
@ -90,6 +90,8 @@ static const PRInt32 kCurrentPrefsVersion = 1;
|
|||||||
- (NSString*)newProfilePath;
|
- (NSString*)newProfilePath;
|
||||||
- (void)migrateChimeraProfile:(NSString*)newProfilePath;
|
- (void)migrateChimeraProfile:(NSString*)newProfilePath;
|
||||||
|
|
||||||
|
- (void)showLaunchFailureAndQuitWithErrorTitle:(NSString*)inTitleFormat errorMessage:(NSString*)inMessageFormat;
|
||||||
|
|
||||||
- (void)configureProxies;
|
- (void)configureProxies;
|
||||||
- (BOOL)updateOneProxy:(NSDictionary*)configDict
|
- (BOOL)updateOneProxy:(NSDictionary*)configDict
|
||||||
protocol:(NSString*)protocol
|
protocol:(NSString*)protocol
|
||||||
@ -143,7 +145,7 @@ static BOOL gMadePrefManager;
|
|||||||
[self registerNotificationListener];
|
[self registerNotificationListener];
|
||||||
|
|
||||||
if ([self initMozillaPrefs] == NO) {
|
if ([self initMozillaPrefs] == NO) {
|
||||||
// XXXw. throw here too
|
// we should never get here
|
||||||
NSLog (@"Failed to initialize mozilla prefs");
|
NSLog (@"Failed to initialize mozilla prefs");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,6 +216,17 @@ static BOOL gMadePrefManager;
|
|||||||
prefsService->SavePrefFile(nsnull);
|
prefsService->SavePrefFile(nsnull);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)showLaunchFailureAndQuitWithErrorTitle:(NSString*)inTitleFormat errorMessage:(NSString*)inMessageFormat
|
||||||
|
{
|
||||||
|
NSString* applicationName = NSLocalizedStringFromTable(@"CFBundleName", @"InfoPlist", nil);
|
||||||
|
|
||||||
|
NSString* errorString = [NSString stringWithFormat:inTitleFormat, applicationName];
|
||||||
|
NSString* messageString = [NSString stringWithFormat:inMessageFormat, applicationName];
|
||||||
|
|
||||||
|
NSRunAlertPanel(errorString, messageString, NSLocalizedString(@"QuitButton", @""), nil, nil);
|
||||||
|
[NSApp terminate:self];
|
||||||
|
}
|
||||||
|
|
||||||
- (BOOL)initMozillaPrefs
|
- (BOOL)initMozillaPrefs
|
||||||
{
|
{
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
@ -223,7 +236,12 @@ static BOOL gMadePrefManager;
|
|||||||
nsCOMPtr<nsILocalFile> binDir;
|
nsCOMPtr<nsILocalFile> binDir;
|
||||||
rv = NS_NewNativeLocalFile(nsDependentCString(binDirPath), PR_TRUE, getter_AddRefs(binDir));
|
rv = NS_NewNativeLocalFile(nsDependentCString(binDirPath), PR_TRUE, getter_AddRefs(binDir));
|
||||||
if (NS_FAILED(rv))
|
if (NS_FAILED(rv))
|
||||||
|
{
|
||||||
|
[self showLaunchFailureAndQuitWithErrorTitle:NSLocalizedString(@"StartupFailureAlert", @"")
|
||||||
|
errorMessage:NSLocalizedString(@"StartupFailureBinPathMsg", @"")];
|
||||||
|
// not reached
|
||||||
return NO;
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
// This shouldn't be needed since we are initing XPCOM with this
|
// This shouldn't be needed since we are initing XPCOM with this
|
||||||
// directory but causes a (harmless) warning if not defined.
|
// directory but causes a (harmless) warning if not defined.
|
||||||
@ -242,52 +260,88 @@ static BOOL gMadePrefManager;
|
|||||||
// Supply our own directory service provider so we can control where
|
// Supply our own directory service provider so we can control where
|
||||||
// the registry and profiles are located.
|
// the registry and profiles are located.
|
||||||
AppDirServiceProvider *provider = new AppDirServiceProvider(nsDependentCString(profileDirName));
|
AppDirServiceProvider *provider = new AppDirServiceProvider(nsDependentCString(profileDirName));
|
||||||
if (!provider) return NO;
|
if (!provider)
|
||||||
|
{
|
||||||
|
[self showLaunchFailureAndQuitWithErrorTitle:NSLocalizedString(@"StartupFailureAlert", @"")
|
||||||
|
errorMessage:NSLocalizedString(@"StartupFailureMsg", @"")];
|
||||||
|
// not reached
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIDirectoryServiceProvider> dirProvider = (nsIDirectoryServiceProvider*)provider;
|
nsCOMPtr<nsIDirectoryServiceProvider> dirProvider = (nsIDirectoryServiceProvider*)provider;
|
||||||
rv = NS_InitEmbedding(binDir, dirProvider,
|
rv = NS_InitEmbedding(binDir, dirProvider,
|
||||||
kPStaticModules, kStaticModuleCount);
|
kPStaticModules, kStaticModuleCount);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
NSLog(@"Embedding init failed.");
|
NSLog(@"Embedding init failed.");
|
||||||
|
[self showLaunchFailureAndQuitWithErrorTitle:NSLocalizedString(@"StartupFailureAlert", @"")
|
||||||
|
errorMessage:NSLocalizedString(@"StartupFailureInitEmbeddingMsg", @"")];
|
||||||
|
// not reached
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSString *newProfilePath = [self newProfilePath];
|
NSString* profilePath = [self newProfilePath];
|
||||||
if (!newProfilePath) {
|
if (!profilePath) {
|
||||||
NSLog(@"Failed to determine profile path!");
|
NSLog(@"Failed to determine profile path!");
|
||||||
return NO;
|
[self showLaunchFailureAndQuitWithErrorTitle:NSLocalizedString(@"StartupFailureAlert", @"")
|
||||||
|
errorMessage:NSLocalizedString(@"StartupFailureProfilePathMsg", @"")];
|
||||||
|
// not reached
|
||||||
|
return NO;
|
||||||
}
|
}
|
||||||
// Check for the existance of prefs.js in our new (as of 0.8) profile dir.
|
|
||||||
|
// Check for the existence of prefs.js in our new (as of 0.8) profile dir.
|
||||||
// If it doesn't exist, attempt to migrate over the contents of the old
|
// If it doesn't exist, attempt to migrate over the contents of the old
|
||||||
// one at ~/Library/Application Support/Chimera/Profiles/default/xxxxxxxx.slt/
|
// one at ~/Library/Application Support/Chimera/Profiles/default/xxxxxxxx.slt/
|
||||||
NSFileManager *fileMgr = [NSFileManager defaultManager];
|
NSFileManager *fileMgr = [NSFileManager defaultManager];
|
||||||
if (![fileMgr fileExistsAtPath:[newProfilePath stringByAppendingPathComponent:@"prefs.js"]])
|
if (![fileMgr fileExistsAtPath:[profilePath stringByAppendingPathComponent:@"prefs.js"]])
|
||||||
[self migrateChimeraProfile:newProfilePath];
|
[self migrateChimeraProfile:profilePath];
|
||||||
|
|
||||||
rv = NS_NewProfileDirServiceProvider(PR_TRUE, &mProfileProvider);
|
rv = NS_NewProfileDirServiceProvider(PR_TRUE, &mProfileProvider);
|
||||||
if (NS_FAILED(rv))
|
if (NS_FAILED(rv))
|
||||||
return NO;
|
{
|
||||||
|
[self showLaunchFailureAndQuitWithErrorTitle:NSLocalizedString(@"StartupFailureAlert", @"")
|
||||||
|
errorMessage:NSLocalizedString(@"StartupFailureMsg", @"")];
|
||||||
|
|
||||||
|
// not reached
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
mProfileProvider->Register();
|
mProfileProvider->Register();
|
||||||
|
|
||||||
nsCOMPtr<nsILocalFile> profileDir;
|
nsCOMPtr<nsILocalFile> profileDir;
|
||||||
rv = NS_NewNativeLocalFile(nsDependentCString([newProfilePath fileSystemRepresentation]),
|
rv = NS_NewNativeLocalFile(nsDependentCString([profilePath fileSystemRepresentation]),
|
||||||
PR_TRUE, getter_AddRefs(profileDir));
|
PR_TRUE, getter_AddRefs(profileDir));
|
||||||
if (NS_FAILED(rv))
|
if (NS_FAILED(rv))
|
||||||
|
{
|
||||||
|
[self showLaunchFailureAndQuitWithErrorTitle:NSLocalizedString(@"StartupFailureAlert", @"")
|
||||||
|
errorMessage:NSLocalizedString(@"StartupFailureMsg", @"")];
|
||||||
|
// not reached
|
||||||
return NO;
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
rv = mProfileProvider->SetProfileDir(profileDir);
|
rv = mProfileProvider->SetProfileDir(profileDir);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
if (rv == NS_ERROR_FILE_ACCESS_DENIED) {
|
if (rv == NS_ERROR_FILE_ACCESS_DENIED) {
|
||||||
NSString *alert = [NSString stringWithFormat: NSLocalizedString(@"AlreadyRunningAlert", @""), NSLocalizedStringFromTable(@"CFBundleName", @"InfoPlist", nil)];
|
[self showLaunchFailureAndQuitWithErrorTitle:NSLocalizedString(@"AlreadyRunningAlert", @"")
|
||||||
NSString *message = [NSString stringWithFormat: NSLocalizedString(@"AlreadyRunningMsg", @""), NSLocalizedStringFromTable(@"CFBundleName", @"InfoPlist", nil)];
|
errorMessage:NSLocalizedString(@"AlreadyRunningMsg", @"")];
|
||||||
NSString *quit = NSLocalizedString(@"AlreadyRunningButton",@"");
|
|
||||||
NSRunAlertPanel(alert,message,quit,nil,nil);
|
|
||||||
[NSApp terminate:self];
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
[self showLaunchFailureAndQuitWithErrorTitle:NSLocalizedString(@"StartupFailureAlert", @"")
|
||||||
|
errorMessage:NSLocalizedString(@"StartupFailureProfileSetupMsg", @"")];
|
||||||
|
}
|
||||||
|
// not reached
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIPref> prefs(do_GetService(NS_PREF_CONTRACTID));
|
nsCOMPtr<nsIPref> prefs(do_GetService(NS_PREF_CONTRACTID));
|
||||||
|
if (!prefs)
|
||||||
|
{
|
||||||
|
[self showLaunchFailureAndQuitWithErrorTitle:NSLocalizedString(@"StartupFailureAlert", @"")
|
||||||
|
errorMessage:NSLocalizedString(@"StartupFailureNoPrefsMsg", @"")];
|
||||||
|
// not reached
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
mPrefs = prefs;
|
mPrefs = prefs;
|
||||||
NS_IF_ADDREF(mPrefs);
|
NS_ADDREF(mPrefs);
|
||||||
|
|
||||||
[self syncMozillaPrefs];
|
[self syncMozillaPrefs];
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user