diff --git a/camino/src/application/MainController.mm b/camino/src/application/MainController.mm index 9ef406058620..0ac25e81b73c 100644 --- a/camino/src/application/MainController.mm +++ b/camino/src/application/MainController.mm @@ -994,7 +994,7 @@ Otherwise, we return the URL we originally got. Right now this supports .url and return mFilterView; } --(NSArray*)browserWindows +- (NSArray*)browserWindows { NSEnumerator* windowEnum = [[NSApp orderedWindows] objectEnumerator]; NSMutableArray* windowArray = [NSMutableArray array]; @@ -1006,7 +1006,8 @@ Otherwise, we return the URL we originally got. Right now this supports .url and // an empty chrome mask, or ones with a toolbar, status bar, and resize control // to be real top-level browser windows for purposes of saving size and // loading urls in. Others are popups and are transient. - if ([[curWindow windowController] isMemberOfClass:[BrowserWindowController class]] && + if ([curWindow isVisible] && + [[curWindow windowController] isMemberOfClass:[BrowserWindowController class]] && [[curWindow windowController] hasFullBrowserChrome]) { [windowArray addObject:curWindow]; @@ -1016,8 +1017,7 @@ Otherwise, we return the URL we originally got. Right now this supports .url and return windowArray; } - --(NSWindow*)getFrontmostBrowserWindow +- (NSWindow*)getFrontmostBrowserWindow { // for some reason, [NSApp mainWindow] doesn't always work, so we have to // do this manually @@ -1031,7 +1031,8 @@ Otherwise, we return the URL we originally got. Right now this supports .url and // an empty chrome mask, or ones with a toolbar, status bar, and resize control // to be real top-level browser windows for purposes of saving size and // loading urls in. Others are popups and are transient. - if ([[curWindow windowController] isMemberOfClass:[BrowserWindowController class]] && + if ([curWindow isVisible] && + [[curWindow windowController] isMemberOfClass:[BrowserWindowController class]] && [[curWindow windowController] hasFullBrowserChrome]) { foundWindow = curWindow; @@ -1681,8 +1682,11 @@ Otherwise, we return the URL we originally got. Right now this supports .url and // - (IBAction)emptyCache:(id)sender { - if (NSRunCriticalAlertPanel(NSLocalizedString(@"EmptyCacheTitle", nil), NSLocalizedString(@"EmptyCacheMessage", nil), - NSLocalizedString(@"EmptyButton", nil), NSLocalizedString(@"CancelButtonText", nil), nil) == NSAlertDefaultReturn) { + if (NSRunCriticalAlertPanel(NSLocalizedString(@"EmptyCacheTitle", nil), + NSLocalizedString(@"EmptyCacheMessage", nil), + NSLocalizedString(@"EmptyButton", nil), + NSLocalizedString(@"CancelButtonText", nil), nil) == NSAlertDefaultReturn) + { // remove cache nsCOMPtr cacheServ (do_GetService("@mozilla.org/network/cache-service;1")); if (cacheServ) @@ -1697,21 +1701,32 @@ Otherwise, we return the URL we originally got. Right now this supports .url and // - warn user about what is going to happen // - if its OK... // - close all open windows, delete cache, history, cookies, site permissions, -// downloads, saved names and passwords +// downloads, saved names and passwords, and clear Top 10 group in bookmarks // - (IBAction)resetBrowser:(id)sender { - if (NSRunCriticalAlertPanel(NSLocalizedString(@"Reset Camino Title", @"Are you sure you want to reset Camino?"), - NSLocalizedString(@"Reset Warning Message", - @"Resetting Camino will erase your browsing history, empty the cache, clear downloads, clear all cookies, clear all site permissions, and remove all remembered usernames and passwords. This action cannot be undone."), - NSLocalizedString(@"Reset Camino", @"Reset Camino"), - NSLocalizedString(@"CancelButtonText", @"Cancel"), - nil) == NSAlertDefaultReturn) { + if (NSRunCriticalAlertPanel(NSLocalizedString(@"Reset Camino Title", nil), + NSLocalizedString(@"Reset Warning Message", nil), + NSLocalizedString(@"Reset Camino", nil), + NSLocalizedString(@"CancelButtonText", nil), + nil) == NSAlertDefaultReturn) + { // close all windows - NSArray *windows = [NSApp orderedWindows]; - for (unsigned int i = 0; i < [windows count]; i++) { - [[windows objectAtIndex:i] performClose:self]; + { + NSArray* openWindows = [[NSApp orderedWindows] copy]; + NSEnumerator* windowEnum = [openWindows objectEnumerator]; + NSWindow* curWindow; + while ((curWindow = [windowEnum nextObject])) + { + // we don't want the "you are closing a window with multiple tabs" warning to show up. + if ([[curWindow windowController] isMemberOfClass:[BrowserWindowController class]]) + [(BrowserWindowController*)[curWindow windowController] setWindowClosesQuietly:YES]; + + if ([curWindow isVisible]) + [curWindow performClose:self]; + } + [openWindows release]; } // remove cache @@ -1739,9 +1754,14 @@ Otherwise, we return the URL we originally got. Right now this supports .url and // remove downloads [[ProgressDlgController sharedDownloadController] clearAllDownloads]; +#if 0 // disable this for now (see bug 3202080> // remove saved names and passwords [[KeychainService instance] removeAllUsernamesAndPasswords]; - +#endif + + // re-set all bookmarks visit counts to zero + [[BookmarkManager sharedBookmarkManager] clearAllVisits]; + // open a new window [self newWindow:self]; } @@ -1759,8 +1779,10 @@ static int SortByProtocolAndName(NSDictionary* item1, NSDictionary* item2, void return [[item1 objectForKey:@"protocol"] compare:[item2 objectForKey:@"protocol"] options:NSCaseInsensitiveSearch]; } +// // NetworkServicesClient implementation - +// XXX maybe just use the bookmarks smart folder for this menu? +// - (void)availableServicesChanged:(NSNotification *)note { // rebuild the submenu, leaving the first item diff --git a/camino/src/browser/BrowserWindowController.h b/camino/src/browser/BrowserWindowController.h index ba022ef68dec..a9710ac4ef75 100644 --- a/camino/src/browser/BrowserWindowController.h +++ b/camino/src/browser/BrowserWindowController.h @@ -160,6 +160,8 @@ typedef enum BOOL mShouldAutosave; BOOL mShouldLoadHomePage; + BOOL mWindowClosesQuietly; // if YES, don't warn on multi-tab window close + unsigned int mChromeMask; // Indicates which parts of the window to show (e.g., don't show toolbars) // C++ object that holds owning refs to XPCOM objects (and related data) @@ -326,7 +328,8 @@ typedef enum - (void) showProgressIndicator; - (void) hideProgressIndicator; -- (BOOL) isResponderGeckoView:(NSResponder*) responder; +- (BOOL)windowClosesQuietly; +- (void)setWindowClosesQuietly:(BOOL)inClosesQuietly; // called when the internal window focus has changed // this allows us to dispatch activate and deactivate events as necessary diff --git a/camino/src/browser/BrowserWindowController.mm b/camino/src/browser/BrowserWindowController.mm index 7c8a956ca4dd..55b8f9e81aee 100644 --- a/camino/src/browser/BrowserWindowController.mm +++ b/camino/src/browser/BrowserWindowController.mm @@ -89,7 +89,6 @@ #include "nsIClipboardCommands.h" #include "nsICommandManager.h" #include "nsICommandParams.h" -#include "nsIContentViewerEdit.h" #include "nsIWebBrowser.h" #include "nsIInterfaceRequestorUtils.h" #include "nsServiceManagerUtils.h" @@ -425,6 +424,7 @@ enum BWCOpenDest { - (void)setupToolbar; - (void)setGeckoActive:(BOOL)inActive; +- (BOOL)isResponderGeckoView:(NSResponder*) responder; - (NSString*)getContextMenuNodeDocumentURL; - (void)loadSourceOfURL:(NSString*)urlStr; - (void)transformFormatString:(NSMutableString*)inFormat domain:(NSString*)inDomain search:(NSString*)inSearch; @@ -481,12 +481,6 @@ enum BWCOpenDest { return self; } -- (BOOL)isResponderGeckoView:(NSResponder*) responder -{ - return ([responder isKindOfClass:[NSView class]] && - [(NSView*)responder isDescendantOf:[mBrowserView getBrowserView]]); -} - - (void)windowDidBecomeKey:(NSNotification *)notification { BOOL windowWithMultipleTabs = ([mTabBrowser numberOfTabViewItems] > 1); @@ -525,12 +519,18 @@ enum BWCOpenDest { } } +- (BOOL)isResponderGeckoView:(NSResponder*) responder +{ + return ([responder isKindOfClass:[NSView class]] && + [(NSView*)responder isDescendantOf:[mBrowserView getBrowserView]]); +} + - (void)windowDidChangeMain { // On 10.4, the unified title bar and toolbar is used, and the bookmark // toolbar's appearance is tweaked to better match the unified look. // Its active/inactive state needs to change along with the toolbar's. - BrowserWindow* browserWin = [self window]; + BrowserWindow* browserWin = (BrowserWindow*)[self window]; if ([browserWin hasUnifiedToolbarAppearance]) { BookmarkToolbar* bookmarkToolbar = [self bookmarkToolbar]; if (bookmarkToolbar) @@ -582,7 +582,8 @@ enum BWCOpenDest { - (BOOL)windowShouldClose:(id)sender { - if ([[PreferenceManager sharedInstance] getBooleanPref:"camino.warn_when_closing" withSuccess:NULL]) + if (!mWindowClosesQuietly && + [[PreferenceManager sharedInstance] getBooleanPref:"camino.warn_when_closing" withSuccess:NULL]) { unsigned int numberOfTabs = [mTabBrowser numberOfTabViewItems]; if (numberOfTabs > 1) @@ -851,7 +852,7 @@ enum BWCOpenDest { const int kWindowStaggerOffset = 22; NSWindow* lastBrowser = [[NSApp delegate] getFrontmostBrowserWindow]; - if ( lastBrowser != [self window] ) { + if ( lastBrowser && lastBrowser != [self window] ) { NSRect screenRect = [[lastBrowser screen] visibleFrame]; NSRect testBrowserFrame = [lastBrowser frame]; NSPoint previousOrigin = testBrowserFrame.origin; @@ -2791,7 +2792,7 @@ enum BWCOpenDest { BrowserWindowController* browser = [[BrowserWindowController alloc] initWithWindowNibName: @"BrowserWindow"]; if (aLoadInBG) { - BrowserWindow* browserWin = [browser window]; + BrowserWindow* browserWin = (BrowserWindow*)[browser window]; [browserWin setSuppressMakeKeyFront:YES]; // prevent gecko focus bringing the window to the front [browserWin orderWindow: NSWindowBelow relativeTo: [[self window] windowNumber]]; [browserWin setSuppressMakeKeyFront:NO]; @@ -3324,6 +3325,16 @@ enum BWCOpenDest { [mProgress removeFromSuperview]; } +- (BOOL)windowClosesQuietly +{ + return mWindowClosesQuietly; +} + +- (void)setWindowClosesQuietly:(BOOL)inClosesQuietly +{ + mWindowClosesQuietly = inClosesQuietly; +} + // // buildPopupBlockerMenu: // diff --git a/camino/src/embedding/CHBrowserListener.mm b/camino/src/embedding/CHBrowserListener.mm index ce8cbd3742a0..f4d353ceca1d 100644 --- a/camino/src/embedding/CHBrowserListener.mm +++ b/camino/src/embedding/CHBrowserListener.mm @@ -244,6 +244,7 @@ CHBrowserListener::GetChromeFlags(PRUint32 *aChromeFlags) *aChromeFlags = mChromeFlags; return NS_OK; } + NS_IMETHODIMP CHBrowserListener::SetChromeFlags(PRUint32 aChromeFlags) {