Camino only - Bug 364497: when app is opened via a link, respect the external app pref for opening in the same window as saved sessions. Patch by Sean Murphy <murph@seanmurph.com> r=smorgan sr=pink

This commit is contained in:
stridey%gmail.com 2007-04-18 20:41:23 +00:00
Родитель 3fb5378d97
Коммит a0f22415f6
3 изменённых файлов: 66 добавлений и 15 удалений

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

@ -22,6 +22,7 @@
*
* Contributor(s):
* David Hyatt <hyatt@mozilla.org> (Original Author)
* Sean Murphy <murph@seanmurph.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@ -42,18 +43,43 @@
#import "MainController.h"
static NSString* const kMainControllerIsInitializedKey = @"initialized";
@implementation GetURLCommand
- (id)performDefaultImplementation
{
MainController* mainController = (MainController*)[NSApp delegate];
// we can get here before -applicationDidFinishLaunching: is called,
// so we have to make sure that gecko has been initted
[mainController ensureGeckoInitted];
[mainController showURL:[self directParameter]];
// We can get here before the application is fully initialized and the previous
// session is restored. We want to avoid opening URLs before that happens.
if ([mainController isInitialized]) {
[mainController showURL:[self directParameter]];
}
else {
[self suspendExecution];
[mainController addObserver:self
forKeyPath:kMainControllerIsInitializedKey
options:NSKeyValueObservingOptionNew
context:NULL];
}
return nil;
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
if ([keyPath isEqualToString:kMainControllerIsInitializedKey] && [[change objectForKey:NSKeyValueChangeNewKey] boolValue]) {
// explicitly perform the command's default implementation again,
// since |resumeExecutionWithResult:| will not.
id result = [self executeCommand];
[self resumeExecutionWithResult:result];
}
}
- (void)dealloc
{
[[NSApp delegate] removeObserver:self forKeyPath:kMainControllerIsInitializedKey];
[super dealloc];
}
@end

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

@ -88,6 +88,7 @@ typedef enum EBookmarkOpenBehavior
IBOutlet NSMenuItem* mCreateBookmarksSeparatorMenuItem; // unused
IBOutlet NSMenuItem* mShowAllBookmarksMenuItem;
BOOL mInitialized;
BOOL mOffline;
BOOL mGeckoInitted;
BOOL mBookmarksMenuUpdatePending;
@ -107,6 +108,8 @@ typedef enum EBookmarkOpenBehavior
NSMutableDictionary* mCharsets;
}
- (BOOL)isInitialized;
// Application menu actions
- (IBAction)aboutWindow:(id)sender;
- (IBAction)feedbackLink:(id)aSender;
@ -177,8 +180,6 @@ typedef enum EBookmarkOpenBehavior
// used by page info panel to show certificate information
- (IBAction)showCertificates:(id)aSender;
- (void)ensureGeckoInitted;
// if the main/key window is a browser window, return its controller, otherwise nil
- (BrowserWindowController*)getMainWindowBrowserController;
- (BrowserWindowController*)getKeyWindowBrowserController;

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

@ -107,6 +107,9 @@ NSString* const kPreviousSessionTerminatedNormallyKey = @"PreviousSessionTermina
@interface MainController(Private)<NetworkServicesClient>
- (void)ensureGeckoInitted;
- (void)ensureInitializationCompleted;
- (void)setInitialized:(BOOL)flag;
- (void)setupStartpage;
- (void)setupRendezvous;
- (void)checkDefaultBrowser;
@ -199,17 +202,31 @@ NSString* const kPreviousSessionTerminatedNormallyKey = @"PreviousSessionTermina
const nsModuleComponentInfo* comps = GetAppComponents(&numComps);
CHBrowserService::RegisterAppComponents(comps, numComps);
// To work around a bug on Tiger where the view hookup order has been changed from postfix to prefix
// order, we need to set a user default to return to the old behavior.
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"NSViewSetAncestorsWindowFirst"];
mGeckoInitted = YES;
}
- (void)applicationDidFinishLaunching:(NSNotification*)aNotification
- (BOOL)isInitialized
{
return mInitialized;
}
- (void)setInitialized:(BOOL)flag
{
mInitialized = flag;
}
- (void)ensureInitializationCompleted
{
if ([self isInitialized])
return;
[self ensureGeckoInitted];
// To work around bugs on Tiger caused by the view hookup order having been
// changed from postfix to prefix order, we need to set a user default to
// return to the old behavior.
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"NSViewSetAncestorsWindowFirst"];
NSNotificationCenter* notificationCenter = [NSNotificationCenter defaultCenter];
// turn on menu display notifications
[NSMenu setupMenuWillDisplayNotifications];
@ -311,6 +328,13 @@ NSString* const kPreviousSessionTerminatedNormallyKey = @"PreviousSessionTermina
// delay the default browser check to give the first page time to load
[self performSelector:@selector(checkDefaultBrowser) withObject:nil afterDelay:2.0f];
[self setInitialized:YES];
}
- (void)applicationDidFinishLaunching:(NSNotification*)aNotification
{
[self ensureInitializationCompleted];
}
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication*)sender
@ -694,9 +718,9 @@ NSString* const kPreviousSessionTerminatedNormallyKey = @"PreviousSessionTermina
- (BOOL)application:(NSApplication*)theApplication openFile:(NSString*)filename
{
// We can get called before -applicationDidFinishLaunching, so make sure gecko
// has been initted
[self ensureGeckoInitted];
// We can get here before the application is fully initialized and the previous
// session is restored. We want to avoid opening URLs before that happens.
[self ensureInitializationCompleted];
NSURL* urlToOpen = [MainController decodeLocalFileURL:[NSURL fileURLWithPath:filename]];
[self showURL:[urlToOpen absoluteString]];