mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-14 10:43:24 +00:00
don't hang if launch services can't find the browser it said is default. no bug
This commit is contained in:
parent
7c6aa20e06
commit
0c201c8dfd
@ -347,6 +347,12 @@ int compareBundleIDAppDisplayNames(id a, id b, void *context)
|
||||
// add user chosen browsers to list
|
||||
[browsersSet addObjectsFromArray:[[NSUserDefaults standardUserDefaults] objectForKey:kUserChosenBrowserUserDefaultsKey]];
|
||||
|
||||
// add default browser in case it hasn't been already
|
||||
NSURL *currSetURL = nil;
|
||||
_LSCopyDefaultSchemeHandlerURL(@"http", &currSetURL);
|
||||
[browsersSet addObject:[OrgMozillaChimeraPreferenceNavigation bundleIDForURL:currSetURL]];
|
||||
[currSetURL release];
|
||||
|
||||
NSMutableArray* browsers = [[browsersSet allObjects] mutableCopy];
|
||||
|
||||
// sort by display name
|
||||
@ -372,9 +378,8 @@ int compareBundleIDAppDisplayNames(id a, id b, void *context)
|
||||
[menu addItem:[NSMenuItem separatorItem]];
|
||||
|
||||
// set up new menu
|
||||
NSString *bundleID;
|
||||
NSEnumerator *browserEnumerator = [browsers objectEnumerator];
|
||||
while (bundleID = [browserEnumerator nextObject]) {
|
||||
while (NSString *bundleID = [browserEnumerator nextObject]) {
|
||||
NSURL *appURL = nil;
|
||||
if (LSFindApplicationForInfo(kLSUnknownCreator, (CFStringRef)bundleID, NULL, NULL, (CFURLRef*)&appURL) == noErr) {
|
||||
NSMenuItem* item = [[NSMenuItem alloc] initWithTitle:[OrgMozillaChimeraPreferenceNavigation displayNameForURL:appURL]
|
||||
@ -400,17 +405,6 @@ int compareBundleIDAppDisplayNames(id a, id b, void *context)
|
||||
}
|
||||
}
|
||||
|
||||
// if the current default browser was not seen in the list, it must be user chosen and LS
|
||||
// isn't detecting it. Add it to the user chosen list and call this method again, then get out.
|
||||
if (!selectedBrowserMenuItem) {
|
||||
NSMutableArray *userSelectedBrowsers = [NSMutableArray arrayWithCapacity:10];
|
||||
[userSelectedBrowsers addObjectsFromArray:[[NSUserDefaults standardUserDefaults] objectForKey:kUserChosenBrowserUserDefaultsKey]];
|
||||
[userSelectedBrowsers addObject:currentDefaultBrowserBundleID];
|
||||
[[NSUserDefaults standardUserDefaults] setObject:userSelectedBrowsers forKey:kUserChosenBrowserUserDefaultsKey];
|
||||
[self updateDefaultBrowserMenu];
|
||||
return;
|
||||
}
|
||||
|
||||
// allow user to select a browser
|
||||
[menu addItem:[NSMenuItem separatorItem]];
|
||||
NSMenuItem* selectItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Select...", "Select...")
|
||||
|
Loading…
Reference in New Issue
Block a user