зеркало из https://github.com/mozilla/pjs.git
Checking in patch from David Haas in bug 155048, with modifications to improve the 'is there a browser window' logic. This also fixes bug 152026 (2 windows when launched with a GetURL AE), and my changes fix bugs 155309 (dragging multiple files onto the icon works now) and 155147 ("browser.always_reuse_window" always works for GetURL events now).
This commit is contained in:
Родитель
4429fa9d76
Коммит
e614caa04d
|
@ -34,30 +34,7 @@
|
|||
|
||||
- (id)performDefaultImplementation
|
||||
{
|
||||
// get the pref that specifies if we want to re-use the existing window or
|
||||
// open a new one. There's really no point caching this pref.
|
||||
PRBool reuseWindow = PR_FALSE;
|
||||
PRBool loadInBackground = PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIPref> prefService ( do_GetService(NS_PREF_CONTRACTID) );
|
||||
if ( prefService ) {
|
||||
prefService->GetBoolPref("browser.always_reuse_window", &reuseWindow);
|
||||
prefService->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
|
||||
}
|
||||
|
||||
// reuse the main window if there is one. The user may have closed all of
|
||||
// them or we may get this event at startup before we've had time to load
|
||||
// our window.
|
||||
|
||||
BrowserWindowController* controller = NULL;
|
||||
if ( reuseWindow && [NSApp mainWindow] ) {
|
||||
controller = [[NSApp mainWindow] windowController];
|
||||
[controller openNewTabWithURL:[self directParameter] loadInBackground:loadInBackground];
|
||||
}
|
||||
else
|
||||
controller = [[NSApp delegate] openBrowserWindowWithURL: [self directParameter]];
|
||||
|
||||
[[[controller getBrowserWrapper] getBrowserView] setActive: YES];
|
||||
[[NSApp delegate] openNewWindowOrTabWithURL:[self directParameter]];
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,24 +7,14 @@
|
|||
objects = {
|
||||
080E96DDFE201D6D7F000001 = {
|
||||
children = (
|
||||
F512F53302D17A2601072C9F,
|
||||
F512F52A02D1287F01072C9F,
|
||||
F5A3669402CCFAF601DC3354,
|
||||
F5A3669602CCFAF601DC3354,
|
||||
F512F52B02D1287F01072C9F,
|
||||
F5A3669702CCFAF601DC3354,
|
||||
F5DE10E90209DC0601A967DF,
|
||||
F517395B020CE3740189DA0C,
|
||||
F528E21A020FD9620168DE43,
|
||||
F5DE10EA0209DC0601A967DF,
|
||||
F632AF8402B9AEBB01000103,
|
||||
F5DE10EB0209DC0601A967DF,
|
||||
F51B70B7026EC98B01A80166,
|
||||
F5AE04BA0206A4FE01A967DF,
|
||||
F52D5CD8027D3D5001A80166,
|
||||
F6BA6D4E01B2F8A601A962F7,
|
||||
F56769FB0208F74A010001CA,
|
||||
F57074BE026D80DF01A80166,
|
||||
2E2939FF027F33604B000102,
|
||||
F59E9F3F0237E43401A967DF,
|
||||
2E748B73029A448D4B000102,
|
||||
F512F52C02D1287F01072C9F,
|
||||
F512F52D02D1287F01072C9F,
|
||||
);
|
||||
isa = PBXGroup;
|
||||
name = Classes;
|
||||
|
@ -173,10 +163,10 @@
|
|||
children = (
|
||||
F51842F30206168101A966FE,
|
||||
080E96DDFE201D6D7F000001,
|
||||
F5571935022B401B010001CA,
|
||||
F53F21EB022B7C77010001CA,
|
||||
F5807368023A1514010001CA,
|
||||
F580736B023A1514010001CA,
|
||||
F5571935022B401B010001CA,
|
||||
29B97315FDCFA39411CA2CEA,
|
||||
29B97317FDCFA39411CA2CEA,
|
||||
29B97323FDCFA39411CA2CEA,
|
||||
|
@ -191,11 +181,8 @@
|
|||
};
|
||||
29B97315FDCFA39411CA2CEA = {
|
||||
children = (
|
||||
29B97316FDCFA39411CA2CEA,
|
||||
F59236C002C89AC90100012B,
|
||||
F59236C102C89AC90100012B,
|
||||
F56F241F02AC6D0401A967F3,
|
||||
F5D1421902BC88F801A967F3,
|
||||
F56F241F02AC6D0401A967F3,
|
||||
);
|
||||
isa = PBXGroup;
|
||||
name = "Other Sources";
|
||||
|
@ -1132,6 +1119,60 @@
|
|||
settings = {
|
||||
};
|
||||
};
|
||||
F512F52A02D1287F01072C9F = {
|
||||
children = (
|
||||
F51B70B7026EC98B01A80166,
|
||||
);
|
||||
isa = PBXGroup;
|
||||
name = "Apple Events";
|
||||
refType = 4;
|
||||
};
|
||||
F512F52B02D1287F01072C9F = {
|
||||
children = (
|
||||
F5DE10E90209DC0601A967DF,
|
||||
F517395B020CE3740189DA0C,
|
||||
F528E21A020FD9620168DE43,
|
||||
);
|
||||
isa = PBXGroup;
|
||||
name = Dialogs;
|
||||
refType = 4;
|
||||
};
|
||||
F512F52C02D1287F01072C9F = {
|
||||
children = (
|
||||
F57074BE026D80DF01A80166,
|
||||
2E2939FF027F33604B000102,
|
||||
2E748B73029A448D4B000102,
|
||||
);
|
||||
isa = PBXGroup;
|
||||
name = "UI elements";
|
||||
refType = 4;
|
||||
};
|
||||
F512F52D02D1287F01072C9F = {
|
||||
children = (
|
||||
F5DE10EB0209DC0601A967DF,
|
||||
F59E9F3F0237E43401A967DF,
|
||||
F5DE10EA0209DC0601A967DF,
|
||||
F6BA6D4E01B2F8A601A962F7,
|
||||
F632AF8402B9AEBB01000103,
|
||||
F56769FB0208F74A010001CA,
|
||||
);
|
||||
isa = PBXGroup;
|
||||
name = "Browser window";
|
||||
path = "";
|
||||
refType = 4;
|
||||
};
|
||||
F512F53302D17A2601072C9F = {
|
||||
children = (
|
||||
29B97316FDCFA39411CA2CEA,
|
||||
F59236C002C89AC90100012B,
|
||||
F5AE04BA0206A4FE01A967DF,
|
||||
F52D5CD8027D3D5001A80166,
|
||||
);
|
||||
isa = PBXGroup;
|
||||
name = Application;
|
||||
path = "";
|
||||
refType = 4;
|
||||
};
|
||||
F5137A1102676B9101026D05 = {
|
||||
isa = PBXFileReference;
|
||||
path = CHFind.h;
|
||||
|
@ -1228,6 +1269,7 @@
|
|||
F53E012902AEE91C01A967F3,
|
||||
F53E013202AEEA2801A967F3,
|
||||
F5A3669302CCFAF601DC3354,
|
||||
F59236C102C89AC90100012B,
|
||||
);
|
||||
isa = PBXGroup;
|
||||
name = Headers;
|
||||
|
|
|
@ -117,9 +117,14 @@ class BookmarksService;
|
|||
-(IBAction) closeTab:(id)aSender;
|
||||
|
||||
-(BrowserWindowController*)openBrowserWindowWithURL: (NSString*)aURL;
|
||||
- (void)openNewWindowOrTabWithURL:(NSString*)inURLString;
|
||||
|
||||
-(NSWindow*)getFrontmostBrowserWindow;
|
||||
|
||||
- (MVPreferencesController *)preferencesController;
|
||||
- (void)displayPreferencesWindow:sender;
|
||||
- (CHPreferenceManager *)preferenceManager;
|
||||
- (BOOL)isMainWindowABrowserWindow;
|
||||
|
||||
- (IBAction)showAboutBox:(id)sender;
|
||||
|
||||
|
|
|
@ -35,20 +35,24 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#import "MainController.h"
|
||||
#import "BrowserWindowController.h"
|
||||
#include "BookmarksService.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsCocoaBrowserService.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsEmbedAPI.h"
|
||||
#include "nsIChromeRegistry.h"
|
||||
#import "CHAboutBox.h"
|
||||
#include <Foundation/NSUserDefaults.h>
|
||||
#include <mach-o/dyld.h>
|
||||
|
||||
#import "MainController.h"
|
||||
#import "BrowserWindowController.h"
|
||||
#import "BookmarksService.h"
|
||||
#import "nsCocoaBrowserService.h"
|
||||
#import "CHAboutBox.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsEmbedAPI.h"
|
||||
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsIPref.h"
|
||||
#include "nsIChromeRegistry.h"
|
||||
|
||||
|
||||
#ifdef _BUILD_STATIC_BIN
|
||||
#include "nsStaticComponent.h"
|
||||
nsresult PR_CALLBACK
|
||||
|
@ -106,37 +110,41 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
printf("Main controller died.\n");
|
||||
}
|
||||
|
||||
-(void)awakeFromNib
|
||||
-(void)applicationDidFinishLaunching:(NSNotification *)aNotification
|
||||
{
|
||||
#ifdef _BUILD_STATIC_BIN
|
||||
[self updatePrebinding];
|
||||
[self updatePrebinding];
|
||||
#endif
|
||||
// initialize if we haven't already.
|
||||
[self preferenceManager];
|
||||
|
||||
mPreferenceManager = [[CHPreferenceManager sharedInstance] retain];
|
||||
|
||||
// don't open a new browser window if we already have one
|
||||
// (for example, from an GetURL Apple Event)
|
||||
NSWindow* browserWindow = [self getFrontmostBrowserWindow];
|
||||
if (!browserWindow)
|
||||
[self newWindow: self];
|
||||
|
||||
[mSplashScreen close];
|
||||
[mSplashScreen close];
|
||||
|
||||
[mBookmarksMenu setAutoenablesItems: NO];
|
||||
mMenuBookmarks = new BookmarksService((BookmarksDataSource*)nil);
|
||||
mMenuBookmarks->AddObserver();
|
||||
mMenuBookmarks->ConstructBookmarksMenu(mBookmarksMenu, nsnull);
|
||||
BookmarksService::gMainController = self;
|
||||
[mBookmarksMenu setAutoenablesItems: NO];
|
||||
mMenuBookmarks = new BookmarksService((BookmarksDataSource*)nil);
|
||||
mMenuBookmarks->AddObserver();
|
||||
mMenuBookmarks->ConstructBookmarksMenu(mBookmarksMenu, nsnull);
|
||||
BookmarksService::gMainController = self;
|
||||
|
||||
// Initialize offline mode.
|
||||
mOffline = NO;
|
||||
nsCOMPtr<nsIIOService> ioService(do_GetService(ioServiceContractID));
|
||||
if (!ioService)
|
||||
return;
|
||||
PRBool offline = PR_FALSE;
|
||||
ioService->GetOffline(&offline);
|
||||
mOffline = offline;
|
||||
// Initialize offline mode.
|
||||
mOffline = NO;
|
||||
nsCOMPtr<nsIIOService> ioService(do_GetService(ioServiceContractID));
|
||||
if (!ioService)
|
||||
return;
|
||||
PRBool offline = PR_FALSE;
|
||||
ioService->GetOffline(&offline);
|
||||
mOffline = offline;
|
||||
|
||||
// Set the menu item's text to "Go Online" if we're currently
|
||||
// offline.
|
||||
if (mOffline)
|
||||
[mOfflineMenuItem setTitle: @"Go Online"];
|
||||
// Set the menu item's text to "Go Online" if we're currently
|
||||
// offline.
|
||||
if (mOffline)
|
||||
[mOfflineMenuItem setTitle: @"Go Online"]; // XXX localize me
|
||||
}
|
||||
|
||||
-(IBAction)newWindow:(id)aSender
|
||||
|
@ -316,6 +324,29 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
[[[mApplication mainWindow] windowController] home: aSender];
|
||||
}
|
||||
|
||||
-(NSWindow*)getFrontmostBrowserWindow
|
||||
{
|
||||
// for some reason, [NSApp mainWindow] doesn't always work, so we have to
|
||||
// do this manually
|
||||
NSArray *windowList = [NSApp orderedWindows];
|
||||
NSWindow *foundWindow = NULL;
|
||||
|
||||
for (unsigned int i = 0; i < [windowList count]; i ++)
|
||||
{
|
||||
NSWindow* thisWindow = [windowList objectAtIndex:i];
|
||||
|
||||
if ([[thisWindow windowController] isMemberOfClass:[BrowserWindowController class]] &&
|
||||
([[thisWindow windowController] chromeMask] == 0)) // only get windows with full chrome
|
||||
{
|
||||
foundWindow = thisWindow;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return foundWindow;
|
||||
}
|
||||
|
||||
// open a new URL. This method always makes a new browser window
|
||||
-(BrowserWindowController*)openBrowserWindowWithURL: (NSString*)aURL
|
||||
{
|
||||
BrowserWindowController* browser = [[BrowserWindowController alloc] initWithWindowNibName: @"BrowserWindow"];
|
||||
|
@ -324,6 +355,40 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
return browser;
|
||||
}
|
||||
|
||||
// open a new URL, observing the prefs on how to behave
|
||||
- (void)openNewWindowOrTabWithURL:(NSString*)inURLString
|
||||
{
|
||||
// make sure we're initted
|
||||
[self preferenceManager];
|
||||
|
||||
PRBool reuseWindow = PR_FALSE;
|
||||
PRBool loadInBackground = PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIPref> prefService ( do_GetService(NS_PREF_CONTRACTID) );
|
||||
if ( prefService ) {
|
||||
prefService->GetBoolPref("browser.always_reuse_window", &reuseWindow);
|
||||
prefService->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
|
||||
}
|
||||
|
||||
// reuse the main window if there is one. The user may have closed all of
|
||||
// them or we may get this event at startup before we've had time to load
|
||||
// our window.
|
||||
BrowserWindowController* controller = NULL;
|
||||
|
||||
NSWindow* browserWindow = [self getFrontmostBrowserWindow];
|
||||
if (reuseWindow && browserWindow) {
|
||||
controller = [browserWindow windowController];
|
||||
[controller openNewTabWithURL:inURLString loadInBackground:loadInBackground];
|
||||
}
|
||||
else {
|
||||
controller = [self openBrowserWindowWithURL: inURLString];
|
||||
}
|
||||
|
||||
[[[controller getBrowserWrapper] getBrowserView] setActive: YES];
|
||||
|
||||
}
|
||||
|
||||
|
||||
-(void)applicationWillTerminate: (NSNotification*)aNotification
|
||||
{
|
||||
printf("Termination notification.\n");
|
||||
|
@ -410,6 +475,13 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
[[mainWindow windowController] manageBookmarks: aSender];
|
||||
}
|
||||
|
||||
- (CHPreferenceManager *)preferenceManager
|
||||
{
|
||||
if (!mPreferenceManager)
|
||||
mPreferenceManager = [[CHPreferenceManager sharedInstance] retain];
|
||||
return mPreferenceManager;
|
||||
}
|
||||
|
||||
- (MVPreferencesController *)preferencesController
|
||||
{
|
||||
if (!preferencesController) {
|
||||
|
@ -430,16 +502,23 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
|
||||
- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
|
||||
{
|
||||
NSWindow* mainWindow = [mApplication mainWindow];
|
||||
/*
|
||||
// On the off chance that we're getting this message off a launch,
|
||||
// we may not have initialized our embedded mozilla. So check here,
|
||||
// and if it's not initialized, do it now.
|
||||
[self preferenceManager];
|
||||
|
||||
if (mainWindow) {
|
||||
[[mainWindow windowController] loadURL:[[NSURL fileURLWithPath:filename] absoluteString]];
|
||||
} else {
|
||||
[self openBrowserWindowWithURL:[[NSURL fileURLWithPath:filename] absoluteString]];
|
||||
}
|
||||
|
||||
return YES;
|
||||
// Make sure it's a browser window b/c "about box" can also become main window.
|
||||
if ([self isMainWindowABrowserWindow]) {
|
||||
[[[mApplication mainWindow] windowController] loadURL:[[NSURL fileURLWithPath:filename] absoluteString]];
|
||||
}
|
||||
else {
|
||||
[self openBrowserWindowWithURL:[[NSURL fileURLWithPath:filename] absoluteString]];
|
||||
}
|
||||
*/
|
||||
[self openNewWindowOrTabWithURL:[[NSURL fileURLWithPath:filename] absoluteString]];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (IBAction)biggerTextSize:(id)aSender
|
||||
|
@ -462,6 +541,7 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
|
||||
-(BOOL)isMainWindowABrowserWindow
|
||||
{
|
||||
// see also getFrontmostBrowserWindow
|
||||
return [[[mApplication mainWindow] windowController] isMemberOfClass:[BrowserWindowController class]];
|
||||
}
|
||||
|
||||
|
|
|
@ -7,24 +7,14 @@
|
|||
objects = {
|
||||
080E96DDFE201D6D7F000001 = {
|
||||
children = (
|
||||
F512F53302D17A2601072C9F,
|
||||
F512F52A02D1287F01072C9F,
|
||||
F5A3669402CCFAF601DC3354,
|
||||
F5A3669602CCFAF601DC3354,
|
||||
F512F52B02D1287F01072C9F,
|
||||
F5A3669702CCFAF601DC3354,
|
||||
F5DE10E90209DC0601A967DF,
|
||||
F517395B020CE3740189DA0C,
|
||||
F528E21A020FD9620168DE43,
|
||||
F5DE10EA0209DC0601A967DF,
|
||||
F632AF8402B9AEBB01000103,
|
||||
F5DE10EB0209DC0601A967DF,
|
||||
F51B70B7026EC98B01A80166,
|
||||
F5AE04BA0206A4FE01A967DF,
|
||||
F52D5CD8027D3D5001A80166,
|
||||
F6BA6D4E01B2F8A601A962F7,
|
||||
F56769FB0208F74A010001CA,
|
||||
F57074BE026D80DF01A80166,
|
||||
2E2939FF027F33604B000102,
|
||||
F59E9F3F0237E43401A967DF,
|
||||
2E748B73029A448D4B000102,
|
||||
F512F52C02D1287F01072C9F,
|
||||
F512F52D02D1287F01072C9F,
|
||||
);
|
||||
isa = PBXGroup;
|
||||
name = Classes;
|
||||
|
@ -173,10 +163,10 @@
|
|||
children = (
|
||||
F51842F30206168101A966FE,
|
||||
080E96DDFE201D6D7F000001,
|
||||
F5571935022B401B010001CA,
|
||||
F53F21EB022B7C77010001CA,
|
||||
F5807368023A1514010001CA,
|
||||
F580736B023A1514010001CA,
|
||||
F5571935022B401B010001CA,
|
||||
29B97315FDCFA39411CA2CEA,
|
||||
29B97317FDCFA39411CA2CEA,
|
||||
29B97323FDCFA39411CA2CEA,
|
||||
|
@ -191,11 +181,8 @@
|
|||
};
|
||||
29B97315FDCFA39411CA2CEA = {
|
||||
children = (
|
||||
29B97316FDCFA39411CA2CEA,
|
||||
F59236C002C89AC90100012B,
|
||||
F59236C102C89AC90100012B,
|
||||
F56F241F02AC6D0401A967F3,
|
||||
F5D1421902BC88F801A967F3,
|
||||
F56F241F02AC6D0401A967F3,
|
||||
);
|
||||
isa = PBXGroup;
|
||||
name = "Other Sources";
|
||||
|
@ -1132,6 +1119,60 @@
|
|||
settings = {
|
||||
};
|
||||
};
|
||||
F512F52A02D1287F01072C9F = {
|
||||
children = (
|
||||
F51B70B7026EC98B01A80166,
|
||||
);
|
||||
isa = PBXGroup;
|
||||
name = "Apple Events";
|
||||
refType = 4;
|
||||
};
|
||||
F512F52B02D1287F01072C9F = {
|
||||
children = (
|
||||
F5DE10E90209DC0601A967DF,
|
||||
F517395B020CE3740189DA0C,
|
||||
F528E21A020FD9620168DE43,
|
||||
);
|
||||
isa = PBXGroup;
|
||||
name = Dialogs;
|
||||
refType = 4;
|
||||
};
|
||||
F512F52C02D1287F01072C9F = {
|
||||
children = (
|
||||
F57074BE026D80DF01A80166,
|
||||
2E2939FF027F33604B000102,
|
||||
2E748B73029A448D4B000102,
|
||||
);
|
||||
isa = PBXGroup;
|
||||
name = "UI elements";
|
||||
refType = 4;
|
||||
};
|
||||
F512F52D02D1287F01072C9F = {
|
||||
children = (
|
||||
F5DE10EB0209DC0601A967DF,
|
||||
F59E9F3F0237E43401A967DF,
|
||||
F5DE10EA0209DC0601A967DF,
|
||||
F6BA6D4E01B2F8A601A962F7,
|
||||
F632AF8402B9AEBB01000103,
|
||||
F56769FB0208F74A010001CA,
|
||||
);
|
||||
isa = PBXGroup;
|
||||
name = "Browser window";
|
||||
path = "";
|
||||
refType = 4;
|
||||
};
|
||||
F512F53302D17A2601072C9F = {
|
||||
children = (
|
||||
29B97316FDCFA39411CA2CEA,
|
||||
F59236C002C89AC90100012B,
|
||||
F5AE04BA0206A4FE01A967DF,
|
||||
F52D5CD8027D3D5001A80166,
|
||||
);
|
||||
isa = PBXGroup;
|
||||
name = Application;
|
||||
path = "";
|
||||
refType = 4;
|
||||
};
|
||||
F5137A1102676B9101026D05 = {
|
||||
isa = PBXFileReference;
|
||||
path = CHFind.h;
|
||||
|
@ -1228,6 +1269,7 @@
|
|||
F53E012902AEE91C01A967F3,
|
||||
F53E013202AEEA2801A967F3,
|
||||
F5A3669302CCFAF601DC3354,
|
||||
F59236C102C89AC90100012B,
|
||||
);
|
||||
isa = PBXGroup;
|
||||
name = Headers;
|
||||
|
|
|
@ -34,30 +34,7 @@
|
|||
|
||||
- (id)performDefaultImplementation
|
||||
{
|
||||
// get the pref that specifies if we want to re-use the existing window or
|
||||
// open a new one. There's really no point caching this pref.
|
||||
PRBool reuseWindow = PR_FALSE;
|
||||
PRBool loadInBackground = PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIPref> prefService ( do_GetService(NS_PREF_CONTRACTID) );
|
||||
if ( prefService ) {
|
||||
prefService->GetBoolPref("browser.always_reuse_window", &reuseWindow);
|
||||
prefService->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
|
||||
}
|
||||
|
||||
// reuse the main window if there is one. The user may have closed all of
|
||||
// them or we may get this event at startup before we've had time to load
|
||||
// our window.
|
||||
|
||||
BrowserWindowController* controller = NULL;
|
||||
if ( reuseWindow && [NSApp mainWindow] ) {
|
||||
controller = [[NSApp mainWindow] windowController];
|
||||
[controller openNewTabWithURL:[self directParameter] loadInBackground:loadInBackground];
|
||||
}
|
||||
else
|
||||
controller = [[NSApp delegate] openBrowserWindowWithURL: [self directParameter]];
|
||||
|
||||
[[[controller getBrowserWrapper] getBrowserView] setActive: YES];
|
||||
[[NSApp delegate] openNewWindowOrTabWithURL:[self directParameter]];
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
|
|
@ -117,9 +117,14 @@ class BookmarksService;
|
|||
-(IBAction) closeTab:(id)aSender;
|
||||
|
||||
-(BrowserWindowController*)openBrowserWindowWithURL: (NSString*)aURL;
|
||||
- (void)openNewWindowOrTabWithURL:(NSString*)inURLString;
|
||||
|
||||
-(NSWindow*)getFrontmostBrowserWindow;
|
||||
|
||||
- (MVPreferencesController *)preferencesController;
|
||||
- (void)displayPreferencesWindow:sender;
|
||||
- (CHPreferenceManager *)preferenceManager;
|
||||
- (BOOL)isMainWindowABrowserWindow;
|
||||
|
||||
- (IBAction)showAboutBox:(id)sender;
|
||||
|
||||
|
|
|
@ -35,20 +35,24 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#import "MainController.h"
|
||||
#import "BrowserWindowController.h"
|
||||
#include "BookmarksService.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsCocoaBrowserService.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsEmbedAPI.h"
|
||||
#include "nsIChromeRegistry.h"
|
||||
#import "CHAboutBox.h"
|
||||
#include <Foundation/NSUserDefaults.h>
|
||||
#include <mach-o/dyld.h>
|
||||
|
||||
#import "MainController.h"
|
||||
#import "BrowserWindowController.h"
|
||||
#import "BookmarksService.h"
|
||||
#import "nsCocoaBrowserService.h"
|
||||
#import "CHAboutBox.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsEmbedAPI.h"
|
||||
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsIPref.h"
|
||||
#include "nsIChromeRegistry.h"
|
||||
|
||||
|
||||
#ifdef _BUILD_STATIC_BIN
|
||||
#include "nsStaticComponent.h"
|
||||
nsresult PR_CALLBACK
|
||||
|
@ -106,37 +110,41 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
printf("Main controller died.\n");
|
||||
}
|
||||
|
||||
-(void)awakeFromNib
|
||||
-(void)applicationDidFinishLaunching:(NSNotification *)aNotification
|
||||
{
|
||||
#ifdef _BUILD_STATIC_BIN
|
||||
[self updatePrebinding];
|
||||
[self updatePrebinding];
|
||||
#endif
|
||||
// initialize if we haven't already.
|
||||
[self preferenceManager];
|
||||
|
||||
mPreferenceManager = [[CHPreferenceManager sharedInstance] retain];
|
||||
|
||||
// don't open a new browser window if we already have one
|
||||
// (for example, from an GetURL Apple Event)
|
||||
NSWindow* browserWindow = [self getFrontmostBrowserWindow];
|
||||
if (!browserWindow)
|
||||
[self newWindow: self];
|
||||
|
||||
[mSplashScreen close];
|
||||
[mSplashScreen close];
|
||||
|
||||
[mBookmarksMenu setAutoenablesItems: NO];
|
||||
mMenuBookmarks = new BookmarksService((BookmarksDataSource*)nil);
|
||||
mMenuBookmarks->AddObserver();
|
||||
mMenuBookmarks->ConstructBookmarksMenu(mBookmarksMenu, nsnull);
|
||||
BookmarksService::gMainController = self;
|
||||
[mBookmarksMenu setAutoenablesItems: NO];
|
||||
mMenuBookmarks = new BookmarksService((BookmarksDataSource*)nil);
|
||||
mMenuBookmarks->AddObserver();
|
||||
mMenuBookmarks->ConstructBookmarksMenu(mBookmarksMenu, nsnull);
|
||||
BookmarksService::gMainController = self;
|
||||
|
||||
// Initialize offline mode.
|
||||
mOffline = NO;
|
||||
nsCOMPtr<nsIIOService> ioService(do_GetService(ioServiceContractID));
|
||||
if (!ioService)
|
||||
return;
|
||||
PRBool offline = PR_FALSE;
|
||||
ioService->GetOffline(&offline);
|
||||
mOffline = offline;
|
||||
// Initialize offline mode.
|
||||
mOffline = NO;
|
||||
nsCOMPtr<nsIIOService> ioService(do_GetService(ioServiceContractID));
|
||||
if (!ioService)
|
||||
return;
|
||||
PRBool offline = PR_FALSE;
|
||||
ioService->GetOffline(&offline);
|
||||
mOffline = offline;
|
||||
|
||||
// Set the menu item's text to "Go Online" if we're currently
|
||||
// offline.
|
||||
if (mOffline)
|
||||
[mOfflineMenuItem setTitle: @"Go Online"];
|
||||
// Set the menu item's text to "Go Online" if we're currently
|
||||
// offline.
|
||||
if (mOffline)
|
||||
[mOfflineMenuItem setTitle: @"Go Online"]; // XXX localize me
|
||||
}
|
||||
|
||||
-(IBAction)newWindow:(id)aSender
|
||||
|
@ -316,6 +324,29 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
[[[mApplication mainWindow] windowController] home: aSender];
|
||||
}
|
||||
|
||||
-(NSWindow*)getFrontmostBrowserWindow
|
||||
{
|
||||
// for some reason, [NSApp mainWindow] doesn't always work, so we have to
|
||||
// do this manually
|
||||
NSArray *windowList = [NSApp orderedWindows];
|
||||
NSWindow *foundWindow = NULL;
|
||||
|
||||
for (unsigned int i = 0; i < [windowList count]; i ++)
|
||||
{
|
||||
NSWindow* thisWindow = [windowList objectAtIndex:i];
|
||||
|
||||
if ([[thisWindow windowController] isMemberOfClass:[BrowserWindowController class]] &&
|
||||
([[thisWindow windowController] chromeMask] == 0)) // only get windows with full chrome
|
||||
{
|
||||
foundWindow = thisWindow;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return foundWindow;
|
||||
}
|
||||
|
||||
// open a new URL. This method always makes a new browser window
|
||||
-(BrowserWindowController*)openBrowserWindowWithURL: (NSString*)aURL
|
||||
{
|
||||
BrowserWindowController* browser = [[BrowserWindowController alloc] initWithWindowNibName: @"BrowserWindow"];
|
||||
|
@ -324,6 +355,40 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
return browser;
|
||||
}
|
||||
|
||||
// open a new URL, observing the prefs on how to behave
|
||||
- (void)openNewWindowOrTabWithURL:(NSString*)inURLString
|
||||
{
|
||||
// make sure we're initted
|
||||
[self preferenceManager];
|
||||
|
||||
PRBool reuseWindow = PR_FALSE;
|
||||
PRBool loadInBackground = PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIPref> prefService ( do_GetService(NS_PREF_CONTRACTID) );
|
||||
if ( prefService ) {
|
||||
prefService->GetBoolPref("browser.always_reuse_window", &reuseWindow);
|
||||
prefService->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
|
||||
}
|
||||
|
||||
// reuse the main window if there is one. The user may have closed all of
|
||||
// them or we may get this event at startup before we've had time to load
|
||||
// our window.
|
||||
BrowserWindowController* controller = NULL;
|
||||
|
||||
NSWindow* browserWindow = [self getFrontmostBrowserWindow];
|
||||
if (reuseWindow && browserWindow) {
|
||||
controller = [browserWindow windowController];
|
||||
[controller openNewTabWithURL:inURLString loadInBackground:loadInBackground];
|
||||
}
|
||||
else {
|
||||
controller = [self openBrowserWindowWithURL: inURLString];
|
||||
}
|
||||
|
||||
[[[controller getBrowserWrapper] getBrowserView] setActive: YES];
|
||||
|
||||
}
|
||||
|
||||
|
||||
-(void)applicationWillTerminate: (NSNotification*)aNotification
|
||||
{
|
||||
printf("Termination notification.\n");
|
||||
|
@ -410,6 +475,13 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
[[mainWindow windowController] manageBookmarks: aSender];
|
||||
}
|
||||
|
||||
- (CHPreferenceManager *)preferenceManager
|
||||
{
|
||||
if (!mPreferenceManager)
|
||||
mPreferenceManager = [[CHPreferenceManager sharedInstance] retain];
|
||||
return mPreferenceManager;
|
||||
}
|
||||
|
||||
- (MVPreferencesController *)preferencesController
|
||||
{
|
||||
if (!preferencesController) {
|
||||
|
@ -430,16 +502,23 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
|
||||
- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
|
||||
{
|
||||
NSWindow* mainWindow = [mApplication mainWindow];
|
||||
/*
|
||||
// On the off chance that we're getting this message off a launch,
|
||||
// we may not have initialized our embedded mozilla. So check here,
|
||||
// and if it's not initialized, do it now.
|
||||
[self preferenceManager];
|
||||
|
||||
if (mainWindow) {
|
||||
[[mainWindow windowController] loadURL:[[NSURL fileURLWithPath:filename] absoluteString]];
|
||||
} else {
|
||||
[self openBrowserWindowWithURL:[[NSURL fileURLWithPath:filename] absoluteString]];
|
||||
}
|
||||
|
||||
return YES;
|
||||
// Make sure it's a browser window b/c "about box" can also become main window.
|
||||
if ([self isMainWindowABrowserWindow]) {
|
||||
[[[mApplication mainWindow] windowController] loadURL:[[NSURL fileURLWithPath:filename] absoluteString]];
|
||||
}
|
||||
else {
|
||||
[self openBrowserWindowWithURL:[[NSURL fileURLWithPath:filename] absoluteString]];
|
||||
}
|
||||
*/
|
||||
[self openNewWindowOrTabWithURL:[[NSURL fileURLWithPath:filename] absoluteString]];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (IBAction)biggerTextSize:(id)aSender
|
||||
|
@ -462,6 +541,7 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
|
||||
-(BOOL)isMainWindowABrowserWindow
|
||||
{
|
||||
// see also getFrontmostBrowserWindow
|
||||
return [[[mApplication mainWindow] windowController] isMemberOfClass:[BrowserWindowController class]];
|
||||
}
|
||||
|
||||
|
|
|
@ -34,30 +34,7 @@
|
|||
|
||||
- (id)performDefaultImplementation
|
||||
{
|
||||
// get the pref that specifies if we want to re-use the existing window or
|
||||
// open a new one. There's really no point caching this pref.
|
||||
PRBool reuseWindow = PR_FALSE;
|
||||
PRBool loadInBackground = PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIPref> prefService ( do_GetService(NS_PREF_CONTRACTID) );
|
||||
if ( prefService ) {
|
||||
prefService->GetBoolPref("browser.always_reuse_window", &reuseWindow);
|
||||
prefService->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
|
||||
}
|
||||
|
||||
// reuse the main window if there is one. The user may have closed all of
|
||||
// them or we may get this event at startup before we've had time to load
|
||||
// our window.
|
||||
|
||||
BrowserWindowController* controller = NULL;
|
||||
if ( reuseWindow && [NSApp mainWindow] ) {
|
||||
controller = [[NSApp mainWindow] windowController];
|
||||
[controller openNewTabWithURL:[self directParameter] loadInBackground:loadInBackground];
|
||||
}
|
||||
else
|
||||
controller = [[NSApp delegate] openBrowserWindowWithURL: [self directParameter]];
|
||||
|
||||
[[[controller getBrowserWrapper] getBrowserView] setActive: YES];
|
||||
[[NSApp delegate] openNewWindowOrTabWithURL:[self directParameter]];
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,24 +7,14 @@
|
|||
objects = {
|
||||
080E96DDFE201D6D7F000001 = {
|
||||
children = (
|
||||
F512F53302D17A2601072C9F,
|
||||
F512F52A02D1287F01072C9F,
|
||||
F5A3669402CCFAF601DC3354,
|
||||
F5A3669602CCFAF601DC3354,
|
||||
F512F52B02D1287F01072C9F,
|
||||
F5A3669702CCFAF601DC3354,
|
||||
F5DE10E90209DC0601A967DF,
|
||||
F517395B020CE3740189DA0C,
|
||||
F528E21A020FD9620168DE43,
|
||||
F5DE10EA0209DC0601A967DF,
|
||||
F632AF8402B9AEBB01000103,
|
||||
F5DE10EB0209DC0601A967DF,
|
||||
F51B70B7026EC98B01A80166,
|
||||
F5AE04BA0206A4FE01A967DF,
|
||||
F52D5CD8027D3D5001A80166,
|
||||
F6BA6D4E01B2F8A601A962F7,
|
||||
F56769FB0208F74A010001CA,
|
||||
F57074BE026D80DF01A80166,
|
||||
2E2939FF027F33604B000102,
|
||||
F59E9F3F0237E43401A967DF,
|
||||
2E748B73029A448D4B000102,
|
||||
F512F52C02D1287F01072C9F,
|
||||
F512F52D02D1287F01072C9F,
|
||||
);
|
||||
isa = PBXGroup;
|
||||
name = Classes;
|
||||
|
@ -173,10 +163,10 @@
|
|||
children = (
|
||||
F51842F30206168101A966FE,
|
||||
080E96DDFE201D6D7F000001,
|
||||
F5571935022B401B010001CA,
|
||||
F53F21EB022B7C77010001CA,
|
||||
F5807368023A1514010001CA,
|
||||
F580736B023A1514010001CA,
|
||||
F5571935022B401B010001CA,
|
||||
29B97315FDCFA39411CA2CEA,
|
||||
29B97317FDCFA39411CA2CEA,
|
||||
29B97323FDCFA39411CA2CEA,
|
||||
|
@ -191,11 +181,8 @@
|
|||
};
|
||||
29B97315FDCFA39411CA2CEA = {
|
||||
children = (
|
||||
29B97316FDCFA39411CA2CEA,
|
||||
F59236C002C89AC90100012B,
|
||||
F59236C102C89AC90100012B,
|
||||
F56F241F02AC6D0401A967F3,
|
||||
F5D1421902BC88F801A967F3,
|
||||
F56F241F02AC6D0401A967F3,
|
||||
);
|
||||
isa = PBXGroup;
|
||||
name = "Other Sources";
|
||||
|
@ -1132,6 +1119,60 @@
|
|||
settings = {
|
||||
};
|
||||
};
|
||||
F512F52A02D1287F01072C9F = {
|
||||
children = (
|
||||
F51B70B7026EC98B01A80166,
|
||||
);
|
||||
isa = PBXGroup;
|
||||
name = "Apple Events";
|
||||
refType = 4;
|
||||
};
|
||||
F512F52B02D1287F01072C9F = {
|
||||
children = (
|
||||
F5DE10E90209DC0601A967DF,
|
||||
F517395B020CE3740189DA0C,
|
||||
F528E21A020FD9620168DE43,
|
||||
);
|
||||
isa = PBXGroup;
|
||||
name = Dialogs;
|
||||
refType = 4;
|
||||
};
|
||||
F512F52C02D1287F01072C9F = {
|
||||
children = (
|
||||
F57074BE026D80DF01A80166,
|
||||
2E2939FF027F33604B000102,
|
||||
2E748B73029A448D4B000102,
|
||||
);
|
||||
isa = PBXGroup;
|
||||
name = "UI elements";
|
||||
refType = 4;
|
||||
};
|
||||
F512F52D02D1287F01072C9F = {
|
||||
children = (
|
||||
F5DE10EB0209DC0601A967DF,
|
||||
F59E9F3F0237E43401A967DF,
|
||||
F5DE10EA0209DC0601A967DF,
|
||||
F6BA6D4E01B2F8A601A962F7,
|
||||
F632AF8402B9AEBB01000103,
|
||||
F56769FB0208F74A010001CA,
|
||||
);
|
||||
isa = PBXGroup;
|
||||
name = "Browser window";
|
||||
path = "";
|
||||
refType = 4;
|
||||
};
|
||||
F512F53302D17A2601072C9F = {
|
||||
children = (
|
||||
29B97316FDCFA39411CA2CEA,
|
||||
F59236C002C89AC90100012B,
|
||||
F5AE04BA0206A4FE01A967DF,
|
||||
F52D5CD8027D3D5001A80166,
|
||||
);
|
||||
isa = PBXGroup;
|
||||
name = Application;
|
||||
path = "";
|
||||
refType = 4;
|
||||
};
|
||||
F5137A1102676B9101026D05 = {
|
||||
isa = PBXFileReference;
|
||||
path = CHFind.h;
|
||||
|
@ -1228,6 +1269,7 @@
|
|||
F53E012902AEE91C01A967F3,
|
||||
F53E013202AEEA2801A967F3,
|
||||
F5A3669302CCFAF601DC3354,
|
||||
F59236C102C89AC90100012B,
|
||||
);
|
||||
isa = PBXGroup;
|
||||
name = Headers;
|
||||
|
|
|
@ -117,9 +117,14 @@ class BookmarksService;
|
|||
-(IBAction) closeTab:(id)aSender;
|
||||
|
||||
-(BrowserWindowController*)openBrowserWindowWithURL: (NSString*)aURL;
|
||||
- (void)openNewWindowOrTabWithURL:(NSString*)inURLString;
|
||||
|
||||
-(NSWindow*)getFrontmostBrowserWindow;
|
||||
|
||||
- (MVPreferencesController *)preferencesController;
|
||||
- (void)displayPreferencesWindow:sender;
|
||||
- (CHPreferenceManager *)preferenceManager;
|
||||
- (BOOL)isMainWindowABrowserWindow;
|
||||
|
||||
- (IBAction)showAboutBox:(id)sender;
|
||||
|
||||
|
|
|
@ -35,20 +35,24 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#import "MainController.h"
|
||||
#import "BrowserWindowController.h"
|
||||
#include "BookmarksService.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsCocoaBrowserService.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsEmbedAPI.h"
|
||||
#include "nsIChromeRegistry.h"
|
||||
#import "CHAboutBox.h"
|
||||
#include <Foundation/NSUserDefaults.h>
|
||||
#include <mach-o/dyld.h>
|
||||
|
||||
#import "MainController.h"
|
||||
#import "BrowserWindowController.h"
|
||||
#import "BookmarksService.h"
|
||||
#import "nsCocoaBrowserService.h"
|
||||
#import "CHAboutBox.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsEmbedAPI.h"
|
||||
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsIPref.h"
|
||||
#include "nsIChromeRegistry.h"
|
||||
|
||||
|
||||
#ifdef _BUILD_STATIC_BIN
|
||||
#include "nsStaticComponent.h"
|
||||
nsresult PR_CALLBACK
|
||||
|
@ -106,37 +110,41 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
printf("Main controller died.\n");
|
||||
}
|
||||
|
||||
-(void)awakeFromNib
|
||||
-(void)applicationDidFinishLaunching:(NSNotification *)aNotification
|
||||
{
|
||||
#ifdef _BUILD_STATIC_BIN
|
||||
[self updatePrebinding];
|
||||
[self updatePrebinding];
|
||||
#endif
|
||||
// initialize if we haven't already.
|
||||
[self preferenceManager];
|
||||
|
||||
mPreferenceManager = [[CHPreferenceManager sharedInstance] retain];
|
||||
|
||||
// don't open a new browser window if we already have one
|
||||
// (for example, from an GetURL Apple Event)
|
||||
NSWindow* browserWindow = [self getFrontmostBrowserWindow];
|
||||
if (!browserWindow)
|
||||
[self newWindow: self];
|
||||
|
||||
[mSplashScreen close];
|
||||
[mSplashScreen close];
|
||||
|
||||
[mBookmarksMenu setAutoenablesItems: NO];
|
||||
mMenuBookmarks = new BookmarksService((BookmarksDataSource*)nil);
|
||||
mMenuBookmarks->AddObserver();
|
||||
mMenuBookmarks->ConstructBookmarksMenu(mBookmarksMenu, nsnull);
|
||||
BookmarksService::gMainController = self;
|
||||
[mBookmarksMenu setAutoenablesItems: NO];
|
||||
mMenuBookmarks = new BookmarksService((BookmarksDataSource*)nil);
|
||||
mMenuBookmarks->AddObserver();
|
||||
mMenuBookmarks->ConstructBookmarksMenu(mBookmarksMenu, nsnull);
|
||||
BookmarksService::gMainController = self;
|
||||
|
||||
// Initialize offline mode.
|
||||
mOffline = NO;
|
||||
nsCOMPtr<nsIIOService> ioService(do_GetService(ioServiceContractID));
|
||||
if (!ioService)
|
||||
return;
|
||||
PRBool offline = PR_FALSE;
|
||||
ioService->GetOffline(&offline);
|
||||
mOffline = offline;
|
||||
// Initialize offline mode.
|
||||
mOffline = NO;
|
||||
nsCOMPtr<nsIIOService> ioService(do_GetService(ioServiceContractID));
|
||||
if (!ioService)
|
||||
return;
|
||||
PRBool offline = PR_FALSE;
|
||||
ioService->GetOffline(&offline);
|
||||
mOffline = offline;
|
||||
|
||||
// Set the menu item's text to "Go Online" if we're currently
|
||||
// offline.
|
||||
if (mOffline)
|
||||
[mOfflineMenuItem setTitle: @"Go Online"];
|
||||
// Set the menu item's text to "Go Online" if we're currently
|
||||
// offline.
|
||||
if (mOffline)
|
||||
[mOfflineMenuItem setTitle: @"Go Online"]; // XXX localize me
|
||||
}
|
||||
|
||||
-(IBAction)newWindow:(id)aSender
|
||||
|
@ -316,6 +324,29 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
[[[mApplication mainWindow] windowController] home: aSender];
|
||||
}
|
||||
|
||||
-(NSWindow*)getFrontmostBrowserWindow
|
||||
{
|
||||
// for some reason, [NSApp mainWindow] doesn't always work, so we have to
|
||||
// do this manually
|
||||
NSArray *windowList = [NSApp orderedWindows];
|
||||
NSWindow *foundWindow = NULL;
|
||||
|
||||
for (unsigned int i = 0; i < [windowList count]; i ++)
|
||||
{
|
||||
NSWindow* thisWindow = [windowList objectAtIndex:i];
|
||||
|
||||
if ([[thisWindow windowController] isMemberOfClass:[BrowserWindowController class]] &&
|
||||
([[thisWindow windowController] chromeMask] == 0)) // only get windows with full chrome
|
||||
{
|
||||
foundWindow = thisWindow;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return foundWindow;
|
||||
}
|
||||
|
||||
// open a new URL. This method always makes a new browser window
|
||||
-(BrowserWindowController*)openBrowserWindowWithURL: (NSString*)aURL
|
||||
{
|
||||
BrowserWindowController* browser = [[BrowserWindowController alloc] initWithWindowNibName: @"BrowserWindow"];
|
||||
|
@ -324,6 +355,40 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
return browser;
|
||||
}
|
||||
|
||||
// open a new URL, observing the prefs on how to behave
|
||||
- (void)openNewWindowOrTabWithURL:(NSString*)inURLString
|
||||
{
|
||||
// make sure we're initted
|
||||
[self preferenceManager];
|
||||
|
||||
PRBool reuseWindow = PR_FALSE;
|
||||
PRBool loadInBackground = PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIPref> prefService ( do_GetService(NS_PREF_CONTRACTID) );
|
||||
if ( prefService ) {
|
||||
prefService->GetBoolPref("browser.always_reuse_window", &reuseWindow);
|
||||
prefService->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
|
||||
}
|
||||
|
||||
// reuse the main window if there is one. The user may have closed all of
|
||||
// them or we may get this event at startup before we've had time to load
|
||||
// our window.
|
||||
BrowserWindowController* controller = NULL;
|
||||
|
||||
NSWindow* browserWindow = [self getFrontmostBrowserWindow];
|
||||
if (reuseWindow && browserWindow) {
|
||||
controller = [browserWindow windowController];
|
||||
[controller openNewTabWithURL:inURLString loadInBackground:loadInBackground];
|
||||
}
|
||||
else {
|
||||
controller = [self openBrowserWindowWithURL: inURLString];
|
||||
}
|
||||
|
||||
[[[controller getBrowserWrapper] getBrowserView] setActive: YES];
|
||||
|
||||
}
|
||||
|
||||
|
||||
-(void)applicationWillTerminate: (NSNotification*)aNotification
|
||||
{
|
||||
printf("Termination notification.\n");
|
||||
|
@ -410,6 +475,13 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
[[mainWindow windowController] manageBookmarks: aSender];
|
||||
}
|
||||
|
||||
- (CHPreferenceManager *)preferenceManager
|
||||
{
|
||||
if (!mPreferenceManager)
|
||||
mPreferenceManager = [[CHPreferenceManager sharedInstance] retain];
|
||||
return mPreferenceManager;
|
||||
}
|
||||
|
||||
- (MVPreferencesController *)preferencesController
|
||||
{
|
||||
if (!preferencesController) {
|
||||
|
@ -430,16 +502,23 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
|
||||
- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
|
||||
{
|
||||
NSWindow* mainWindow = [mApplication mainWindow];
|
||||
/*
|
||||
// On the off chance that we're getting this message off a launch,
|
||||
// we may not have initialized our embedded mozilla. So check here,
|
||||
// and if it's not initialized, do it now.
|
||||
[self preferenceManager];
|
||||
|
||||
if (mainWindow) {
|
||||
[[mainWindow windowController] loadURL:[[NSURL fileURLWithPath:filename] absoluteString]];
|
||||
} else {
|
||||
[self openBrowserWindowWithURL:[[NSURL fileURLWithPath:filename] absoluteString]];
|
||||
}
|
||||
|
||||
return YES;
|
||||
// Make sure it's a browser window b/c "about box" can also become main window.
|
||||
if ([self isMainWindowABrowserWindow]) {
|
||||
[[[mApplication mainWindow] windowController] loadURL:[[NSURL fileURLWithPath:filename] absoluteString]];
|
||||
}
|
||||
else {
|
||||
[self openBrowserWindowWithURL:[[NSURL fileURLWithPath:filename] absoluteString]];
|
||||
}
|
||||
*/
|
||||
[self openNewWindowOrTabWithURL:[[NSURL fileURLWithPath:filename] absoluteString]];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (IBAction)biggerTextSize:(id)aSender
|
||||
|
@ -462,6 +541,7 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
|
||||
-(BOOL)isMainWindowABrowserWindow
|
||||
{
|
||||
// see also getFrontmostBrowserWindow
|
||||
return [[[mApplication mainWindow] windowController] isMemberOfClass:[BrowserWindowController class]];
|
||||
}
|
||||
|
||||
|
|
|
@ -7,24 +7,14 @@
|
|||
objects = {
|
||||
080E96DDFE201D6D7F000001 = {
|
||||
children = (
|
||||
F512F53302D17A2601072C9F,
|
||||
F512F52A02D1287F01072C9F,
|
||||
F5A3669402CCFAF601DC3354,
|
||||
F5A3669602CCFAF601DC3354,
|
||||
F512F52B02D1287F01072C9F,
|
||||
F5A3669702CCFAF601DC3354,
|
||||
F5DE10E90209DC0601A967DF,
|
||||
F517395B020CE3740189DA0C,
|
||||
F528E21A020FD9620168DE43,
|
||||
F5DE10EA0209DC0601A967DF,
|
||||
F632AF8402B9AEBB01000103,
|
||||
F5DE10EB0209DC0601A967DF,
|
||||
F51B70B7026EC98B01A80166,
|
||||
F5AE04BA0206A4FE01A967DF,
|
||||
F52D5CD8027D3D5001A80166,
|
||||
F6BA6D4E01B2F8A601A962F7,
|
||||
F56769FB0208F74A010001CA,
|
||||
F57074BE026D80DF01A80166,
|
||||
2E2939FF027F33604B000102,
|
||||
F59E9F3F0237E43401A967DF,
|
||||
2E748B73029A448D4B000102,
|
||||
F512F52C02D1287F01072C9F,
|
||||
F512F52D02D1287F01072C9F,
|
||||
);
|
||||
isa = PBXGroup;
|
||||
name = Classes;
|
||||
|
@ -173,10 +163,10 @@
|
|||
children = (
|
||||
F51842F30206168101A966FE,
|
||||
080E96DDFE201D6D7F000001,
|
||||
F5571935022B401B010001CA,
|
||||
F53F21EB022B7C77010001CA,
|
||||
F5807368023A1514010001CA,
|
||||
F580736B023A1514010001CA,
|
||||
F5571935022B401B010001CA,
|
||||
29B97315FDCFA39411CA2CEA,
|
||||
29B97317FDCFA39411CA2CEA,
|
||||
29B97323FDCFA39411CA2CEA,
|
||||
|
@ -191,11 +181,8 @@
|
|||
};
|
||||
29B97315FDCFA39411CA2CEA = {
|
||||
children = (
|
||||
29B97316FDCFA39411CA2CEA,
|
||||
F59236C002C89AC90100012B,
|
||||
F59236C102C89AC90100012B,
|
||||
F56F241F02AC6D0401A967F3,
|
||||
F5D1421902BC88F801A967F3,
|
||||
F56F241F02AC6D0401A967F3,
|
||||
);
|
||||
isa = PBXGroup;
|
||||
name = "Other Sources";
|
||||
|
@ -1132,6 +1119,60 @@
|
|||
settings = {
|
||||
};
|
||||
};
|
||||
F512F52A02D1287F01072C9F = {
|
||||
children = (
|
||||
F51B70B7026EC98B01A80166,
|
||||
);
|
||||
isa = PBXGroup;
|
||||
name = "Apple Events";
|
||||
refType = 4;
|
||||
};
|
||||
F512F52B02D1287F01072C9F = {
|
||||
children = (
|
||||
F5DE10E90209DC0601A967DF,
|
||||
F517395B020CE3740189DA0C,
|
||||
F528E21A020FD9620168DE43,
|
||||
);
|
||||
isa = PBXGroup;
|
||||
name = Dialogs;
|
||||
refType = 4;
|
||||
};
|
||||
F512F52C02D1287F01072C9F = {
|
||||
children = (
|
||||
F57074BE026D80DF01A80166,
|
||||
2E2939FF027F33604B000102,
|
||||
2E748B73029A448D4B000102,
|
||||
);
|
||||
isa = PBXGroup;
|
||||
name = "UI elements";
|
||||
refType = 4;
|
||||
};
|
||||
F512F52D02D1287F01072C9F = {
|
||||
children = (
|
||||
F5DE10EB0209DC0601A967DF,
|
||||
F59E9F3F0237E43401A967DF,
|
||||
F5DE10EA0209DC0601A967DF,
|
||||
F6BA6D4E01B2F8A601A962F7,
|
||||
F632AF8402B9AEBB01000103,
|
||||
F56769FB0208F74A010001CA,
|
||||
);
|
||||
isa = PBXGroup;
|
||||
name = "Browser window";
|
||||
path = "";
|
||||
refType = 4;
|
||||
};
|
||||
F512F53302D17A2601072C9F = {
|
||||
children = (
|
||||
29B97316FDCFA39411CA2CEA,
|
||||
F59236C002C89AC90100012B,
|
||||
F5AE04BA0206A4FE01A967DF,
|
||||
F52D5CD8027D3D5001A80166,
|
||||
);
|
||||
isa = PBXGroup;
|
||||
name = Application;
|
||||
path = "";
|
||||
refType = 4;
|
||||
};
|
||||
F5137A1102676B9101026D05 = {
|
||||
isa = PBXFileReference;
|
||||
path = CHFind.h;
|
||||
|
@ -1228,6 +1269,7 @@
|
|||
F53E012902AEE91C01A967F3,
|
||||
F53E013202AEEA2801A967F3,
|
||||
F5A3669302CCFAF601DC3354,
|
||||
F59236C102C89AC90100012B,
|
||||
);
|
||||
isa = PBXGroup;
|
||||
name = Headers;
|
||||
|
|
|
@ -34,30 +34,7 @@
|
|||
|
||||
- (id)performDefaultImplementation
|
||||
{
|
||||
// get the pref that specifies if we want to re-use the existing window or
|
||||
// open a new one. There's really no point caching this pref.
|
||||
PRBool reuseWindow = PR_FALSE;
|
||||
PRBool loadInBackground = PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIPref> prefService ( do_GetService(NS_PREF_CONTRACTID) );
|
||||
if ( prefService ) {
|
||||
prefService->GetBoolPref("browser.always_reuse_window", &reuseWindow);
|
||||
prefService->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
|
||||
}
|
||||
|
||||
// reuse the main window if there is one. The user may have closed all of
|
||||
// them or we may get this event at startup before we've had time to load
|
||||
// our window.
|
||||
|
||||
BrowserWindowController* controller = NULL;
|
||||
if ( reuseWindow && [NSApp mainWindow] ) {
|
||||
controller = [[NSApp mainWindow] windowController];
|
||||
[controller openNewTabWithURL:[self directParameter] loadInBackground:loadInBackground];
|
||||
}
|
||||
else
|
||||
controller = [[NSApp delegate] openBrowserWindowWithURL: [self directParameter]];
|
||||
|
||||
[[[controller getBrowserWrapper] getBrowserView] setActive: YES];
|
||||
[[NSApp delegate] openNewWindowOrTabWithURL:[self directParameter]];
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
|
|
@ -117,9 +117,14 @@ class BookmarksService;
|
|||
-(IBAction) closeTab:(id)aSender;
|
||||
|
||||
-(BrowserWindowController*)openBrowserWindowWithURL: (NSString*)aURL;
|
||||
- (void)openNewWindowOrTabWithURL:(NSString*)inURLString;
|
||||
|
||||
-(NSWindow*)getFrontmostBrowserWindow;
|
||||
|
||||
- (MVPreferencesController *)preferencesController;
|
||||
- (void)displayPreferencesWindow:sender;
|
||||
- (CHPreferenceManager *)preferenceManager;
|
||||
- (BOOL)isMainWindowABrowserWindow;
|
||||
|
||||
- (IBAction)showAboutBox:(id)sender;
|
||||
|
||||
|
|
|
@ -35,20 +35,24 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#import "MainController.h"
|
||||
#import "BrowserWindowController.h"
|
||||
#include "BookmarksService.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsCocoaBrowserService.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsEmbedAPI.h"
|
||||
#include "nsIChromeRegistry.h"
|
||||
#import "CHAboutBox.h"
|
||||
#include <Foundation/NSUserDefaults.h>
|
||||
#include <mach-o/dyld.h>
|
||||
|
||||
#import "MainController.h"
|
||||
#import "BrowserWindowController.h"
|
||||
#import "BookmarksService.h"
|
||||
#import "nsCocoaBrowserService.h"
|
||||
#import "CHAboutBox.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsEmbedAPI.h"
|
||||
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsIPref.h"
|
||||
#include "nsIChromeRegistry.h"
|
||||
|
||||
|
||||
#ifdef _BUILD_STATIC_BIN
|
||||
#include "nsStaticComponent.h"
|
||||
nsresult PR_CALLBACK
|
||||
|
@ -106,37 +110,41 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
printf("Main controller died.\n");
|
||||
}
|
||||
|
||||
-(void)awakeFromNib
|
||||
-(void)applicationDidFinishLaunching:(NSNotification *)aNotification
|
||||
{
|
||||
#ifdef _BUILD_STATIC_BIN
|
||||
[self updatePrebinding];
|
||||
[self updatePrebinding];
|
||||
#endif
|
||||
// initialize if we haven't already.
|
||||
[self preferenceManager];
|
||||
|
||||
mPreferenceManager = [[CHPreferenceManager sharedInstance] retain];
|
||||
|
||||
// don't open a new browser window if we already have one
|
||||
// (for example, from an GetURL Apple Event)
|
||||
NSWindow* browserWindow = [self getFrontmostBrowserWindow];
|
||||
if (!browserWindow)
|
||||
[self newWindow: self];
|
||||
|
||||
[mSplashScreen close];
|
||||
[mSplashScreen close];
|
||||
|
||||
[mBookmarksMenu setAutoenablesItems: NO];
|
||||
mMenuBookmarks = new BookmarksService((BookmarksDataSource*)nil);
|
||||
mMenuBookmarks->AddObserver();
|
||||
mMenuBookmarks->ConstructBookmarksMenu(mBookmarksMenu, nsnull);
|
||||
BookmarksService::gMainController = self;
|
||||
[mBookmarksMenu setAutoenablesItems: NO];
|
||||
mMenuBookmarks = new BookmarksService((BookmarksDataSource*)nil);
|
||||
mMenuBookmarks->AddObserver();
|
||||
mMenuBookmarks->ConstructBookmarksMenu(mBookmarksMenu, nsnull);
|
||||
BookmarksService::gMainController = self;
|
||||
|
||||
// Initialize offline mode.
|
||||
mOffline = NO;
|
||||
nsCOMPtr<nsIIOService> ioService(do_GetService(ioServiceContractID));
|
||||
if (!ioService)
|
||||
return;
|
||||
PRBool offline = PR_FALSE;
|
||||
ioService->GetOffline(&offline);
|
||||
mOffline = offline;
|
||||
// Initialize offline mode.
|
||||
mOffline = NO;
|
||||
nsCOMPtr<nsIIOService> ioService(do_GetService(ioServiceContractID));
|
||||
if (!ioService)
|
||||
return;
|
||||
PRBool offline = PR_FALSE;
|
||||
ioService->GetOffline(&offline);
|
||||
mOffline = offline;
|
||||
|
||||
// Set the menu item's text to "Go Online" if we're currently
|
||||
// offline.
|
||||
if (mOffline)
|
||||
[mOfflineMenuItem setTitle: @"Go Online"];
|
||||
// Set the menu item's text to "Go Online" if we're currently
|
||||
// offline.
|
||||
if (mOffline)
|
||||
[mOfflineMenuItem setTitle: @"Go Online"]; // XXX localize me
|
||||
}
|
||||
|
||||
-(IBAction)newWindow:(id)aSender
|
||||
|
@ -316,6 +324,29 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
[[[mApplication mainWindow] windowController] home: aSender];
|
||||
}
|
||||
|
||||
-(NSWindow*)getFrontmostBrowserWindow
|
||||
{
|
||||
// for some reason, [NSApp mainWindow] doesn't always work, so we have to
|
||||
// do this manually
|
||||
NSArray *windowList = [NSApp orderedWindows];
|
||||
NSWindow *foundWindow = NULL;
|
||||
|
||||
for (unsigned int i = 0; i < [windowList count]; i ++)
|
||||
{
|
||||
NSWindow* thisWindow = [windowList objectAtIndex:i];
|
||||
|
||||
if ([[thisWindow windowController] isMemberOfClass:[BrowserWindowController class]] &&
|
||||
([[thisWindow windowController] chromeMask] == 0)) // only get windows with full chrome
|
||||
{
|
||||
foundWindow = thisWindow;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return foundWindow;
|
||||
}
|
||||
|
||||
// open a new URL. This method always makes a new browser window
|
||||
-(BrowserWindowController*)openBrowserWindowWithURL: (NSString*)aURL
|
||||
{
|
||||
BrowserWindowController* browser = [[BrowserWindowController alloc] initWithWindowNibName: @"BrowserWindow"];
|
||||
|
@ -324,6 +355,40 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
return browser;
|
||||
}
|
||||
|
||||
// open a new URL, observing the prefs on how to behave
|
||||
- (void)openNewWindowOrTabWithURL:(NSString*)inURLString
|
||||
{
|
||||
// make sure we're initted
|
||||
[self preferenceManager];
|
||||
|
||||
PRBool reuseWindow = PR_FALSE;
|
||||
PRBool loadInBackground = PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIPref> prefService ( do_GetService(NS_PREF_CONTRACTID) );
|
||||
if ( prefService ) {
|
||||
prefService->GetBoolPref("browser.always_reuse_window", &reuseWindow);
|
||||
prefService->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
|
||||
}
|
||||
|
||||
// reuse the main window if there is one. The user may have closed all of
|
||||
// them or we may get this event at startup before we've had time to load
|
||||
// our window.
|
||||
BrowserWindowController* controller = NULL;
|
||||
|
||||
NSWindow* browserWindow = [self getFrontmostBrowserWindow];
|
||||
if (reuseWindow && browserWindow) {
|
||||
controller = [browserWindow windowController];
|
||||
[controller openNewTabWithURL:inURLString loadInBackground:loadInBackground];
|
||||
}
|
||||
else {
|
||||
controller = [self openBrowserWindowWithURL: inURLString];
|
||||
}
|
||||
|
||||
[[[controller getBrowserWrapper] getBrowserView] setActive: YES];
|
||||
|
||||
}
|
||||
|
||||
|
||||
-(void)applicationWillTerminate: (NSNotification*)aNotification
|
||||
{
|
||||
printf("Termination notification.\n");
|
||||
|
@ -410,6 +475,13 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
[[mainWindow windowController] manageBookmarks: aSender];
|
||||
}
|
||||
|
||||
- (CHPreferenceManager *)preferenceManager
|
||||
{
|
||||
if (!mPreferenceManager)
|
||||
mPreferenceManager = [[CHPreferenceManager sharedInstance] retain];
|
||||
return mPreferenceManager;
|
||||
}
|
||||
|
||||
- (MVPreferencesController *)preferencesController
|
||||
{
|
||||
if (!preferencesController) {
|
||||
|
@ -430,16 +502,23 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
|
||||
- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
|
||||
{
|
||||
NSWindow* mainWindow = [mApplication mainWindow];
|
||||
/*
|
||||
// On the off chance that we're getting this message off a launch,
|
||||
// we may not have initialized our embedded mozilla. So check here,
|
||||
// and if it's not initialized, do it now.
|
||||
[self preferenceManager];
|
||||
|
||||
if (mainWindow) {
|
||||
[[mainWindow windowController] loadURL:[[NSURL fileURLWithPath:filename] absoluteString]];
|
||||
} else {
|
||||
[self openBrowserWindowWithURL:[[NSURL fileURLWithPath:filename] absoluteString]];
|
||||
}
|
||||
|
||||
return YES;
|
||||
// Make sure it's a browser window b/c "about box" can also become main window.
|
||||
if ([self isMainWindowABrowserWindow]) {
|
||||
[[[mApplication mainWindow] windowController] loadURL:[[NSURL fileURLWithPath:filename] absoluteString]];
|
||||
}
|
||||
else {
|
||||
[self openBrowserWindowWithURL:[[NSURL fileURLWithPath:filename] absoluteString]];
|
||||
}
|
||||
*/
|
||||
[self openNewWindowOrTabWithURL:[[NSURL fileURLWithPath:filename] absoluteString]];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (IBAction)biggerTextSize:(id)aSender
|
||||
|
@ -462,6 +541,7 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
|
||||
-(BOOL)isMainWindowABrowserWindow
|
||||
{
|
||||
// see also getFrontmostBrowserWindow
|
||||
return [[[mApplication mainWindow] windowController] isMemberOfClass:[BrowserWindowController class]];
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче