Bug 442806: Use seperate, versioned caches for offline apps. r+sr=bz

This commit is contained in:
Dave Camp
2008-08-19 19:30:44 -07:00
parent 83757beabe
commit 4e3c0bbc64
38 changed files with 1537 additions and 1276 deletions

View File

@@ -143,6 +143,9 @@
#include "nsINestedURI.h"
#include "nsITransportSecurityInfo.h"
#include "nsINSSErrorsService.h"
#include "nsIApplicationCache.h"
#include "nsIApplicationCacheContainer.h"
#include "nsIPermissionManager.h"
// Editor-related
#include "nsIEditingSession.h"
@@ -458,6 +461,22 @@ NS_IMETHODIMP nsDocShell::GetInterface(const nsIID & aIID, void **aSink)
mContentViewer->GetDOMDocument((nsIDOMDocument **) aSink);
return *aSink ? NS_OK : NS_NOINTERFACE;
}
else if (aIID.Equals(NS_GET_IID(nsIApplicationCacheContainer)) &&
NS_SUCCEEDED(EnsureContentViewer())) {
*aSink = nsnull;
// Return the toplevel document as an
// nsIApplicationCacheContainer.
nsCOMPtr<nsIDocShellTreeItem> rootItem;
GetSameTypeRootTreeItem(getter_AddRefs(rootItem));
nsCOMPtr<nsIDOMDocument> domDoc = do_GetInterface(rootItem);
NS_ASSERTION(domDoc, "Should have a document.");
if (!domDoc)
return NS_ERROR_NO_INTERFACE;
return domDoc->QueryInterface(aIID, aSink);
}
else if (aIID.Equals(NS_GET_IID(nsIPrompt)) &&
NS_SUCCEEDED(EnsureScriptEnvironment())) {
nsresult rv;
@@ -7275,6 +7294,15 @@ nsDocShell::DoURILoad(nsIURI * aURI,
if (aFirstParty) {
// tag first party URL loads
loadFlags |= nsIChannel::LOAD_INITIAL_DOCUMENT_URI;
// Toplevel document loads in domains with the offline-app
// permission should check for an associated application
// cache.
nsCOMPtr<nsIDocShellTreeItem> root;
GetSameTypeRootTreeItem(getter_AddRefs(root));
if (root == this && NS_OfflineAppAllowed(aURI)) {
loadFlags |= nsICachingChannel::LOAD_CHECK_OFFLINE_CACHE;
}
}
if (mLoadType == LOAD_ERROR_PAGE) {