Converting users of nsIPrefBranch to use the PreferenceManager (no bug).

This commit is contained in:
smfr%smfr.org 2005-04-04 01:52:35 +00:00
Родитель 559d42561b
Коммит 4a686700e0
4 изменённых файлов: 29 добавлений и 65 удалений

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

@ -73,7 +73,6 @@
#include "nsIDOMLocation.h"
#include "nsIDOMElement.h"
#include "nsIDOMEvent.h"
#include "nsIPrefBranch.h"
#include "nsIContextMenuListener.h"
#include "nsIDOMWindow.h"
#include "CHBrowserService.h"
@ -90,7 +89,6 @@
#include "nsIContentViewerEdit.h"
#include "nsIWebBrowser.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsIPrefBranch.h"
#include "nsServiceManagerUtils.h"
#include "nsIURI.h"
#include "nsIURIFixup.h"
@ -1584,9 +1582,7 @@ enum BWCOpenDest {
- (void)loadSourceOfURL:(NSString*)urlStr
{
// first attempt to get the source that's already loaded
PRBool loadInBackground;
nsCOMPtr<nsIPrefBranch> pref(do_GetService("@mozilla.org/preferences-service;1"));
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
BOOL loadInBackground = [[PreferenceManager sharedInstance] getBooleanPref:"browser.tabs.loadInBackground" withSuccess:NULL];
nsCOMPtr<nsISupports> desc = [[mBrowserView getBrowserView] getPageDescriptor];
if (desc) {
@ -2272,9 +2268,8 @@ enum BWCOpenDest {
BOOL loadHomepage = NO;
if (contents == eNewTabHomepage)
{
nsCOMPtr<nsIPrefBranch> pref(do_GetService("@mozilla.org/preferences-service;1"));
PRInt32 newTabPage = 0; // 0=about:blank, 1=home page, 2=last page visited
pref->GetIntPref("browser.tabs.startPage", &newTabPage);
// 0 = about:blank, 1 = home page, 2 = last page visited
int newTabPage = [[PreferenceManager sharedInstance] getIntPref:"browser.tabs.startPage" withSuccess:NULL];
loadHomepage = (newTabPage == 1);
}
@ -2392,11 +2387,7 @@ enum BWCOpenDest {
if (tabViewItem)
{
NSString* url = [[tabViewItem view] getCurrentURLSpec];
PRBool backgroundLoad = PR_FALSE;
nsCOMPtr<nsIPrefBranch> pref(do_GetService("@mozilla.org/preferences-service;1"));
if (pref)
pref->GetBoolPref("browser.tabs.loadInBackground", &backgroundLoad);
BOOL backgroundLoad = [[PreferenceManager sharedInstance] getBooleanPref:"browser.tabs.loadInBackground" withSuccess:NULL];
[self openNewWindowWithURL:url referrer:nil loadInBackground:backgroundLoad allowPopups:NO];
@ -2846,12 +2837,7 @@ enum BWCOpenDest {
if ([hrefStr length] == 0)
return;
nsCOMPtr<nsIPrefBranch> pref(do_GetService("@mozilla.org/preferences-service;1"));
if (!pref)
return; // Something bad happened if we can't get prefs.
PRBool loadInBackground;
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
BOOL loadInBackground = [[PreferenceManager sharedInstance] getBooleanPref:"browser.tabs.loadInBackground" withSuccess:NULL];
NSString* referrer = [[mBrowserView getBrowserView] getFocusedURLString];
@ -3253,20 +3239,15 @@ enum BWCOpenDest {
//
- (BOOL) handleCommandReturn
{
BOOL handled = NO;
// determine whether to load in background
PRBool loadInBG;
nsCOMPtr<nsIPrefBranch> pref(do_GetService("@mozilla.org/preferences-service;1"));
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBG);
BOOL loadInBG = [[PreferenceManager sharedInstance] getBooleanPref:"browser.tabs.loadInBackground" withSuccess:NULL];
// determine whether to load in tab or window
PRBool loadInTab;
pref->GetBoolPref("browser.tabs.opentabfor.middleclick",&loadInTab);
BOOL loadInTab = [[PreferenceManager sharedInstance] getBooleanPref:"browser.tabs.opentabfor.middleclick" withSuccess:NULL];
BWCOpenDest destination = loadInTab ? kDestinationNewTab : kDestinationNewWindow;
// see if command-return came in the url bar
BOOL handled = NO;
if ([mURLBar fieldEditor] && [[self window] firstResponder] == [mURLBar fieldEditor]) {
handled = YES;
[self goToLocationFromToolbarURLField:mURLBar inView:destination inBackground:loadInBG];

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

@ -49,6 +49,7 @@
#import "PageProxyIcon.h"
#import "KeychainService.h"
#import "AutoCompleteTextField.h"
#include "CHBrowserService.h"
#include "nsCOMPtr.h"
#include "nsIServiceManager.h"
@ -65,15 +66,8 @@
#include "nsIChromeEventHandler.h"
#include "nsPIDOMWindow.h"
#include "nsIDOMEventReceiver.h"
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include "CHBrowserService.h"
#include "nsIWebProgressListener.h"
#include <QuickDraw.h>
static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
static NSString* const kOfflineNotificationName = @"offlineModeChanged";
@interface BrowserWrapper(Private)
@ -599,7 +593,7 @@ static NSString* const kOfflineNotificationName = @"offlineModeChanged";
- (void)updateOfflineStatus
{
nsCOMPtr<nsIIOService> ioService(do_GetService(ioServiceContractID));
nsCOMPtr<nsIIOService> ioService(do_GetService("@mozilla.org/network/io-service;1"));
if (!ioService)
return;
PRBool offline = PR_FALSE;
@ -758,12 +752,7 @@ static NSString* const kOfflineNotificationName = @"offlineModeChanged";
- (CHBrowserView*)createBrowserWindow:(unsigned int)aMask
{
nsCOMPtr<nsIPrefBranch> pref(do_GetService("@mozilla.org/preferences-service;1"));
if (!pref)
return NS_OK; // Something bad happened if we can't get prefs.
PRBool showBlocker;
pref->GetBoolPref("browser.popups.showPopupBlocker", &showBlocker);
BOOL showBlocker = [[PreferenceManager sharedInstance] getBooleanPref:"browser.popups.showPopupBlocker" withSuccess:NULL];
if (showBlocker) {
nsCOMPtr<nsIDOMWindow> domWindow = getter_AddRefs([mBrowserView getContentWindow]);
@ -776,14 +765,13 @@ static NSString* const kOfflineNotificationName = @"offlineModeChanged";
text: [NSString stringWithFormat: NSLocalizedString(@"PopupBlockMsg", @""), NSLocalizedStringFromTable(@"CFBundleName", @"InfoPlist", nil)]];
// This is a one-time dialog.
pref->SetBoolPref("browser.popups.showPopupBlocker", PR_FALSE);
[[PreferenceManager sharedInstance] setPref:"browser.popups.showPopupBlocker" toBoolean:NO];
if (confirm)
pref->SetBoolPref("dom.disable_open_during_load", PR_TRUE);
[[PreferenceManager sharedInstance] setPref:"dom.disable_open_during_load" toBoolean:YES];
[[PreferenceManager sharedInstance] savePrefsFile];
nsCOMPtr<nsIPrefService> prefService(do_QueryInterface(pref));
prefService->SavePrefFile(nsnull);
if (confirm)
return nil;
}

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

@ -36,23 +36,26 @@
*
* ***** END LICENSE BLOCK ***** */
#import "NSString+Utils.h"
#include "nsCOMPtr.h"
#include "ContentClickListener.h"
#include "nsIDOMElement.h"
#include "nsEmbedAPI.h"
#include "nsString.h"
#include "nsUnicharUtils.h"
#include "nsIPrefBranch.h"
#include "nsIDOMElement.h"
#include "nsIDOMMouseEvent.h"
#include "nsEmbedAPI.h"
#include "nsIDOMEventTarget.h"
// Common helper routines (also used by the context menu code)
#include "GeckoUtils.h"
#import "NSString+Utils.h"
#import "PreferenceManager.h"
#import "CHBrowserView.h"
#import "ContentClickListener.h"
NS_IMPL_ISUPPORTS2(ContentClickListener, nsIDOMMouseListener, nsIDOMEventListener)
ContentClickListener::ContentClickListener(id aBrowserController)
@ -82,10 +85,6 @@ ContentClickListener::MouseClick(nsIDOMEvent* aEvent)
// really uses these anyway? :)
if (!linkContent || href.IsEmpty())
return NS_OK;
nsCOMPtr<nsIPrefBranch> pref(do_GetService("@mozilla.org/preferences-service;1"));
if (!pref)
return NS_OK; // Something bad happened if we can't get prefs.
PRUint16 button;
nsCOMPtr<nsIDOMMouseEvent> mouseEvent(do_QueryInterface(aEvent));
@ -100,10 +99,9 @@ ContentClickListener::MouseClick(nsIDOMEvent* aEvent)
if ((metaKey && button == 0) || button == 1) {
// The command key is down or we got a middle click. Open the link in a new window or tab.
PRBool useTab = FALSE;
pref->GetBoolPref("browser.tabs.opentabfor.middleclick", &useTab);
PRBool loadInBackground = FALSE;
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
BOOL useTab = [[PreferenceManager sharedInstance] getBooleanPref:"browser.tabs.opentabfor.middleclick" withSuccess:NULL];
BOOL loadInBackground = [[PreferenceManager sharedInstance] getBooleanPref:"browser.tabs.loadInBackground" withSuccess:NULL];
NSString* referrer = [[[mBrowserController getBrowserWrapper] getBrowserView] getFocusedURLString];
if (shiftKey)

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

@ -1093,15 +1093,12 @@ nsresult
FindUsernamePasswordFields(nsIDOMHTMLFormElement* inFormElement, nsIDOMHTMLInputElement** outUsername,
nsIDOMHTMLInputElement** outPassword, PRBool inStopWhenFound)
{
PRBool autoCompleteOverride = PR_FALSE;
nsCOMPtr<nsIPrefBranch> pref(do_GetService("@mozilla.org/preferences-service;1"));
if (pref)
pref->GetBoolPref("wallet.crypto.autocompleteoverride", &autoCompleteOverride);
if ( !outUsername || !outPassword )
return NS_ERROR_FAILURE;
*outUsername = *outPassword = nsnull;
PRBool autoCompleteOverride = [[PreferenceManager sharedInstance] getBooleanPref:"wallet.crypto.autocompleteoverride" withSuccess:NULL];
// pages can specify that they don't want autofill by setting a
// "autocomplete=off" attribute on the form.
nsAutoString autocomplete;