Commit e6a755ba authored by Kathleen Brade's avatar Kathleen Brade Committed by Georg Koppen
Browse files

Bug #6539: Isolate the Image Cache per url bar domain.

The image cache maintains its own table outside of the main cache, and does
not obey cacheKeys by default.
parent b4c2a546
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -180,6 +180,7 @@
#include "xpcprivate.h" // nsXPConnect
#include "HTMLSplitOnSpacesTokenizer.h"
#include "nsContentTypeParser.h"
#include "mozIThirdPartyUtil.h"

#include "nsIBidiKeyboard.h"

@@ -3012,10 +3013,16 @@ nsContentUtils::LoadImage(nsIURI* aURI, nsIDocument* aLoadingDocument,
  // Make the URI immutable so people won't change it under us
  NS_TryToSetImmutable(aURI);
 
  nsCOMPtr<nsIURI> firstPartyIsolationURI;
  nsCOMPtr<mozIThirdPartyUtil> thirdPartySvc
                               = do_GetService(THIRDPARTYUTIL_CONTRACTID);
  thirdPartySvc->GetFirstPartyIsolationURI(nullptr, aLoadingDocument,
                                           getter_AddRefs(firstPartyIsolationURI));
 
  // XXXbz using "documentURI" for the initialDocumentURI is not quite
  // right, but the best we can do here...
  return imgLoader->LoadImage(aURI,                 /* uri to load */
                              documentURI,          /* initialDocumentURI */
                              firstPartyIsolationURI,  /* initialDocumentURI */
                              aReferrer,            /* referrer */
                              aReferrerPolicy,      /* referrer policy */
                              aLoadingPrincipal,    /* loading principal */
+7 −2
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@
#include "nsIContentPolicy.h"
#include "nsAutoPtr.h"
#include "imgRequestProxy.h"

#include "mozIThirdPartyUtil.h"

//*****************************************************************************
// class nsContextMenuInfo
@@ -294,7 +294,12 @@ nsContextMenuInfo::GetBackgroundImageRequestInternal(nsIDOMNode *aDOMNode, imgRe
          nsRefPtr<imgLoader> il = imgLoader::GetInstance();
          NS_ENSURE_TRUE(il, NS_ERROR_FAILURE);

          return il->LoadImage(bgUri, nullptr, nullptr,
          nsCOMPtr<nsIURI> firstPartyIsolationURI;
          nsCOMPtr<mozIThirdPartyUtil> thirdPartySvc
              = do_GetService(THIRDPARTYUTIL_CONTRACTID);
          thirdPartySvc->GetFirstPartyIsolationURI(nullptr, doc,
                                                   getter_AddRefs(firstPartyIsolationURI));
          return il->LoadImage(bgUri, firstPartyIsolationURI, nullptr,
                               doc->GetReferrerPolicy(), principal, nullptr,
                               nullptr, nullptr, nsIRequest::LOAD_NORMAL,
                               nullptr, nsIContentPolicy::TYPE_IMAGE,
+3 −0
Original line number Diff line number Diff line
@@ -358,6 +358,9 @@ nsCookiePermission::CanSetCookie(nsIURI *aURI,
        }
      }
    }

    // TODO: Why don't we just use this here:
    // httpChannelInternal->GetDocumentURI(aURI);
  }

  return NS_OK;
+2 −2
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ interface imgILoader : nsISupports
  /**
   * Start the load and decode of an image.
   * @param aURI the URI to load
   * @param aInitialDocumentURI the URI that 'initiated' the load -- used for
   * @param aFirstPartyIsolationURI the URI that 'initiated' the load -- used for
   *           3rd party cookie blocking
   * @param aReferrerURI the 'referring' URI
   * @param aReferrerPolicy the policy to apply to sending referrers.
@@ -62,7 +62,7 @@ interface imgILoader : nsISupports
   * goes away.
   */
  imgIRequest loadImageXPCOM(in nsIURI aURI,
                             in nsIURI aInitialDocumentURL,
                             in nsIURI aFirstPartyIsolationURI,
                             in nsIURI aReferrerURI,
                             in AString aReferrerPolicy,
                             in nsIPrincipal aLoadingPrincipal,
+7 −0
Original line number Diff line number Diff line
@@ -74,6 +74,13 @@ public:
    return newURI.forget();
  }

  nsresult Equals(nsIURI *otherURI, bool *result) {
    nsAutoCString otherSpec;    
    otherURI->GetSpec(otherSpec);
    *result = mSpec.Equals(otherSpec);
    return NS_OK;
  }

private:
  // Since this is a basic storage class, no duplication of spec parsing is
  // included in the functionality. Instead, the class depends upon the
Loading