Bug 319509: When doing Reset Camino, don't prompt about closing windows with multiple tabs open.
Bug 320208: Reset Camino should not clear out keychain passwords, since we don't know whether we created them.
Bug 319491: Reset Camino should clear the visit counts on the bookmarks, thus clearing the top 10 list.

Also changed -getFrontmostBrowserWindow and -browserWindows to not return windows that are not visible (e.g. those that are being created or destroyed), which fixing some odd cascading issues, and should prevent us from ever showing sheets on hidden windows.
This commit is contained in:
smfr%smfr.org 2005-12-19 05:23:49 +00:00
Родитель 0e3637a568
Коммит ad03fd2d7d
4 изменённых файлов: 68 добавлений и 31 удалений

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

@ -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<nsICacheService> 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

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

@ -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

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

@ -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:
//

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

@ -244,6 +244,7 @@ CHBrowserListener::GetChromeFlags(PRUint32 *aChromeFlags)
*aChromeFlags = mChromeFlags;
return NS_OK;
}
NS_IMETHODIMP
CHBrowserListener::SetChromeFlags(PRUint32 aChromeFlags)
{