bug 257281 - add browser reset functionality
This commit is contained in:
Родитель
beb802c9a3
Коммит
9d21b202c2
Двоичные данные
camino/resources/localized/English.lproj/Localizable.strings
Двоичные данные
camino/resources/localized/English.lproj/Localizable.strings
Двоичный файл не отображается.
|
@ -45,6 +45,7 @@
|
|||
printPage = id;
|
||||
releaseNoteLink = id;
|
||||
reloadWithCharset = id;
|
||||
resetBrowser = id;
|
||||
savePage = id;
|
||||
searchCustomizeLink = id;
|
||||
sendURL = id;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<key>IBEditorPositions</key>
|
||||
<dict>
|
||||
<key>29</key>
|
||||
<string>431 579 433 44 0 0 1280 832 </string>
|
||||
<string>757 833 433 44 0 0 1920 1178 </string>
|
||||
<key>494</key>
|
||||
<string>507 508 116 61 0 0 1152 848 </string>
|
||||
</dict>
|
||||
|
@ -18,6 +18,6 @@
|
|||
<integer>29</integer>
|
||||
</array>
|
||||
<key>IBSystem Version</key>
|
||||
<string>7F44</string>
|
||||
<string>7M34</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
Двоичные данные
camino/resources/localized/English.lproj/MainMenu.nib/keyedobjects.nib
сгенерированный
Normal file
Двоичные данные
camino/resources/localized/English.lproj/MainMenu.nib/keyedobjects.nib
сгенерированный
Normal file
Двоичный файл не отображается.
|
@ -194,6 +194,9 @@ typedef enum EBookmarkOpenBehavior
|
|||
-(IBAction) setFileExtension:(id)aSender;
|
||||
|
||||
// utility routine to test if a url is "blank" (either empty or about:blank)
|
||||
+(BOOL) isBlankURL:(NSString*)inURL;
|
||||
+(BOOL)isBlankURL:(NSString*)inURL;
|
||||
|
||||
// security feature to reset browser
|
||||
-(IBAction)resetBrowser:(id)sender;
|
||||
|
||||
@end
|
||||
|
|
|
@ -77,6 +77,11 @@
|
|||
#include "nsIObserverService.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "nsIPermissionManager.h"
|
||||
#include "nsICookieManager.h"
|
||||
#include "nsIBrowserHistory.h"
|
||||
#include "nsICacheService.h"
|
||||
|
||||
#ifdef _BUILD_STATIC_BIN
|
||||
#include "nsStaticComponent.h"
|
||||
|
@ -192,7 +197,7 @@ const int kReuseWindowOnAE = 2;
|
|||
// (for example, from an GetURL Apple Event)
|
||||
NSWindow* browserWindow = [self getFrontmostBrowserWindow];
|
||||
if (!browserWindow)
|
||||
[self newWindow: self];
|
||||
[self newWindow:self];
|
||||
|
||||
// Initialize offline mode.
|
||||
mOffline = NO;
|
||||
|
@ -726,11 +731,10 @@ const int kReuseWindowOnAE = 2;
|
|||
{
|
||||
// for some reason, [NSApp mainWindow] doesn't always work, so we have to
|
||||
// do this manually
|
||||
NSArray *windowList = [NSApp orderedWindows];
|
||||
NSWindow *foundWindow = NULL;
|
||||
NSArray *windowList = [NSApp orderedWindows];
|
||||
NSWindow *foundWindow = nil;
|
||||
|
||||
for (unsigned int i = 0; i < [windowList count]; i ++)
|
||||
{
|
||||
for (unsigned int i = 0; i < [windowList count]; i ++) {
|
||||
NSWindow* thisWindow = [windowList objectAtIndex:i];
|
||||
|
||||
// not all browser windows are created equal. We only consider those with
|
||||
|
@ -1299,6 +1303,60 @@ const int kReuseWindowOnAE = 2;
|
|||
[self openNewWindowOrTabWithURL:urlString andReferrer:nil];
|
||||
}
|
||||
|
||||
/*
|
||||
* Here we need to:
|
||||
* - 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
|
||||
*/
|
||||
- (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 hisory, 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) {
|
||||
|
||||
// close all windows
|
||||
NSArray *windows = [NSApp orderedWindows];
|
||||
for (int i = 0; i < [windows count]; i++) {
|
||||
[[windows objectAtIndex:i] performClose:self];
|
||||
}
|
||||
|
||||
// remove cache
|
||||
nsCOMPtr<nsICacheService> cacheServ (do_GetService("@mozilla.org/network/cache-service;1"));
|
||||
if (cacheServ)
|
||||
cacheServ->EvictEntries(nsICache::STORE_ANYWHERE);
|
||||
|
||||
// remove cookies
|
||||
nsCOMPtr<nsICookieManager> cm(do_GetService(NS_COOKIEMANAGER_CONTRACTID));
|
||||
nsICookieManager* mCookieManager = cm.get();
|
||||
if (mCookieManager)
|
||||
mCookieManager->RemoveAll();
|
||||
|
||||
// remove site permissions
|
||||
nsCOMPtr<nsIPermissionManager> pm(do_GetService(NS_PERMISSIONMANAGER_CONTRACTID));
|
||||
nsIPermissionManager* mPermissionManager = pm.get();
|
||||
if (mPermissionManager)
|
||||
mPermissionManager->RemoveAll();
|
||||
|
||||
// remove history
|
||||
nsCOMPtr<nsIBrowserHistory> hist (do_GetService("@mozilla.org/browser/global-history;2"));
|
||||
if (hist)
|
||||
hist->RemoveAllPages();
|
||||
|
||||
// remove downloads
|
||||
[[ProgressDlgController sharedDownloadController] clearAllDownloads];
|
||||
|
||||
// remove saved names and passwords
|
||||
[[KeychainService instance] removeAllUsernamesAndPasswords];
|
||||
|
||||
// open a new window
|
||||
[self newWindow:self];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
|
|
|
@ -81,6 +81,7 @@ enum KeychainPromptResult { kSave, kDontRemember, kNeverRemember } ;
|
|||
- (BOOL) findUsernameAndPassword:(NSString*)realm port:(PRInt32)inPort;
|
||||
- (void) storeUsernameAndPassword:(NSString*)realm port:(PRInt32)inPort user:(NSString*)username password:(NSString*)pwd;
|
||||
- (void) removeUsernameAndPassword:(NSString*)realm port:(PRInt32)inPort item:(KCItemRef)item;
|
||||
- (void) removeAllUsernamesAndPasswords;
|
||||
- (void) updateUsernameAndPassword:(NSString*)realm port:(PRInt32)inPort user:(NSString*)username password:(NSString*)pwd item:(KCItemRef)item;
|
||||
|
||||
- (void) addListenerToView:(CHBrowserView*)view;
|
||||
|
|
|
@ -309,22 +309,39 @@ int KeychainPrefChangedCallback(const char* inPref, void* unused)
|
|||
// removes the username/password combo from the keychain. If |inItemRef| is a valid item, it
|
||||
// uses that. If it's a null ref, it will look it up in the keychain based on the realm.
|
||||
//
|
||||
- (void) removeUsernameAndPassword:(NSString*)realm port:(PRInt32)inPort item:(KCItemRef)inItemRef
|
||||
- (void)removeUsernameAndPassword:(NSString*)realm port:(PRInt32)inPort item:(KCItemRef)inItemRef
|
||||
{
|
||||
if ( !inItemRef ) {
|
||||
if ( inPort == -1 )
|
||||
if (!inItemRef) {
|
||||
if (inPort == -1)
|
||||
inPort = kAnyPort;
|
||||
const int kBufferLen = 255;
|
||||
char buffer[kBufferLen];
|
||||
UInt32 actualSize;
|
||||
kcfindinternetpassword([realm UTF8String], 0, 0, inPort, kKCProtocolTypeHTTP, kKCAuthTypeHTTPDigest,
|
||||
kcfindinternetpassword([realm UTF8String], NULL, NULL, inPort, kKCProtocolTypeHTTP, kKCAuthTypeHTTPDigest,
|
||||
kBufferLen, buffer, &actualSize, &inItemRef);
|
||||
}
|
||||
|
||||
if ( inItemRef )
|
||||
if (inItemRef)
|
||||
KCDeleteItem(inItemRef);
|
||||
}
|
||||
|
||||
- (void)removeAllUsernamesAndPasswords {
|
||||
const int kBufferLen = 255;
|
||||
char buffer[kBufferLen];
|
||||
UInt32 actualSize;
|
||||
KCItemRef itemRef = NULL;
|
||||
|
||||
while (TRUE) {
|
||||
kcfindinternetpassword(NULL, NULL, NULL, kAnyPort, kKCProtocolTypeHTTP, kKCAuthTypeHTTPDigest,
|
||||
kBufferLen, buffer, &actualSize, &itemRef);
|
||||
if (itemRef)
|
||||
KCDeleteItem(itemRef);
|
||||
else
|
||||
break;
|
||||
itemRef = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// addListenerToView:
|
||||
//
|
||||
|
|
|
@ -98,11 +98,7 @@
|
|||
-(IBAction)open:(id)sender;
|
||||
|
||||
-(int)numDownloadsInProgress;
|
||||
|
||||
-(void)setupDownloadTimer;
|
||||
-(void)killDownloadTimer;
|
||||
-(void)setDownloadProgress:(NSTimer *)aTimer;
|
||||
|
||||
-(void)clearAllDownloads;
|
||||
-(void)didStartDownload:(id <CHDownloadProgressDisplay>)progressDisplay;
|
||||
-(void)didEndDownload:(id <CHDownloadProgressDisplay>)progressDisplay;
|
||||
-(void)removeDownload:(id <CHDownloadProgressDisplay>)progressDisplay;
|
||||
|
|
|
@ -52,6 +52,8 @@ static NSString *ProgressWindowFrameSaveName = @"ProgressWindow";
|
|||
-(NSMutableArray*)getSelectedProgressViewControllers;
|
||||
-(void)deselectAllDLInstances:(NSArray*)instances;
|
||||
-(void)makeDLInstanceVisibleIfItsNotAlready:(ProgressViewController*)controller;
|
||||
-(void)killDownloadTimer;
|
||||
-(void)setupDownloadTimer;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -178,6 +180,19 @@ static id gSharedProgressController = nil;
|
|||
mSelectionPivotIndex = -1;
|
||||
}
|
||||
|
||||
// remove all downloads, cancelling if necessary
|
||||
// this is used for the browser reset function
|
||||
-(void)clearAllDownloads
|
||||
{
|
||||
for (int i = [mProgressViewControllers count] - 1; i >= 0; i--) {
|
||||
// the ProgressViewController method "cancel:" has a sanity check, so its ok to call on anything
|
||||
// make sure downloads are not active before removing them
|
||||
[[mProgressViewControllers objectAtIndex:i] cancel:self];
|
||||
[self removeDownload:[mProgressViewControllers objectAtIndex:i]]; // remove the download
|
||||
}
|
||||
mSelectionPivotIndex = -1;
|
||||
}
|
||||
|
||||
// calculate what buttons should be enabled/disabled because the user changed the selection state
|
||||
-(void)DLInstanceSelected:(NSNotification*)notification
|
||||
{
|
||||
|
@ -456,6 +471,12 @@ static id gSharedProgressController = nil;
|
|||
}
|
||||
}
|
||||
|
||||
// Called by our timer to refresh all the download stats
|
||||
- (void)setDownloadProgress:(NSTimer *)aTimer
|
||||
{
|
||||
[mProgressViewControllers makeObjectsPerformSelector:@selector(refreshDownloadInfo)];
|
||||
}
|
||||
|
||||
- (void)setupDownloadTimer
|
||||
{
|
||||
[self killDownloadTimer];
|
||||
|
@ -466,12 +487,6 @@ static id gSharedProgressController = nil;
|
|||
repeats:YES] retain];
|
||||
}
|
||||
|
||||
// Called by our timer to refresh all the download stats
|
||||
- (void)setDownloadProgress:(NSTimer *)aTimer
|
||||
{
|
||||
[mProgressViewControllers makeObjectsPerformSelector:@selector(refreshDownloadInfo)];
|
||||
}
|
||||
|
||||
-(NSApplicationTerminateReply)allowTerminate
|
||||
{
|
||||
if ([self numDownloadsInProgress] > 0) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче