Bug 407883 - Fix Downloads window opening and focusing prefs logic (and names). Switches to toolkit pref names and values (where available) and splits opening and focusing the Downloads window into two prefs. Patch by Chris Lawson <cl-bugs-new@chrislawson.net>, r=ilya, sr=smorgan
git-svn-id: svn://10.0.0.236/trunk@257353 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
1f8b654dde
commit
23b3d930b2
@ -94,8 +94,9 @@ private:
|
||||
|
||||
- (void)willSelect
|
||||
{
|
||||
[mAutoCloseDLManager setState:![self getBooleanPref:kGeckoPrefLeaveDownloadManagerOpen withSuccess:NULL]];
|
||||
[mEnableHelperApps setState:[self getBooleanPref:kGeckoPrefAutoOpenDownloads withSuccess:NULL]];
|
||||
// Our behaviour here should match what the browser does when the prefs don't exist.
|
||||
[mAutoCloseDLManager setState:([self getBooleanPref:kGeckoPrefCloseDownloadManagerWhenDone withSuccess:NULL]) ? NSOnState : NSOffState];
|
||||
[mEnableHelperApps setState:([self getBooleanPref:kGeckoPrefAutoOpenDownloads withSuccess:NULL]) ? NSOnState : NSOffState];
|
||||
[mDownloadRemovalPolicy selectItem:[[mDownloadRemovalPolicy menu] itemWithTag:[self getIntPref:kGeckoPrefDownloadCleanupPolicy
|
||||
withSuccess:NULL]]];
|
||||
|
||||
@ -108,12 +109,11 @@ private:
|
||||
|
||||
- (IBAction)checkboxClicked:(id)sender
|
||||
{
|
||||
if (sender == mAutoCloseDLManager) {
|
||||
[self setPref:kGeckoPrefLeaveDownloadManagerOpen toBoolean:![sender state]];
|
||||
}
|
||||
if (sender == mEnableHelperApps) {
|
||||
if (sender == mAutoCloseDLManager)
|
||||
[self setPref:kGeckoPrefCloseDownloadManagerWhenDone toBoolean:[sender state]];
|
||||
|
||||
if (sender == mEnableHelperApps)
|
||||
[self setPref:kGeckoPrefAutoOpenDownloads toBoolean:[sender state]];
|
||||
}
|
||||
}
|
||||
|
||||
// Sets the IC download pref to the given path. We write to Internet Config
|
||||
|
||||
@ -1,42 +1,74 @@
|
||||
{
|
||||
IBClasses = (
|
||||
{
|
||||
CLASS = FirstResponder;
|
||||
LANGUAGE = ObjC;
|
||||
SUPERCLASS = NSObject;
|
||||
},
|
||||
{
|
||||
CLASS = NSPreferencePane;
|
||||
LANGUAGE = ObjC;
|
||||
OUTLETS = {
|
||||
"_firstKeyView" = NSView;
|
||||
"_initialKeyView" = NSView;
|
||||
"_lastKeyView" = NSView;
|
||||
"_window" = NSWindow;
|
||||
};
|
||||
SUPERCLASS = NSObject;
|
||||
},
|
||||
{
|
||||
ACTIONS = {
|
||||
checkboxClicked = id;
|
||||
chooseDownloadFolder = id;
|
||||
chooseDownloadRemovalPolicy = id;
|
||||
};
|
||||
CLASS = OrgMozillaCaminoPreferenceDownloads;
|
||||
LANGUAGE = ObjC;
|
||||
OUTLETS = {
|
||||
mAutoCloseDLManager = NSButton;
|
||||
mDownloadFolder = NSPopUpButton;
|
||||
mDownloadRemovalPolicy = NSPopUpButton;
|
||||
mEnableHelperApps = NSButton;
|
||||
};
|
||||
SUPERCLASS = PreferencePaneBase;
|
||||
},
|
||||
{
|
||||
CLASS = PreferencePaneBase;
|
||||
LANGUAGE = ObjC;
|
||||
SUPERCLASS = NSPreferencePane;
|
||||
}
|
||||
);
|
||||
IBVersion = 1;
|
||||
}
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>IBClasses</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CLASS</key>
|
||||
<string>PreferencePaneBase</string>
|
||||
<key>LANGUAGE</key>
|
||||
<string>ObjC</string>
|
||||
<key>SUPERCLASS</key>
|
||||
<string>NSPreferencePane</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CLASS</key>
|
||||
<string>FirstResponder</string>
|
||||
<key>LANGUAGE</key>
|
||||
<string>ObjC</string>
|
||||
<key>SUPERCLASS</key>
|
||||
<string>NSObject</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CLASS</key>
|
||||
<string>NSPreferencePane</string>
|
||||
<key>LANGUAGE</key>
|
||||
<string>ObjC</string>
|
||||
<key>OUTLETS</key>
|
||||
<dict>
|
||||
<key>_firstKeyView</key>
|
||||
<string>NSView</string>
|
||||
<key>_initialKeyView</key>
|
||||
<string>NSView</string>
|
||||
<key>_lastKeyView</key>
|
||||
<string>NSView</string>
|
||||
<key>_window</key>
|
||||
<string>NSWindow</string>
|
||||
</dict>
|
||||
<key>SUPERCLASS</key>
|
||||
<string>NSObject</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>ACTIONS</key>
|
||||
<dict>
|
||||
<key>checkboxClicked</key>
|
||||
<string>id</string>
|
||||
<key>chooseDownloadFolder</key>
|
||||
<string>id</string>
|
||||
<key>chooseDownloadRemovalPolicy</key>
|
||||
<string>id</string>
|
||||
</dict>
|
||||
<key>CLASS</key>
|
||||
<string>OrgMozillaCaminoPreferenceDownloads</string>
|
||||
<key>LANGUAGE</key>
|
||||
<string>ObjC</string>
|
||||
<key>OUTLETS</key>
|
||||
<dict>
|
||||
<key>mAutoCloseDLManager</key>
|
||||
<string>NSButton</string>
|
||||
<key>mDownloadFolder</key>
|
||||
<string>NSPopUpButton</string>
|
||||
<key>mDownloadRemovalPolicy</key>
|
||||
<string>NSPopUpButton</string>
|
||||
<key>mEnableHelperApps</key>
|
||||
<string>NSButton</string>
|
||||
</dict>
|
||||
<key>SUPERCLASS</key>
|
||||
<string>PreferencePaneBase</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>IBVersion</key>
|
||||
<string>1</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
||||
@ -2,15 +2,17 @@
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>IBDocumentLocation</key>
|
||||
<string>34 11 522 320 0 0 1024 746 </string>
|
||||
<key>IBFramework Version</key>
|
||||
<string>489.0</string>
|
||||
<string>629</string>
|
||||
<key>IBOldestOS</key>
|
||||
<integer>5</integer>
|
||||
<key>IBOpenObjects</key>
|
||||
<array>
|
||||
<integer>5</integer>
|
||||
<integer>6</integer>
|
||||
</array>
|
||||
<key>IBSystem Version</key>
|
||||
<string>9D34</string>
|
||||
<string>9J61</string>
|
||||
<key>targetFramework</key>
|
||||
<string>IBCocoaFramework</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
||||
Binary file not shown.
@ -77,16 +77,19 @@ pref("browser.urlbar.autocomplete.enabled", true);
|
||||
// Don't do inline autocomplete in the location bar
|
||||
pref("browser.urlbar.autoFill", false);
|
||||
|
||||
// Default to auto download enabled but auto helper dispatch disabled
|
||||
pref("browser.download.autoDownload", true);
|
||||
pref("browser.download.autoDispatch", false);
|
||||
pref("browser.download.progressDnldDialog.keepAlive", true);
|
||||
// Download to the default location but don't process files after downloading.
|
||||
pref("browser.download.useDownloadDir", true);
|
||||
pref("browser.download.manager.openDownloadedFiles", false);
|
||||
pref("browser.download.manager.closeWhenDone", false);
|
||||
|
||||
// Download removing policy
|
||||
pref("browser.download.downloadRemoveAction", 0);
|
||||
pref("browser.download.manager.retention", 2);
|
||||
|
||||
// bring download window to the front when each download starts
|
||||
pref("browser.download.progressDnldDialog.bringToFront", true);
|
||||
pref("browser.download.manager.focusWhenStarting", true);
|
||||
|
||||
// open download window when each download starts
|
||||
pref("browser.download.manager.showWhenStarting", true);
|
||||
|
||||
// set typeahead find to search all text by default, but not invoke
|
||||
// unless you type '/'
|
||||
|
||||
@ -39,6 +39,8 @@
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "BrowserWindowController.h"
|
||||
|
||||
#include "nsNetError.h"
|
||||
|
||||
#import "NSString+Utils.h"
|
||||
@ -521,18 +523,54 @@ static id gSharedProgressController = nil;
|
||||
|
||||
-(void)didStartDownload:(ProgressViewController*)progressDisplay
|
||||
{
|
||||
if (![[self window] isVisible]) {
|
||||
[self showWindow:nil]; // make sure the window is visible
|
||||
}
|
||||
BOOL gotPref;
|
||||
NSWindow* downloadManagerWindow = [self window];
|
||||
BOOL shouldOpenManager = [[PreferenceManager sharedInstance] getBooleanPref:kGeckoPrefOpenDownloadManagerOnDownload
|
||||
withSuccess:&gotPref];
|
||||
if (shouldOpenManager || !gotPref) {
|
||||
// A common cause of user confusion is the window being visible but behind other
|
||||
// windows. They have no idea the download was successful, and click the link
|
||||
// two or three times before looking around to see what happened.
|
||||
// This ensures the download manager is open and visible, and has the side effect of
|
||||
// making it key and front (i.e., focusing it).
|
||||
// Some people don't want the manager to be stealing focus on every download,
|
||||
// so we support a (hidden) pref to allow the manager not to be focused each time.
|
||||
BOOL bringToFront = [[PreferenceManager sharedInstance] getBooleanPref:kGeckoPrefFocusDownloadManagerOnDownload
|
||||
withSuccess:&gotPref];
|
||||
if (bringToFront || !gotPref) {
|
||||
[self showWindow:nil];
|
||||
}
|
||||
else if (![downloadManagerWindow isVisible]) {
|
||||
// If the hidden pref is set to false and the manager isn't already open,
|
||||
// open it and send it to the back of all browser windows. This is sort of
|
||||
// arbitrary, but it beats |orderBack| (which includes visible windows
|
||||
// from other apps and can thus look weird).
|
||||
// NB: We include popups and view-source windows in this definition of
|
||||
// "browser window", though we generally don't elsewhere.
|
||||
|
||||
// a common cause of user confusion is the window being visible but behind other windows. They
|
||||
// have no idea the download was successful, and click the link two or three times before
|
||||
// looking around to see what happened. We always want the download window to come to the
|
||||
// front on a new download (unless they set a user_pref);
|
||||
BOOL gotPref = NO;
|
||||
BOOL bringToFront = [[PreferenceManager sharedInstance] getBooleanPref:kGeckoPrefFocusDownloadManagerOnDownload withSuccess:&gotPref];
|
||||
if (gotPref && bringToFront)
|
||||
[[self window] makeKeyAndOrderFront:self];
|
||||
// Store the current key window before we stomp it.
|
||||
NSWindow* storedKeyWindow = [NSApp keyWindow];
|
||||
|
||||
[self showWindow:nil];
|
||||
|
||||
NSEnumerator* windowEnum = [[NSApp orderedWindows] reverseObjectEnumerator];
|
||||
NSWindow* rearmostBrowserWindow = nil;
|
||||
|
||||
NSWindow* curWindow;
|
||||
while ((curWindow = [windowEnum nextObject])) {
|
||||
if ([[curWindow windowController] isMemberOfClass:[BrowserWindowController class]]) {
|
||||
rearmostBrowserWindow = curWindow;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (rearmostBrowserWindow) {
|
||||
[downloadManagerWindow orderWindow:NSWindowBelow relativeTo:[rearmostBrowserWindow windowNumber]];
|
||||
// Restore the stored key/main window.
|
||||
[storedKeyWindow makeKeyAndOrderFront:self];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[self rebuildViews];
|
||||
[self setupDownloadTimer];
|
||||
@ -540,7 +578,7 @@ static id gSharedProgressController = nil;
|
||||
// Downloads should be individually selected when initiated.
|
||||
[self updateSelectionOfDownload:progressDisplay withBehavior:DownloadSelectExclusively];
|
||||
|
||||
// make sure new download is visible
|
||||
// Make sure the new download is visible.
|
||||
[self scrollIntoView:progressDisplay];
|
||||
}
|
||||
|
||||
@ -569,13 +607,11 @@ static id gSharedProgressController = nil;
|
||||
{
|
||||
// Only check if there are zero downloads running and there is no sheet
|
||||
// (e.g. toolbar customization sheet) attached.
|
||||
if ([self numDownloadsInProgress] == 0 && ![[self window] attachedSheet])
|
||||
{
|
||||
if ([self numDownloadsInProgress] == 0 && ![[self window] attachedSheet]) {
|
||||
BOOL gotPref;
|
||||
BOOL keepDownloadsOpen = [[PreferenceManager sharedInstance] getBooleanPref:kGeckoPrefLeaveDownloadManagerOpen
|
||||
withSuccess:&gotPref];
|
||||
if (gotPref && !keepDownloadsOpen)
|
||||
{
|
||||
BOOL closeDownloadManager = [[PreferenceManager sharedInstance] getBooleanPref:kGeckoPrefCloseDownloadManagerWhenDone
|
||||
withSuccess:&gotPref];
|
||||
if (gotPref && closeDownloadManager) {
|
||||
// don't call -performClose: on the window, because we don't want Cocoa to look
|
||||
// for the option key and try to close all windows
|
||||
[self close];
|
||||
|
||||
@ -60,6 +60,7 @@
|
||||
#include "nsIObserver.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "GeckoUtils.h"
|
||||
#include "GeckoPrefConstants.h"
|
||||
|
||||
NSString* const InitEmbeddingNotificationName = @"InitEmebedding"; // this is actually broadcast from MainController
|
||||
NSString* const TermEmbeddingNotificationName = @"TermEmbedding";
|
||||
@ -276,15 +277,15 @@ CHBrowserService::CreateChromeWindow(nsIWebBrowserChrome *parent,
|
||||
NS_IMETHODIMP
|
||||
CHBrowserService::Show(nsIHelperAppLauncher* inLauncher, nsISupports* inContext, PRUint32 aReason)
|
||||
{
|
||||
PRBool autoDownload = PR_FALSE;
|
||||
|
||||
// See if pref enabled to allow automatic download
|
||||
PRBool downloadWithoutDialog = PR_FALSE;
|
||||
|
||||
// Check for pref to download to defined downloads directory
|
||||
nsCOMPtr<nsIPref> prefService (do_GetService(NS_PREF_CONTRACTID));
|
||||
if (prefService)
|
||||
prefService->GetBoolPref("browser.download.autoDownload", &autoDownload);
|
||||
|
||||
prefService->GetBoolPref(kGeckoPrefDownloadToDefaultLocation, &downloadWithoutDialog);
|
||||
|
||||
nsCOMPtr<nsIFile> downloadFile;
|
||||
if (autoDownload)
|
||||
if (downloadWithoutDialog)
|
||||
{
|
||||
NS_GetSpecialDirectory(NS_MAC_DEFAULT_DOWNLOAD_DIR, getter_AddRefs(downloadFile));
|
||||
|
||||
|
||||
@ -264,17 +264,25 @@ extern const char* const kGeckoPrefProxyBypassList; // string
|
||||
// Controls whether downloads should be auto-launched
|
||||
extern const char* const kGeckoPrefAutoOpenDownloads; // bool
|
||||
|
||||
// Controls when downloads are removed from the manager
|
||||
extern const char* const kGeckoPrefDownloadCleanupPolicy; // int
|
||||
// Possible values:
|
||||
extern const int kRemoveDownloadsManually;
|
||||
extern const int kRemoveDownloadsOnQuit;
|
||||
extern const int kRemoveDownloadsOnSuccess;
|
||||
extern const int kRemoveDownloadsOnQuit;
|
||||
extern const int kRemoveDownloadsManually;
|
||||
|
||||
// Controls whether the download manager is focused when a download is started
|
||||
extern const char* const kGeckoPrefFocusDownloadManagerOnDownload; // bool
|
||||
|
||||
// Controls whether the download manager opens when a download is started
|
||||
extern const char* const kGeckoPrefOpenDownloadManagerOnDownload; // bool
|
||||
|
||||
// Controls whether the download manager stays open after downloads complete
|
||||
extern const char* const kGeckoPrefLeaveDownloadManagerOpen; // bool
|
||||
extern const char* const kGeckoPrefCloseDownloadManagerWhenDone; // bool
|
||||
|
||||
// Controls whether downloads are saved to the Downloads directory
|
||||
// or prompted for a save location every time
|
||||
extern const char* const kGeckoPrefDownloadToDefaultLocation; // bool
|
||||
|
||||
#pragma mark Page Appearance
|
||||
|
||||
@ -330,4 +338,26 @@ extern const char* const kGeckoPrefSafeBrowsingPhishingCheckingEnabled; // bool
|
||||
extern const char* const kGeckoPrefSafeBrowsingMalwareCheckingEnabled; // bool
|
||||
extern const char* const kGeckoPrefSafeBrowsingDataProvider; // int
|
||||
|
||||
#pragma mark Obsolete Downloads Prefs
|
||||
// These prefs are all obsolete as of Camino 2.0.
|
||||
|
||||
// Formerly controlled when downloads were removed from the manager
|
||||
extern const char* const kOldGeckoPrefDownloadCleanupPolicy; // int
|
||||
// Possible values:
|
||||
extern const int kOldRemoveDownloadsManually;
|
||||
extern const int kOldRemoveDownloadsOnQuit;
|
||||
extern const int kOldRemoveDownloadsOnSuccess;
|
||||
|
||||
// Formerly controlled whether the manager would open on download (iff closed)
|
||||
extern const char* const kOldGeckoPrefFocusDownloadManagerOnDownload; // bool
|
||||
|
||||
// Formerly controlled whether manager stayed open after downloads completed
|
||||
extern const char* const kOldGeckoPrefLeaveDownloadManagerOpen; // bool
|
||||
|
||||
// Formerly controlled whether to use default downloads directory
|
||||
extern const char* const kOldGeckoPrefDownloadToDefaultLocation; // bool
|
||||
|
||||
// Formerly controlled whether to process downloads with helper apps
|
||||
extern const char* const kOldGeckoPrefAutoOpenDownloads; // bool
|
||||
|
||||
#pragma GCC visibility pop
|
||||
|
||||
@ -178,10 +178,12 @@ const char* const kGeckoPrefProxyBypassList = "network.proxy.no_proxies_on";
|
||||
|
||||
#pragma mark Downloads
|
||||
|
||||
const char* const kGeckoPrefAutoOpenDownloads = "browser.download.autoDispatch";
|
||||
const char* const kGeckoPrefDownloadCleanupPolicy = "browser.download.downloadRemoveAction";
|
||||
const char* const kGeckoPrefFocusDownloadManagerOnDownload = "browser.download.progressDnldDialog.bringToFront";
|
||||
const char* const kGeckoPrefLeaveDownloadManagerOpen = "browser.download.progressDnldDialog.keepAlive";
|
||||
const char* const kGeckoPrefAutoOpenDownloads = "browser.download.manager.openDownloadedFiles";
|
||||
const char* const kGeckoPrefDownloadCleanupPolicy = "browser.download.manager.retention";
|
||||
const char* const kGeckoPrefFocusDownloadManagerOnDownload = "browser.download.manager.focusWhenStarting";
|
||||
const char* const kGeckoPrefOpenDownloadManagerOnDownload = "browser.download.manager.showWhenStarting";
|
||||
const char* const kGeckoPrefCloseDownloadManagerWhenDone = "browser.download.manager.closeWhenDone";
|
||||
const char* const kGeckoPrefDownloadToDefaultLocation = "browser.download.useDownloadDir";
|
||||
|
||||
#pragma mark Page Appearance
|
||||
|
||||
@ -215,6 +217,14 @@ const char* const kGeckoPrefSafeBrowsingPhishingCheckingEnabled = "browser.safeb
|
||||
const char* const kGeckoPrefSafeBrowsingMalwareCheckingEnabled = "browser.safebrowsing.malware.enabled";
|
||||
const char* const kGeckoPrefSafeBrowsingDataProvider = "browser.safebrowsing.dataProvider";
|
||||
|
||||
#pragma mark Obsolete Downloads Prefs
|
||||
|
||||
const char* const kOldGeckoPrefAutoOpenDownloads = "browser.download.autoDispatch";
|
||||
const char* const kOldGeckoPrefDownloadToDefaultLocation = "browser.download.autoDownload";
|
||||
const char* const kOldGeckoPrefDownloadCleanupPolicy = "browser.download.downloadRemoveAction";
|
||||
const char* const kOldGeckoPrefFocusDownloadManagerOnDownload = "browser.download.progressDnldDialog.bringToFront";
|
||||
const char* const kOldGeckoPrefLeaveDownloadManagerOpen = "browser.download.progressDnldDialog.keepAlive";
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Values
|
||||
|
||||
@ -271,6 +281,13 @@ const int kCookieLifetimeAsk = 1;
|
||||
const int kCookieLifetimeSession = 2;
|
||||
|
||||
// kGeckoPrefDownloadCleanupPolicy values
|
||||
const int kRemoveDownloadsManually = 0;
|
||||
// NB: these are the opposite of what they used to be!
|
||||
const int kRemoveDownloadsOnSuccess = 0;
|
||||
const int kRemoveDownloadsOnQuit = 1;
|
||||
const int kRemoveDownloadsOnSuccess = 2;
|
||||
const int kRemoveDownloadsManually = 2;
|
||||
|
||||
// kOldGeckoPrefDownloadCleanupPolicy values
|
||||
// NB: these are the opposite of the new ones!
|
||||
const int kOldRemoveDownloadsManually = 0;
|
||||
const int kOldRemoveDownloadsOnQuit = 1;
|
||||
const int kOldRemoveDownloadsOnSuccess = 2;
|
||||
|
||||
@ -85,7 +85,7 @@ static NSString* const kFlashBlockChangedNotificationName = @"FlashBlockChanged"
|
||||
// This is an arbitrary version stamp that gets written to the prefs file.
|
||||
// It can be used to detect when a new version of Camino is run that needs
|
||||
// some prefs to be upgraded.
|
||||
static const PRInt32 kCurrentPrefsVersion = 1;
|
||||
static const PRInt32 kCurrentPrefsVersion = 2;
|
||||
|
||||
// CheckCompatibility and WriteVersion are based on the versions in
|
||||
// toolkit/xre/nsAppRunner.cpp. This is done to provide forward
|
||||
@ -195,6 +195,7 @@ WriteVersion(nsIFile* aProfileDir, const nsACString& aVersion,
|
||||
- (void)registerNotificationListener;
|
||||
- (void)initUpdatePrefs;
|
||||
- (void)cleanUpObsoletePrefs;
|
||||
- (void)migrateOldDownloadPrefs;
|
||||
|
||||
- (void)termEmbedding:(NSNotification*)aNotification;
|
||||
- (void)xpcomTerminate:(NSNotification*)aNotification;
|
||||
@ -781,6 +782,11 @@ static BOOL gMadePrefManager;
|
||||
if (mLastRunPrefsVersion < 1)
|
||||
mPrefs->SetCharPref("intl.charset.detector", "");
|
||||
|
||||
// Starting with pref version 2, we migrated to the toolkit versions of
|
||||
// all our download manager preferences.
|
||||
if (mLastRunPrefsVersion < 2)
|
||||
[self migrateOldDownloadPrefs];
|
||||
|
||||
mPrefs->SetIntPref("camino.prefs_version", kCurrentPrefsVersion);
|
||||
|
||||
// Fix up the cookie prefs. If 'p3p' or 'accept foreign cookies' are on,
|
||||
@ -1452,4 +1458,44 @@ typedef enum EProxyConfig {
|
||||
return jsEnabled && pluginsEnabled;
|
||||
}
|
||||
|
||||
//
|
||||
// migrateOldDownloadPrefs
|
||||
//
|
||||
// Migrates from our old Gecko download preferences, which were a mish-mash of all sorts
|
||||
// of different things, to the standard toolkit prefs (where they exist).
|
||||
//
|
||||
-(void)migrateOldDownloadPrefs
|
||||
{
|
||||
BOOL gotPref;
|
||||
|
||||
unsigned int oldCleanupPolicy = [self getIntPref:kOldGeckoPrefDownloadCleanupPolicy withSuccess:&gotPref];
|
||||
// The new policy values (0 = on success; 1 = on quit; 2 = manually) are reversed from the old
|
||||
// (manually/on quit/on success), so subtract from 2 to translate.
|
||||
[self setPref:kGeckoPrefDownloadCleanupPolicy toInt:(gotPref ? (2 - oldCleanupPolicy) : kRemoveDownloadsManually)];
|
||||
|
||||
BOOL oldFocusPref = [self getBooleanPref:kOldGeckoPrefFocusDownloadManagerOnDownload withSuccess:&gotPref];
|
||||
// If we failed to get a pref, default to focus-on-download.
|
||||
[self setPref:kGeckoPrefFocusDownloadManagerOnDownload toBoolean:(gotPref ? oldFocusPref : YES)];
|
||||
|
||||
BOOL oldStayOpenPref = [self getBooleanPref:kOldGeckoPrefLeaveDownloadManagerOpen withSuccess:&gotPref];
|
||||
// The new pref is "close when done" rather than "stay open", so true is now false.
|
||||
// If we failed to get a pref, default to keeping the manager open.
|
||||
[self setPref:kGeckoPrefCloseDownloadManagerWhenDone toBoolean:(gotPref ? !oldStayOpenPref : NO)];
|
||||
|
||||
BOOL oldDownloadDirectoryPref = [self getBooleanPref:kOldGeckoPrefDownloadToDefaultLocation withSuccess:&gotPref];
|
||||
// If we somehow failed to get a pref here, default to dialogless downloads.
|
||||
[self setPref:kGeckoPrefDownloadToDefaultLocation toBoolean:(gotPref ? oldDownloadDirectoryPref : YES)];
|
||||
|
||||
BOOL oldProcessDownloadsPref = [self getBooleanPref:kOldGeckoPrefAutoOpenDownloads withSuccess:&gotPref];
|
||||
// If we somehow failed to get a pref, default to no processing.
|
||||
[self setPref:kGeckoPrefAutoOpenDownloads toBoolean:(gotPref ? oldProcessDownloadsPref : NO)];
|
||||
|
||||
// Now remove all the old prefs so we don't leave cruft in the profile.
|
||||
[self clearPref:kOldGeckoPrefDownloadCleanupPolicy];
|
||||
[self clearPref:kOldGeckoPrefFocusDownloadManagerOnDownload];
|
||||
[self clearPref:kOldGeckoPrefLeaveDownloadManagerOpen];
|
||||
[self clearPref:kOldGeckoPrefDownloadToDefaultLocation];
|
||||
[self clearPref:kOldGeckoPrefAutoOpenDownloads];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user