chromium/content/browser/interest_group/ad_auction_url_loader_interceptor.h

// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CONTENT_BROWSER_INTEREST_GROUP_AD_AUCTION_URL_LOADER_INTERCEPTOR_H_
#define CONTENT_BROWSER_INTEREST_GROUP_AD_AUCTION_URL_LOADER_INTERCEPTOR_H_

#include <string>
#include <vector>

#include "base/memory/raw_ref.h"
#include "content/browser/loader/subresource_proxying_url_loader.h"
#include "content/public/browser/weak_document_ptr.h"
#include "net/http/http_request_headers.h"
#include "net/url_request/redirect_info.h"
#include "services/network/public/cpp/resource_request.h"
#include "services/network/public/mojom/url_response_head.mojom-forward.h"
#include "url/gurl.h"
#include "url/origin.h"

namespace content {

// A loader interceptor for handling an ad auction subresource request,
// including fetch(<url>, {adAuctionHeaders: true}).
//
// This loader interceptor works as follows:
//   1. Before making a network request (i.e. WillStartRequest()), if the
//      request is eligible for ad auction headers, add the
//      `Sec-Ad-Auction-Fetch: ?1` header.
//   2. If any redirect is encountered, skip handling the response; otherwise,
//      for the response (i.e. OnReceiveResponse()), if the previous request was
//      eligible for ad auction headers, and if the response header contains the
//      auction result, signals, or additional bids, associate them with the
//      top-level page.
class CONTENT_EXPORT AdAuctionURLLoaderInterceptor
    : public SubresourceProxyingURLLoader::Interceptor {};

}  // namespace content

#endif  // CONTENT_BROWSER_INTEREST_GROUP_AD_AUCTION_URL_LOADER_INTERCEPTOR_H_