зеркало из https://github.com/mozilla/pjs.git
Bug 232201 part 2 - update consumers to use inherited nsIPrefBranchInternal interface. This should be happy for codesize. r=alecf sr=darin
This commit is contained in:
Родитель
36e6edb041
Коммит
34cd8e8bdf
|
@ -47,7 +47,6 @@
|
|||
#include "nsIWidget.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIPrefBranchInternal.h"
|
||||
#include "nsDOMEvent.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsIEditorDocShell.h"
|
||||
|
@ -214,9 +213,7 @@ nsEventStateManager::Init()
|
|||
&nsEventStateManager::gGeneralAccesskeyModifier);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPrefBranchInternal> prefBranchInt(do_QueryInterface(mPrefBranch));
|
||||
if (prefBranchInt)
|
||||
prefBranchInt->AddObserver("accessibility.browsewithcaret", this, PR_TRUE);
|
||||
mPrefBranch->AddObserver("accessibility.browsewithcaret", this, PR_TRUE);
|
||||
}
|
||||
|
||||
if (nsEventStateManager::sTextfieldSelectModel == eTextfieldSelect_unset) {
|
||||
|
@ -272,9 +269,7 @@ nsEventStateManager::~nsEventStateManager()
|
|||
nsresult
|
||||
nsEventStateManager::Shutdown()
|
||||
{
|
||||
nsCOMPtr<nsIPrefBranchInternal> prefBranchInt(do_QueryInterface(mPrefBranch));
|
||||
if (prefBranchInt)
|
||||
prefBranchInt->RemoveObserver("accessibility.browsewithcaret", this);
|
||||
mPrefBranch->RemoveObserver("accessibility.browsewithcaret", this);
|
||||
|
||||
mPrefBranch = nsnull;
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
#include "nsIEventStateManager.h"
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefBranchInternal.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsHashtable.h"
|
||||
|
@ -306,7 +306,7 @@ protected:
|
|||
static PRInt32 gGeneralAccesskeyModifier;
|
||||
|
||||
// For preferences handling
|
||||
nsCOMPtr<nsIPrefBranch> mPrefBranch;
|
||||
nsCOMPtr<nsIPrefBranchInternal> mPrefBranch;
|
||||
PRPackedBool m_haveShutdown;
|
||||
|
||||
// To inform people that dispatched events that frames have been cleared and
|
||||
|
|
|
@ -99,7 +99,6 @@
|
|||
#include "nsIMarkupDocumentViewer.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefBranchInternal.h"
|
||||
#include "nsIPrefLocalizedString.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIPrivateDOMEvent.h"
|
||||
|
|
|
@ -77,7 +77,7 @@ protected:
|
|||
void Sync(nsIPrefBranch *aPrefBranch);
|
||||
|
||||
PRUint32 mHostingFlags;
|
||||
nsCOMPtr<nsIPrefService> mPrefService;
|
||||
nsCOMPtr<nsIPrefBranchInternal> mPrefBranch;
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
@ -99,8 +99,8 @@ PrefObserver::PrefObserver() :
|
|||
mHostingFlags(kDefaultHostingFlags)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
mPrefService = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
|
||||
NS_ASSERTION(mPrefService, "where is the pref service?");
|
||||
mPrefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
|
||||
NS_ASSERTION(mPrefBranch, "where is the pref service?");
|
||||
}
|
||||
|
||||
PrefObserver::~PrefObserver()
|
||||
|
@ -164,19 +164,14 @@ void PrefObserver::Sync(nsIPrefBranch *aPrefBranch)
|
|||
nsresult
|
||||
PrefObserver::Subscribe()
|
||||
{
|
||||
NS_ENSURE_TRUE(mPrefService, NS_ERROR_FAILURE);
|
||||
NS_ENSURE_TRUE(mPrefBranch, NS_ERROR_FAILURE);
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch = do_QueryInterface(mPrefService, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIPrefBranchInternal> prefInternal = do_QueryInterface(prefBranch, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
mPrefBranch->AddObserver(kProxyPref, this, PR_TRUE);
|
||||
mPrefBranch->AddObserver(kUserAgentPref, this, PR_TRUE);
|
||||
mPrefBranch->AddObserver(kActiveXHostingFlags, this, PR_TRUE);
|
||||
|
||||
prefInternal->AddObserver(kProxyPref, this, PR_TRUE);
|
||||
prefInternal->AddObserver(kUserAgentPref, this, PR_TRUE);
|
||||
prefInternal->AddObserver(kActiveXHostingFlags, this, PR_TRUE);
|
||||
|
||||
Sync(prefBranch);
|
||||
Sync(mPrefBranch);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
@ -184,17 +179,12 @@ PrefObserver::Subscribe()
|
|||
nsresult
|
||||
PrefObserver::Unsubscribe()
|
||||
{
|
||||
NS_ENSURE_TRUE(mPrefService, NS_ERROR_FAILURE);
|
||||
NS_ENSURE_TRUE(mPrefBranch, NS_ERROR_FAILURE);
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch = do_QueryInterface(mPrefService, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIPrefBranchInternal> prefInternal = do_QueryInterface(prefBranch, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
prefInternal->RemoveObserver(kProxyPref, this);
|
||||
prefInternal->RemoveObserver(kUserAgentPref, this);
|
||||
prefInternal->RemoveObserver(kActiveXHostingFlags, this);
|
||||
mPrefBranch->RemoveObserver(kProxyPref, this);
|
||||
mPrefBranch->RemoveObserver(kUserAgentPref, this);
|
||||
mPrefBranch->RemoveObserver(kActiveXHostingFlags, this);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -137,19 +137,16 @@ nsCookiePermission::Init()
|
|||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// failure to access the pref service is non-fatal...
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch =
|
||||
nsCOMPtr<nsIPrefBranchInternal> prefBranch =
|
||||
do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||
if (prefBranch) {
|
||||
nsCOMPtr<nsIPrefBranchInternal> prefInt = do_QueryInterface(prefBranch);
|
||||
if (prefInt) {
|
||||
prefInt->AddObserver(kCookiesAskPermission, this, PR_FALSE);
|
||||
prefInt->AddObserver(kCookiesLifetimeEnabled, this, PR_FALSE);
|
||||
prefBranch->AddObserver(kCookiesAskPermission, this, PR_FALSE);
|
||||
prefBranch->AddObserver(kCookiesLifetimeEnabled, this, PR_FALSE);
|
||||
#ifndef MOZ_PHOENIX
|
||||
prefInt->AddObserver(kCookiesLifetimeCurrentSession, this, PR_FALSE);
|
||||
prefInt->AddObserver(kCookiesLifetimeDays, this, PR_FALSE);
|
||||
prefInt->AddObserver(kCookiesDisabledForMailNews, this, PR_FALSE);
|
||||
prefBranch->AddObserver(kCookiesLifetimeCurrentSession, this, PR_FALSE);
|
||||
prefBranch->AddObserver(kCookiesLifetimeDays, this, PR_FALSE);
|
||||
prefBranch->AddObserver(kCookiesDisabledForMailNews, this, PR_FALSE);
|
||||
#endif
|
||||
}
|
||||
PrefChanged(prefBranch, nsnull);
|
||||
}
|
||||
|
||||
|
|
|
@ -116,19 +116,17 @@ nsresult nsImgManager::Init()
|
|||
// other things, like mailnews blocking
|
||||
mPermissionManager = do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
|
||||
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||
nsCOMPtr<nsIPrefBranchInternal> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||
if (prefBranch) {
|
||||
nsCOMPtr<nsIPrefBranchInternal> prefInternal = do_QueryInterface(prefBranch);
|
||||
if (prefInternal) {
|
||||
prefInternal->AddObserver(kImageBehaviorPrefName, this, PR_TRUE);
|
||||
prefBranch->AddObserver(kImageBehaviorPrefName, this, PR_TRUE);
|
||||
|
||||
// We don't do anything with it yet, but let it be. (bug 110112, 146513)
|
||||
prefInternal->AddObserver(kImageWarningPrefName, this, PR_TRUE);
|
||||
// We don't do anything with it yet, but let it be. (bug 110112, 146513)
|
||||
prefBranch->AddObserver(kImageWarningPrefName, this, PR_TRUE);
|
||||
|
||||
// What is this pref, and how do you set it?
|
||||
prefBranch->AddObserver(kImageBlockerPrefName, this, PR_TRUE);
|
||||
prefBranch->AddObserver(kImageBlockImageInMailNewsPrefName, this, PR_TRUE);
|
||||
|
||||
// What is this pref, and how do you set it?
|
||||
prefInternal->AddObserver(kImageBlockerPrefName, this, PR_TRUE);
|
||||
prefInternal->AddObserver(kImageBlockImageInMailNewsPrefName, this, PR_TRUE);
|
||||
}
|
||||
PrefChanged(prefBranch, nsnull);
|
||||
}
|
||||
|
||||
|
|
|
@ -88,10 +88,7 @@ nsPopupWindowManager::Init()
|
|||
}
|
||||
mPolicy = permission ? (PRUint32) DENY_POPUP : (PRUint32) ALLOW_POPUP;
|
||||
|
||||
nsCOMPtr<nsIPrefBranchInternal> prefInternal = do_QueryInterface(mPrefBranch, &rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
prefInternal->AddObserver(kPopupDisablePref, this, PR_TRUE);
|
||||
}
|
||||
mPrefBranch->AddObserver(kPopupDisablePref, this, PR_TRUE);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
#include "nsIObserverService.h"
|
||||
#include "nsIPermissionManager.h"
|
||||
#include "nsIPopupWindowManager.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefBranchInternal.h"
|
||||
#include "nsWeakReference.h"
|
||||
|
||||
class nsIURI;
|
||||
|
@ -65,7 +65,7 @@ public:
|
|||
private:
|
||||
PRUint32 mPolicy;
|
||||
nsCOMPtr<nsIPermissionManager> mPermissionManager;
|
||||
nsCOMPtr<nsIPrefBranch> mPrefBranch;
|
||||
nsCOMPtr<nsIPrefBranchInternal> mPrefBranch;
|
||||
};
|
||||
|
||||
// {4275d3f4-752a-427a-b432-14d5dda1c20b}
|
||||
|
|
|
@ -58,12 +58,9 @@ NS_IMPL_ISUPPORTS2(nsP3PService, nsICookieConsent, nsIObserver)
|
|||
nsP3PService::nsP3PService()
|
||||
{
|
||||
// we can live without a prefservice, so errors here aren't fatal
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||
nsCOMPtr<nsIPrefBranchInternal> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||
if (prefBranch) {
|
||||
nsCOMPtr<nsIPrefBranchInternal> prefInternal = do_QueryInterface(prefBranch);
|
||||
if (prefInternal) {
|
||||
prefInternal->AddObserver(kCookiesP3PStringPref, this, PR_TRUE);
|
||||
}
|
||||
prefBranch->AddObserver(kCookiesP3PStringPref, this, PR_TRUE);
|
||||
}
|
||||
PrefChanged(prefBranch);
|
||||
}
|
||||
|
|
|
@ -174,8 +174,7 @@ nsTypeAheadFind::~nsTypeAheadFind()
|
|||
RemoveDocListeners();
|
||||
mTimer = nsnull;
|
||||
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
||||
nsCOMPtr<nsIPrefBranchInternal> prefInternal(do_QueryInterface(prefBranch));
|
||||
nsCOMPtr<nsIPrefBranchInternal> prefInternal(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
||||
if (prefInternal) {
|
||||
prefInternal->RemoveObserver("accessibility.typeaheadfind", this);
|
||||
prefInternal->RemoveObserver("accessibility.browsewithcaret", this);
|
||||
|
@ -189,13 +188,12 @@ nsTypeAheadFind::Init()
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
||||
nsCOMPtr<nsIPrefBranchInternal> prefInternal(do_QueryInterface(prefBranch));
|
||||
nsCOMPtr<nsIPrefBranchInternal> prefInternal(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
||||
mSearchRange = do_CreateInstance(kRangeCID);
|
||||
mStartPointRange = do_CreateInstance(kRangeCID);
|
||||
mEndPointRange = do_CreateInstance(kRangeCID);
|
||||
mFind = do_CreateInstance(NS_FIND_CONTRACTID);
|
||||
if (!prefBranch || !prefInternal || !mSearchRange || !mStartPointRange ||
|
||||
if (!prefInternal || !mSearchRange || !mStartPointRange ||
|
||||
!mEndPointRange || !mFind) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -209,7 +207,7 @@ nsTypeAheadFind::Init()
|
|||
|
||||
|
||||
// ----------- Get accel key --------------------
|
||||
rv = prefBranch->GetIntPref("ui.key.accelKey", &sAccelKey);
|
||||
rv = prefInternal->GetIntPref("ui.key.accelKey", &sAccelKey);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// ----------- Get initial preferences ----------
|
||||
|
|
|
@ -51,7 +51,6 @@
|
|||
|
||||
// pref. includes
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIPrefBranchInternal.h"
|
||||
|
||||
#define SCHEMA_2001_NAMESPACE "http://www.w3.org/2001/XMLSchema"
|
||||
#define SCHEMA_1999_NAMESPACE "http://www.w3.org/1999/XMLSchema"
|
||||
|
|
|
@ -993,18 +993,11 @@ nsHTMLFramesetFrame::Reflow(nsIPresContext* aPresContext,
|
|||
|
||||
PRBool firstTime = (eReflowReason_Initial == aReflowState.reason);
|
||||
if (firstTime) {
|
||||
nsCOMPtr<nsIPrefService> prefService(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
||||
if (prefService) {
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch;
|
||||
prefService->GetBranch(nsnull, getter_AddRefs(prefBranch));
|
||||
if (prefBranch) {
|
||||
nsCOMPtr<nsIPrefBranchInternal> prefBranchInternal(do_QueryInterface(prefBranch));
|
||||
if (prefBranchInternal) {
|
||||
mPrefBranchWeakRef = do_GetWeakReference(prefBranchInternal);
|
||||
prefBranchInternal->AddObserver(kFrameResizePref, this, PR_FALSE);
|
||||
}
|
||||
prefBranch->GetBoolPref(kFrameResizePref, &mForceFrameResizability);
|
||||
}
|
||||
nsCOMPtr<nsIPrefBranchInternal> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
||||
if (prefBranch) {
|
||||
mPrefBranchWeakRef = do_GetWeakReference(prefBranch);
|
||||
prefBranch->AddObserver(kFrameResizePref, this, PR_FALSE);
|
||||
prefBranch->GetBoolPref(kFrameResizePref, &mForceFrameResizability);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -993,18 +993,11 @@ nsHTMLFramesetFrame::Reflow(nsIPresContext* aPresContext,
|
|||
|
||||
PRBool firstTime = (eReflowReason_Initial == aReflowState.reason);
|
||||
if (firstTime) {
|
||||
nsCOMPtr<nsIPrefService> prefService(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
||||
if (prefService) {
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch;
|
||||
prefService->GetBranch(nsnull, getter_AddRefs(prefBranch));
|
||||
if (prefBranch) {
|
||||
nsCOMPtr<nsIPrefBranchInternal> prefBranchInternal(do_QueryInterface(prefBranch));
|
||||
if (prefBranchInternal) {
|
||||
mPrefBranchWeakRef = do_GetWeakReference(prefBranchInternal);
|
||||
prefBranchInternal->AddObserver(kFrameResizePref, this, PR_FALSE);
|
||||
}
|
||||
prefBranch->GetBoolPref(kFrameResizePref, &mForceFrameResizability);
|
||||
}
|
||||
nsCOMPtr<nsIPrefBranchInternal> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
||||
if (prefBranch) {
|
||||
mPrefBranchWeakRef = do_GetWeakReference(prefBranch);
|
||||
prefBranch->AddObserver(kFrameResizePref, this, PR_FALSE);
|
||||
prefBranch->GetBoolPref(kFrameResizePref, &mForceFrameResizability);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -294,14 +294,13 @@ nsXULTooltipListener::Init(nsIContent* aSourceNode, nsIRootBox* aRootBox)
|
|||
|
||||
// Only the first time, register the callback and get the initial value of the pref
|
||||
if (!prefChangeRegistered) {
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
||||
nsCOMPtr<nsIPrefBranchInternal> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
||||
if (prefBranch) {
|
||||
// get the initial value of the pref
|
||||
nsresult rv = prefBranch->GetBoolPref("browser.chrome.toolbar_tips", &sShowTooltips);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// register the callback so we get notified of updates
|
||||
nsCOMPtr<nsIPrefBranchInternal> prefInternal(do_QueryInterface(prefBranch));
|
||||
rv = prefInternal->AddObserver("browser.chrome.toolbar_tips", this, PR_FALSE);
|
||||
rv = prefBranch->AddObserver("browser.chrome.toolbar_tips", this, PR_FALSE);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
prefChangeRegistered = PR_TRUE;
|
||||
}
|
||||
|
|
|
@ -141,7 +141,7 @@ nsresult nsPrefService::Init()
|
|||
if (!rootBranch)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
mRootBranch = (nsIPrefBranch *)rootBranch;
|
||||
mRootBranch = (nsIPrefBranchInternal *)rootBranch;
|
||||
|
||||
nsXPIDLCString lockFileName;
|
||||
nsresult rv;
|
||||
|
@ -271,11 +271,7 @@ NS_IMETHODIMP nsPrefService::GetBranch(const char *aPrefRoot, nsIPrefBranch **_r
|
|||
rv = CallQueryInterface(prefBranch, _retval);
|
||||
} else {
|
||||
// special case caching the default root
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch = do_QueryInterface(mRootBranch, &rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
*_retval = prefBranch;
|
||||
NS_ADDREF(*_retval);
|
||||
}
|
||||
rv = CallQueryInterface(mRootBranch, _retval);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
@ -294,29 +290,6 @@ NS_IMETHODIMP nsPrefService::GetDefaultBranch(const char *aPrefRoot, nsIPrefBran
|
|||
}
|
||||
|
||||
|
||||
// Forward these methods through the nsIPrefBranchInternal headers
|
||||
|
||||
NS_IMETHODIMP nsPrefService::AddObserver(const char *aDomain, nsIObserver *aObserver, PRBool aHoldWeak)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIPrefBranchInternal> prefBranch = do_QueryInterface(mRootBranch, &rv);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = prefBranch->AddObserver(aDomain, aObserver, aHoldWeak);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsPrefService::RemoveObserver(const char *aDomain, nsIObserver *aObserver)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIPrefBranchInternal> prefBranch = do_QueryInterface(mRootBranch, &rv);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = prefBranch->RemoveObserver(aDomain, aObserver);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
nsresult nsPrefService::NotifyServiceObservers(const char *aTopic)
|
||||
{
|
||||
nsresult rv;
|
||||
|
|
|
@ -56,7 +56,7 @@ public:
|
|||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIPREFSERVICE
|
||||
NS_FORWARD_NSIPREFBRANCH(mRootBranch->)
|
||||
NS_DECL_NSIPREFBRANCHINTERNAL
|
||||
NS_FORWARD_NSIPREFBRANCHINTERNAL(mRootBranch->)
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
nsPrefService();
|
||||
|
@ -74,7 +74,7 @@ protected:
|
|||
nsresult WritePrefFile(nsIFile* aFile);
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIPrefBranch> mRootBranch;
|
||||
nsCOMPtr<nsIPrefBranchInternal> mRootBranch;
|
||||
nsIFile* mCurrentFile;
|
||||
PRPackedBool mErrorOpeningUserPrefs;
|
||||
|
||||
|
|
|
@ -219,14 +219,11 @@ nsIOService::Init()
|
|||
mRestrictedPortList.AppendElement(NS_REINTERPRET_CAST(void *, gBadPortList[i]));
|
||||
|
||||
// Further modifications to the port list come from prefs
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch;
|
||||
nsCOMPtr<nsIPrefBranchInternal> prefBranch;
|
||||
GetPrefBranch(getter_AddRefs(prefBranch));
|
||||
if (prefBranch) {
|
||||
nsCOMPtr<nsIPrefBranchInternal> pbi = do_QueryInterface(prefBranch);
|
||||
if (pbi) {
|
||||
pbi->AddObserver(PORT_PREF_PREFIX, this, PR_TRUE);
|
||||
pbi->AddObserver(AUTODIAL_PREF, this, PR_TRUE);
|
||||
}
|
||||
prefBranch->AddObserver(PORT_PREF_PREFIX, this, PR_TRUE);
|
||||
prefBranch->AddObserver(AUTODIAL_PREF, this, PR_TRUE);
|
||||
PrefsChanged(prefBranch);
|
||||
}
|
||||
|
||||
|
@ -319,7 +316,7 @@ nsIOService::GetProtocolHandler(const char* scheme, nsIProtocolHandler* *result)
|
|||
|
||||
PRBool externalProtocol = PR_FALSE;
|
||||
PRBool listedProtocol = PR_TRUE;
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch;
|
||||
nsCOMPtr<nsIPrefBranchInternal> prefBranch;
|
||||
GetPrefBranch(getter_AddRefs(prefBranch));
|
||||
if (prefBranch) {
|
||||
nsCAutoString externalProtocolPref("network.protocol-handler.external.");
|
||||
|
@ -634,13 +631,10 @@ nsIOService::ParsePortList(nsIPrefBranch *prefBranch, const char *pref, PRBool r
|
|||
}
|
||||
|
||||
void
|
||||
nsIOService::GetPrefBranch(nsIPrefBranch **result)
|
||||
nsIOService::GetPrefBranch(nsIPrefBranchInternal **result)
|
||||
{
|
||||
*result = nsnull;
|
||||
nsCOMPtr<nsIPrefService> prefService =
|
||||
do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||
if (prefService)
|
||||
prefService->GetBranch(nsnull, result);
|
||||
CallGetService(NS_PREFSERVICE_CONTRACTID, result);
|
||||
}
|
||||
|
||||
// nsIObserver interface
|
||||
|
|
|
@ -67,6 +67,7 @@
|
|||
static const char *gScheme[] = {"chrome", "file", "http", "jar", "resource"};
|
||||
|
||||
class nsIPrefBranch;
|
||||
class nsIPrefBranchInternal;
|
||||
|
||||
class nsIOService : public nsIIOService
|
||||
, public nsIObserver
|
||||
|
@ -102,7 +103,7 @@ protected:
|
|||
|
||||
// Prefs wrangling
|
||||
void PrefsChanged(nsIPrefBranch *prefs, const char *pref = nsnull);
|
||||
void GetPrefBranch(nsIPrefBranch **);
|
||||
void GetPrefBranch(nsIPrefBranchInternal **);
|
||||
void ParsePortList(nsIPrefBranch *prefBranch, const char *pref, PRBool remove);
|
||||
|
||||
protected:
|
||||
|
|
|
@ -148,12 +148,10 @@ nsresult
|
|||
nsProtocolProxyService::Init()
|
||||
{
|
||||
// failure to access prefs is non-fatal
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||
nsCOMPtr<nsIPrefBranchInternal> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||
if (prefBranch) {
|
||||
// monitor proxy prefs
|
||||
nsCOMPtr<nsIPrefBranchInternal> prefInt = do_QueryInterface(prefBranch);
|
||||
if (prefInt)
|
||||
prefInt->AddObserver("network.proxy", this, PR_FALSE);
|
||||
prefBranch->AddObserver("network.proxy", this, PR_FALSE);
|
||||
|
||||
// read all prefs
|
||||
PrefsChanged(prefBranch, nsnull);
|
||||
|
|
|
@ -302,22 +302,15 @@ nsStandardURL::~nsStandardURL()
|
|||
void
|
||||
nsStandardURL::InitGlobalObjects()
|
||||
{
|
||||
nsCOMPtr<nsIPrefService> prefService( do_GetService(NS_PREFSERVICE_CONTRACTID) );
|
||||
if (prefService) {
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch;
|
||||
prefService->GetBranch(nsnull, getter_AddRefs(prefBranch));
|
||||
if (prefBranch) {
|
||||
nsCOMPtr<nsIPrefBranchInternal> pbi( do_QueryInterface(prefBranch) );
|
||||
if (pbi) {
|
||||
nsCOMPtr<nsIObserver> obs( new nsPrefObserver() );
|
||||
pbi->AddObserver(NS_NET_PREF_ESCAPEUTF8, obs.get(), PR_FALSE);
|
||||
pbi->AddObserver(NS_NET_PREF_ENABLEIDN, obs.get(), PR_FALSE);
|
||||
// initialize IDN
|
||||
nsCOMPtr<nsIIDNService> serv(do_GetService(NS_IDNSERVICE_CONTRACTID));
|
||||
if (serv)
|
||||
NS_ADDREF(gIDNService = serv.get());
|
||||
}
|
||||
}
|
||||
nsCOMPtr<nsIPrefBranchInternal> prefBranch( do_GetService(NS_PREFSERVICE_CONTRACTID) );
|
||||
if (prefBranch) {
|
||||
nsCOMPtr<nsIObserver> obs( new nsPrefObserver() );
|
||||
prefBranch->AddObserver(NS_NET_PREF_ESCAPEUTF8, obs.get(), PR_FALSE);
|
||||
prefBranch->AddObserver(NS_NET_PREF_ENABLEIDN, obs.get(), PR_FALSE);
|
||||
// initialize IDN
|
||||
nsCOMPtr<nsIIDNService> serv(do_GetService(NS_IDNSERVICE_CONTRACTID));
|
||||
if (serv)
|
||||
NS_ADDREF(gIDNService = serv.get());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ public:
|
|||
|
||||
nsresult Install();
|
||||
nsresult Remove();
|
||||
nsresult ReadPrefs();
|
||||
nsresult ReadPrefs(nsIPrefBranch* branch);
|
||||
|
||||
PRBool DiskCacheEnabled();
|
||||
PRInt32 DiskCacheCapacity() { return mDiskCacheCapacity; }
|
||||
|
@ -133,10 +133,7 @@ nsCacheProfilePrefObserver::Install()
|
|||
|
||||
|
||||
// install preferences observer
|
||||
nsCOMPtr<nsIPrefService> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||
if (!prefs) return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIPrefBranchInternal> branch = do_QueryInterface(prefs);
|
||||
nsCOMPtr<nsIPrefBranchInternal> branch = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||
if (!branch) return NS_ERROR_FAILURE;
|
||||
|
||||
char * prefList[] = {
|
||||
|
@ -167,7 +164,7 @@ nsCacheProfilePrefObserver::Install()
|
|||
mHaveProfile = PR_TRUE;
|
||||
}
|
||||
|
||||
rv = ReadPrefs();
|
||||
rv = ReadPrefs(branch);
|
||||
|
||||
return NS_SUCCEEDED(rv) ? rv2 : rv;
|
||||
}
|
||||
|
@ -194,11 +191,7 @@ nsCacheProfilePrefObserver::Remove()
|
|||
|
||||
|
||||
// remove Pref Service observers
|
||||
nsCOMPtr<nsIPrefService> prefService = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIPrefBranchInternal> prefInternal = do_QueryInterface(prefService, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsCOMPtr<nsIPrefBranchInternal> prefInternal = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||
|
||||
// remove Disk cache pref observers
|
||||
rv = prefInternal->RemoveObserver(DISK_CACHE_ENABLE_PREF, this);
|
||||
|
@ -246,7 +239,8 @@ nsCacheProfilePrefObserver::Observe(nsISupports * subject,
|
|||
} else if (!strcmp("profile-after-change", topic)) {
|
||||
// profile after change
|
||||
mHaveProfile = PR_TRUE;
|
||||
ReadPrefs();
|
||||
nsCOMPtr<nsIPrefBranch> branch = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||
ReadPrefs(branch);
|
||||
nsCacheService::OnProfileChanged();
|
||||
|
||||
} else if (!strcmp(NS_PREFBRANCH_PREFCHANGE_TOPIC_ID, topic)) {
|
||||
|
@ -302,16 +296,10 @@ nsCacheProfilePrefObserver::Observe(nsISupports * subject,
|
|||
|
||||
|
||||
nsresult
|
||||
nsCacheProfilePrefObserver::ReadPrefs()
|
||||
nsCacheProfilePrefObserver::ReadPrefs(nsIPrefBranch* branch)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsCOMPtr<nsIPrefService> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||
if (!prefs) return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIPrefBranch> branch = do_QueryInterface(prefs);
|
||||
if (!branch) return NS_ERROR_FAILURE;
|
||||
|
||||
#ifdef NECKO_DISK_CACHE
|
||||
// read disk cache device prefs
|
||||
mDiskCacheEnabled = PR_TRUE; // presume disk cache is enabled
|
||||
|
|
|
@ -379,13 +379,9 @@ nsCookieService::Init()
|
|||
}
|
||||
|
||||
// init our pref and observer
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||
nsCOMPtr<nsIPrefBranchInternal> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||
if (prefBranch) {
|
||||
// add observers
|
||||
nsCOMPtr<nsIPrefBranchInternal> prefInternal = do_QueryInterface(prefBranch);
|
||||
if (prefInternal)
|
||||
prefInternal->AddObserver(kCookiesPermissions, this, PR_TRUE);
|
||||
|
||||
prefBranch->AddObserver(kCookiesPermissions, this, PR_TRUE);
|
||||
PrefChanged(prefBranch);
|
||||
}
|
||||
|
||||
|
|
|
@ -283,7 +283,7 @@ nsDNSService::Init()
|
|||
PRBool enableIDN = PR_TRUE;
|
||||
|
||||
// read prefs
|
||||
nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||
nsCOMPtr<nsIPrefBranchInternal> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||
if (prefs) {
|
||||
PRInt32 val;
|
||||
if (NS_SUCCEEDED(prefs->GetIntPref(kPrefDnsCacheEntries, &val)))
|
||||
|
@ -307,12 +307,9 @@ nsDNSService::Init()
|
|||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
// register as prefs observer
|
||||
nsCOMPtr<nsIPrefBranchInternal> prefsInt = do_QueryInterface(prefs);
|
||||
if (prefsInt) {
|
||||
prefsInt->AddObserver(kPrefDnsCacheEntries, this, PR_FALSE);
|
||||
prefsInt->AddObserver(kPrefDnsCacheExpiration, this, PR_FALSE);
|
||||
prefsInt->AddObserver(kPrefEnableIDN, this, PR_FALSE);
|
||||
}
|
||||
prefs->AddObserver(kPrefDnsCacheEntries, this, PR_FALSE);
|
||||
prefs->AddObserver(kPrefDnsCacheExpiration, this, PR_FALSE);
|
||||
prefs->AddObserver(kPrefEnableIDN, this, PR_FALSE);
|
||||
}
|
||||
|
||||
return nsHostResolver::Create(maxCacheEntries,
|
||||
|
|
|
@ -121,18 +121,14 @@ nsFtpProtocolHandler::Init()
|
|||
}
|
||||
|
||||
if (mIdleTimeout == -1) {
|
||||
nsCOMPtr<nsIPrefService> prefSrv = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsCOMPtr<nsIPrefBranch> branch;
|
||||
// I have to get the root pref branch because of bug 107617
|
||||
rv = prefSrv->GetBranch(nsnull, getter_AddRefs(branch));
|
||||
nsCOMPtr<nsIPrefBranchInternal> branch = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = branch->GetIntPref(IDLE_TIMEOUT_PREF, &mIdleTimeout);
|
||||
if (NS_FAILED(rv))
|
||||
mIdleTimeout = 5*60; // 5 minute default
|
||||
prefSrv->GetBranch(nsnull, getter_AddRefs(branch));
|
||||
nsCOMPtr<nsIPrefBranchInternal> pbi = do_QueryInterface(branch);
|
||||
rv = pbi->AddObserver(IDLE_TIMEOUT_PREF, this, PR_TRUE);
|
||||
|
||||
rv = branch->AddObserver(IDLE_TIMEOUT_PREF, this, PR_TRUE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
|
|
|
@ -191,18 +191,15 @@ nsHttpHandler::Init()
|
|||
InitUserAgentComponents();
|
||||
|
||||
// monitor some preference changes
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch;
|
||||
GetPrefBranch(getter_AddRefs(prefBranch));
|
||||
nsCOMPtr<nsIPrefBranchInternal> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||
if (prefBranch) {
|
||||
nsCOMPtr<nsIPrefBranchInternal> pbi = do_QueryInterface(prefBranch);
|
||||
if (pbi) {
|
||||
pbi->AddObserver(HTTP_PREF_PREFIX, this, PR_TRUE);
|
||||
pbi->AddObserver(UA_PREF_PREFIX, this, PR_TRUE);
|
||||
pbi->AddObserver(INTL_ACCEPT_LANGUAGES, this, PR_TRUE);
|
||||
pbi->AddObserver(INTL_ACCEPT_CHARSET, this, PR_TRUE);
|
||||
pbi->AddObserver(NETWORK_ENABLEIDN, this, PR_TRUE);
|
||||
pbi->AddObserver(BROWSER_PREF("disk_cache_ssl"), this, PR_TRUE);
|
||||
}
|
||||
prefBranch->AddObserver(HTTP_PREF_PREFIX, this, PR_TRUE);
|
||||
prefBranch->AddObserver(UA_PREF_PREFIX, this, PR_TRUE);
|
||||
prefBranch->AddObserver(INTL_ACCEPT_LANGUAGES, this, PR_TRUE);
|
||||
prefBranch->AddObserver(INTL_ACCEPT_CHARSET, this, PR_TRUE);
|
||||
prefBranch->AddObserver(NETWORK_ENABLEIDN, this, PR_TRUE);
|
||||
prefBranch->AddObserver(BROWSER_PREF("disk_cache_ssl"), this, PR_TRUE);
|
||||
|
||||
PrefsChanged(prefBranch, nsnull);
|
||||
}
|
||||
|
||||
|
@ -1027,16 +1024,6 @@ nsHttpHandler::PrefsChanged(nsIPrefBranch *prefs, const char *pref)
|
|||
#undef PREF_CHANGED
|
||||
}
|
||||
|
||||
void
|
||||
nsHttpHandler::GetPrefBranch(nsIPrefBranch **result)
|
||||
{
|
||||
*result = nsnull;
|
||||
nsCOMPtr<nsIPrefService> prefService =
|
||||
do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||
if (prefService)
|
||||
prefService->GetBranch(nsnull, result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocates a C string into that contains a ISO 639 language list
|
||||
* notated with HTTP "q" values for output with a HTTP Accept-Language
|
||||
|
|
|
@ -181,7 +181,6 @@ private:
|
|||
void BuildUserAgent();
|
||||
void InitUserAgentComponents();
|
||||
void PrefsChanged(nsIPrefBranch *prefs, const char *pref);
|
||||
void GetPrefBranch(nsIPrefBranch **);
|
||||
|
||||
nsresult SetAccept(const char *);
|
||||
nsresult SetAcceptLanguages(const char *);
|
||||
|
|
|
@ -227,20 +227,14 @@ nsPrefetchService::Init()
|
|||
nsresult rv;
|
||||
|
||||
// read prefs and hook up pref observer
|
||||
nsCOMPtr<nsIPrefService> prefServ(do_GetService(kPrefServiceCID, &rv));
|
||||
nsCOMPtr<nsIPrefBranchInternal> prefs(do_GetService(kPrefServiceCID, &rv));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsIPrefBranch> prefs;
|
||||
rv = prefServ->GetBranch(nsnull, getter_AddRefs(prefs));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
PRBool enabled;
|
||||
rv = prefs->GetBoolPref(PREFETCH_PREF, &enabled);
|
||||
if (NS_SUCCEEDED(rv) && enabled)
|
||||
mDisabled = PR_FALSE;
|
||||
PRBool enabled;
|
||||
rv = prefs->GetBoolPref(PREFETCH_PREF, &enabled);
|
||||
if (NS_SUCCEEDED(rv) && enabled)
|
||||
mDisabled = PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIPrefBranchInternal> prefsInt(do_QueryInterface(prefs));
|
||||
if (prefsInt)
|
||||
prefsInt->AddObserver(PREFETCH_PREF, this, PR_TRUE);
|
||||
}
|
||||
prefs->AddObserver(PREFETCH_PREF, this, PR_TRUE);
|
||||
}
|
||||
|
||||
// Observe xpcom-shutdown event
|
||||
|
|
Загрузка…
Ссылка в новой задаче