Bug 1237783 - Make sure we correctly turn off appcache. r=ehsan

This commit is contained in:
Honza Bambas 2016-02-05 08:36:00 -05:00
parent 61107b5fc9
commit bb3147ef68
2 changed files with 14 additions and 1 deletions

View File

@ -69,7 +69,7 @@ typedef any Transferable;
#ifdef HAVE_SIDEBAR
[Replaceable, Throws] readonly attribute External external;
#endif
[Throws] readonly attribute ApplicationCache applicationCache;
[Throws, Pref="browser.cache.offline.enable"] readonly attribute ApplicationCache applicationCache;
// user prompts
[Throws, UnsafeInPrerendering] void alert();

View File

@ -52,6 +52,7 @@ using namespace mozilla;
using namespace mozilla::dom;
static nsOfflineCacheUpdateService *gOfflineCacheUpdateService = nullptr;
static bool sAllowOfflineCache = true;
nsTHashtable<nsCStringHashKey>* nsOfflineCacheUpdateService::mAllowedDomains = nullptr;
@ -247,6 +248,10 @@ nsOfflineCacheUpdateService::nsOfflineCacheUpdateService()
, mUpdateRunning(false)
, mLowFreeSpace(false)
{
MOZ_ASSERT(NS_IsMainThread());
Preferences::AddBoolVarCache(&sAllowOfflineCache,
"browser.cache.offline.enable",
true);
}
nsOfflineCacheUpdateService::~nsOfflineCacheUpdateService()
@ -605,6 +610,10 @@ OfflineAppPermForPrincipal(nsIPrincipal *aPrincipal,
{
*aAllowed = false;
if (!sAllowOfflineCache) {
return NS_OK;
}
if (!aPrincipal)
return NS_ERROR_INVALID_ARG;
@ -696,6 +705,10 @@ nsOfflineCacheUpdateService::AllowOfflineApp(nsIPrincipal *aPrincipal)
{
nsresult rv;
if (!sAllowOfflineCache) {
return NS_ERROR_NOT_AVAILABLE;
}
if (GeckoProcessType_Default != XRE_GetProcessType()) {
ContentChild* child = ContentChild::GetSingleton();