Commit 1509ba1c authored by Tom Schuster's avatar Tom Schuster
Browse files

Bug 1808146 - When creating a file promise for images, remember the referrer. r=nika

parent ca080b31
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -494,6 +494,13 @@ nsresult nsCopySupport::ImageCopy(nsIImageLoadingContent* aImageElement,
        aImageElement, getter_AddRefs(imgRequest));
    NS_ENSURE_TRUE(image, NS_ERROR_FAILURE);

    if (imgRequest) {
      // Remember the referrer used for this image request.
      nsCOMPtr<nsIReferrerInfo> referrerInfo;
      imgRequest->GetReferrerInfo(getter_AddRefs(referrerInfo));
      trans->SetReferrerInfo(referrerInfo);
    }

#ifdef XP_WIN
    rv = AppendImagePromise(trans, imgRequest, aImageElement);
    NS_ENSURE_SUCCESS(rv, rv);
+2 −1
Original line number Diff line number Diff line
@@ -3475,7 +3475,7 @@ mozilla::ipc::IPCResult ContentParent::RecvSetClipboard(
    const IPCDataTransfer& aDataTransfer, const bool& aIsPrivateData,
    nsIPrincipal* aRequestingPrincipal,
    const nsContentPolicyType& aContentPolicyType,
    const int32_t& aWhichClipboard) {
    nsIReferrerInfo* aReferrerInfo, const int32_t& aWhichClipboard) {
  // aRequestingPrincipal is allowed to be nullptr here.

  if (!ValidatePrincipal(aRequestingPrincipal,
@@ -3491,6 +3491,7 @@ mozilla::ipc::IPCResult ContentParent::RecvSetClipboard(
      do_CreateInstance("@mozilla.org/widget/transferable;1", &rv);
  NS_ENSURE_SUCCESS(rv, IPC_OK());
  trans->Init(nullptr);
  trans->SetReferrerInfo(aReferrerInfo);

  rv = nsContentUtils::IPCTransferableToTransferable(
      aDataTransfer, aIsPrivateData, aRequestingPrincipal, aContentPolicyType,
+1 −1
Original line number Diff line number Diff line
@@ -1005,7 +1005,7 @@ class ContentParent final : public PContentParent,
      const IPCDataTransfer& aDataTransfer, const bool& aIsPrivateData,
      nsIPrincipal* aRequestingPrincipal,
      const nsContentPolicyType& aContentPolicyType,
      const int32_t& aWhichClipboard);
      nsIReferrerInfo* aReferrerInfo, const int32_t& aWhichClipboard);

  mozilla::ipc::IPCResult RecvGetClipboard(nsTArray<nsCString>&& aTypes,
                                           const int32_t& aWhichClipboard,
+1 −0
Original line number Diff line number Diff line
@@ -1217,6 +1217,7 @@ parent:
                       bool aIsPrivateData,
                       nullable nsIPrincipal aRequestingPrincipal,
                       nsContentPolicyType aContentPolicyType,
                       nullable nsIReferrerInfo aReferrerInfo,
                       int32_t aWhichClipboard);

    // Given a list of supported types, returns the clipboard data for the
+6 −0
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@
interface imgINotificationObserver;
interface nsIURI;
interface nsIPrincipal;
interface nsIReferrerInfo;

/**
 * imgIRequest interface
@@ -142,6 +143,11 @@ interface imgIRequest : nsIRequest
   */
  readonly attribute long CORSMode;

  /**
   * The referrer that this image was loaded with.
   */
  readonly attribute nsIReferrerInfo referrerInfo;

  /**
   * Cancels this request as in nsIRequest::Cancel(); further, also nulls out
   * decoderObserver so it gets no further notifications from us.
Loading