mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 906282 - Replace pref observer with var cache and remove nsIObserver inheritance. r=bz
This commit is contained in:
parent
7db29cbd88
commit
f70f83da01
@ -99,7 +99,6 @@
|
||||
#include "nsISHEntry.h"
|
||||
#include "nsIWindowWatcher.h"
|
||||
#include "nsIPromptFactory.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsITransportSecurityInfo.h"
|
||||
#include "nsINSSErrorsService.h"
|
||||
#include "nsIApplicationCacheChannel.h"
|
||||
@ -197,6 +196,11 @@ static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
// True means sUseErrorPages has been added to preferences var cache.
|
||||
static bool gAddedPreferencesVarCache = false;
|
||||
|
||||
bool nsDocShell::sUseErrorPages = false;
|
||||
|
||||
// Number of documents currently loading
|
||||
static int32_t gNumberOfDocumentsLoading = 0;
|
||||
|
||||
@ -898,7 +902,6 @@ NS_INTERFACE_MAP_BEGIN(nsDocShell)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIContentViewerContainer)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIWebPageDescriptor)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIAuthPromptProvider)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIObserver)
|
||||
NS_INTERFACE_MAP_ENTRY(nsILoadContext)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIWebShellServices)
|
||||
NS_INTERFACE_MAP_ENTRY(nsILinkHandler)
|
||||
@ -2573,16 +2576,15 @@ nsDocShell::SetSecurityUI(nsISecureBrowserUI *aSecurityUI)
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::GetUseErrorPages(bool *aUseErrorPages)
|
||||
{
|
||||
*aUseErrorPages = mUseErrorPages;
|
||||
*aUseErrorPages = UseErrorPages();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::SetUseErrorPages(bool aUseErrorPages)
|
||||
{
|
||||
// If mUseErrorPages is set explicitly, stop observing the pref.
|
||||
// If mUseErrorPages is set explicitly, stop using sUseErrorPages.
|
||||
if (mObserveErrorPages) {
|
||||
Preferences::RemoveObserver(this, "browser.xul.error_pages.enabled");
|
||||
mObserveErrorPages = false;
|
||||
}
|
||||
mUseErrorPages = aUseErrorPages;
|
||||
@ -4486,7 +4488,8 @@ nsDocShell::DisplayLoadError(nsresult aError, nsIURI *aURI,
|
||||
|
||||
// Display the error as a page or an alert prompt
|
||||
NS_ENSURE_FALSE(messageStr.IsEmpty(), NS_ERROR_FAILURE);
|
||||
if (mUseErrorPages) {
|
||||
|
||||
if (UseErrorPages()) {
|
||||
// Display an error page
|
||||
LoadErrorPage(aURI, aURL, errorPage.get(), error.get(),
|
||||
messageStr.get(), cssClass.get(), aFailedChannel);
|
||||
@ -4939,8 +4942,11 @@ nsDocShell::Create()
|
||||
mUseErrorPages =
|
||||
Preferences::GetBool("browser.xul.error_pages.enabled", mUseErrorPages);
|
||||
|
||||
if (mObserveErrorPages) {
|
||||
Preferences::AddStrongObserver(this, "browser.xul.error_pages.enabled");
|
||||
if(!gAddedPreferencesVarCache) {
|
||||
Preferences::AddBoolVarCache(&sUseErrorPages,
|
||||
"browser.xul.error_pages.enabled",
|
||||
mUseErrorPages);
|
||||
gAddedPreferencesVarCache = true;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIObserverService> serv = services::GetObserverService();
|
||||
@ -4972,7 +4978,6 @@ nsDocShell::Destroy()
|
||||
|
||||
// Remove our pref observers
|
||||
if (mObserveErrorPages) {
|
||||
Preferences::RemoveObserver(this, "browser.xul.error_pages.enabled");
|
||||
mObserveErrorPages = false;
|
||||
}
|
||||
|
||||
@ -6976,7 +6981,7 @@ nsDocShell::EndPageLoad(nsIWebProgress * aProgress,
|
||||
aStatus == NS_ERROR_CONNECTION_REFUSED ||
|
||||
aStatus == NS_ERROR_UNKNOWN_PROXY_HOST ||
|
||||
aStatus == NS_ERROR_PROXY_CONNECTION_REFUSED) &&
|
||||
(isTopFrame || mUseErrorPages)) {
|
||||
(isTopFrame || UseErrorPages())) {
|
||||
DisplayLoadError(aStatus, url, nullptr, aChannel);
|
||||
}
|
||||
// Errors to be shown for any frame
|
||||
@ -11947,31 +11952,6 @@ nsDocShell::GetAuthPrompt(uint32_t aPromptReason, const nsIID& iid,
|
||||
reinterpret_cast<void**>(aResult));
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
// nsDocShell::nsIObserver
|
||||
//*****************************************************************************
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::Observe(nsISupports *aSubject, const char *aTopic,
|
||||
const PRUnichar *aData)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (mObserveErrorPages &&
|
||||
!nsCRT::strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID) &&
|
||||
!nsCRT::strcmp(aData,
|
||||
NS_LITERAL_STRING("browser.xul.error_pages.enabled").get())) {
|
||||
|
||||
bool tmpbool;
|
||||
rv = Preferences::GetBool("browser.xul.error_pages.enabled", &tmpbool);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
mUseErrorPages = tmpbool;
|
||||
|
||||
} else {
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
// nsDocShell::nsILoadContext
|
||||
//*****************************************************************************
|
||||
|
@ -39,7 +39,6 @@
|
||||
#include "nsIWebProgressListener.h"
|
||||
#include "nsIDocShellLoadInfo.h"
|
||||
#include "nsIAuthPromptProvider.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsILoadContext.h"
|
||||
#include "nsIWebShellServices.h"
|
||||
#include "nsILinkHandler.h"
|
||||
@ -136,7 +135,6 @@ class nsDocShell : public nsDocLoader,
|
||||
public nsIWebProgressListener,
|
||||
public nsIWebPageDescriptor,
|
||||
public nsIAuthPromptProvider,
|
||||
public nsIObserver,
|
||||
public nsILoadContext,
|
||||
public nsIWebShellServices,
|
||||
public nsILinkHandler,
|
||||
@ -169,7 +167,6 @@ public:
|
||||
NS_DECL_NSICONTENTVIEWERCONTAINER
|
||||
NS_DECL_NSIWEBPAGEDESCRIPTOR
|
||||
NS_DECL_NSIAUTHPROMPTPROVIDER
|
||||
NS_DECL_NSIOBSERVER
|
||||
NS_DECL_NSICLIPBOARDCOMMANDS
|
||||
NS_DECL_NSIWEBSHELLSERVICES
|
||||
NS_FORWARD_SAFE_NSIDOMSTORAGEMANAGER(TopSessionStorageManager())
|
||||
@ -527,6 +524,11 @@ protected:
|
||||
return uint32_t(t_usec /= usec_per_sec);
|
||||
}
|
||||
|
||||
inline bool UseErrorPages()
|
||||
{
|
||||
return (mObserveErrorPages ? sUseErrorPages : mUseErrorPages);
|
||||
}
|
||||
|
||||
bool IsFrame();
|
||||
|
||||
//
|
||||
@ -789,6 +791,9 @@ protected:
|
||||
};
|
||||
FullscreenAllowedState mFullscreenAllowed;
|
||||
|
||||
// Cached value of the "browser.xul.error_pages.enabled" preference.
|
||||
static bool sUseErrorPages;
|
||||
|
||||
bool mCreated;
|
||||
bool mAllowSubframes;
|
||||
bool mAllowPlugins;
|
||||
|
Loading…
Reference in New Issue
Block a user