Commit 7aa15255 authored by Kathleen Brade's avatar Kathleen Brade Committed by Mike Perry
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 cc841cc8
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -167,6 +167,7 @@
#include "nsWrapperCacheInlines.h"
#include "nsXULPopupManager.h"
#include "xpcprivate.h" // nsXPConnect
#include "mozIThirdPartyUtil.h"

#ifdef IBMBIDI
#include "nsIBidiKeyboard.h"
@@ -2675,8 +2676,6 @@ nsContentUtils::LoadImage(nsIURI* aURI, nsIDocument* aLoadingDocument,
  nsCOMPtr<nsILoadGroup> loadGroup = aLoadingDocument->GetDocumentLoadGroup();
  NS_ASSERTION(loadGroup, "Could not get loadgroup; onload may fire too early");

  nsIURI *documentURI = aLoadingDocument->GetDocumentURI();

  // check for a Content Security Policy to pass down to the channel that
  // will get created to load the image
  nsCOMPtr<nsIChannelPolicy> channelPolicy;
@@ -2694,10 +2693,14 @@ nsContentUtils::LoadImage(nsIURI* aURI, nsIDocument* aLoadingDocument,
  // Make the URI immutable so people won't change it under us
  NS_TryToSetImmutable(aURI);
 
  // XXXbz using "documentURI" for the initialDocumentURI is not quite
  // right, but the best we can do here...
  nsCOMPtr<nsIURI> firstPartyURI;
  nsCOMPtr<mozIThirdPartyUtil> thirdPartySvc
                               = do_GetService(THIRDPARTYUTIL_CONTRACTID);
  thirdPartySvc->GetFirstPartyURI(nullptr, aLoadingDocument,
                                  getter_AddRefs(firstPartyURI));

  return imgLoader->LoadImage(aURI,                 /* uri to load */
                              documentURI,          /* initialDocumentURI */
                              firstPartyURI,        /* firstPartyURI */
                              aReferrer,            /* referrer */
                              aLoadingPrincipal,    /* loading principal */
                              loadGroup,            /* loadgroup */
+16 −10
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@
#include "nsIContentPolicy.h"
#include "nsAutoPtr.h"
#include "imgRequestProxy.h"
#include "mozIThirdPartyUtil.h"

//*****************************************************************************
// class nsContextMenuInfo
@@ -271,7 +272,8 @@ nsContextMenuInfo::GetBackgroundImageRequestInternal(nsIDOMNode *aDOMNode, imgRe
  nsCOMPtr<nsIPrincipal> principal;
  nsCOMPtr<nsIChannelPolicy> channelPolicy;
  nsCOMPtr<nsIContentSecurityPolicy> csp;
  if (doc) {
  NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);

  principal = doc->NodePrincipal();
  nsresult rv = principal->GetCsp(getter_AddRefs(csp));
  NS_ENSURE_SUCCESS(rv, rv);
@@ -280,7 +282,6 @@ nsContextMenuInfo::GetBackgroundImageRequestInternal(nsIDOMNode *aDOMNode, imgRe
    channelPolicy->SetContentSecurityPolicy(csp);
    channelPolicy->SetLoadType(nsIContentPolicy::TYPE_IMAGE);
  }
  }
  
  while (true) {
    nsCOMPtr<nsIDOMElement> domElement(do_QueryInterface(domNode));
@@ -305,8 +306,13 @@ nsContextMenuInfo::GetBackgroundImageRequestInternal(nsIDOMNode *aDOMNode, imgRe

          nsRefPtr<imgLoader> il = imgLoader::GetInstance();
          NS_ENSURE_TRUE(il, NS_ERROR_FAILURE);
          nsCOMPtr<nsIURI> firstPartyURI;
          nsCOMPtr<mozIThirdPartyUtil> thirdPartySvc
              = do_GetService(THIRDPARTYUTIL_CONTRACTID);
          thirdPartySvc->GetFirstPartyURI(nullptr, doc,
                                          getter_AddRefs(firstPartyURI));

          return il->LoadImage(bgUri, nullptr, nullptr, principal, nullptr,
          return il->LoadImage(bgUri, firstPartyURI, nullptr, principal, nullptr,
                               nullptr, nullptr, nsIRequest::LOAD_NORMAL,
                               nullptr, channelPolicy, aRequest);
        }
+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 3rd party cookie blocking
   * @param aFirstPartyURI the urlbar URI that 'initiated' the load -- used for 3rd party blocking
   * @param aReferrerURI the 'referring' URI
   * @param aLoadingPrincipal the principal of the loading document
   * @param aLoadGroup Loadgroup to put the image load into
@@ -55,7 +55,7 @@ interface imgILoader : nsISupports
   * goes away.
   */
  imgIRequest loadImageXPCOM(in nsIURI aURI,
                             in nsIURI aInitialDocumentURL,
                             in nsIURI aFirstPartyURI,
                             in nsIURI aReferrerURI,
                             in nsIPrincipal aLoadingPrincipal,
                             in nsILoadGroup aLoadGroup,
+188 −91

File changed.

Preview size limit exceeded, changes collapsed.

Loading