blob: ab9bdb069df75e184ab03849f08d0aede5b29159 [file] [log] [blame]
// Copyright 2025 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_VARIATIONS_NET_OMNIBOX_AUTOFOCUS_URL_LOADER_THROTTLE_H_
#define COMPONENTS_VARIATIONS_NET_OMNIBOX_AUTOFOCUS_URL_LOADER_THROTTLE_H_
#include <memory>
#include <vector>
#include "base/memory/weak_ptr.h"
#include "build/build_config.h"
#include "third_party/blink/public/common/loader/url_loader_throttle.h"
namespace variations {
// This class is created per request. If the request is for a Google domain
// served over HTTPS, it adds a header describing the state of the omnibox
// autofocus experiment.
// It also removes this header on redirect away from Google domains.
class COMPONENT_EXPORT(OMNIBOX_AUTOFOCUS_HTTP_HEADERS)
OmniboxAutofocusURLLoaderThrottle : public blink::URLLoaderThrottle {
public:
OmniboxAutofocusURLLoaderThrottle();
~OmniboxAutofocusURLLoaderThrottle() override;
OmniboxAutofocusURLLoaderThrottle(OmniboxAutofocusURLLoaderThrottle&&) =
delete;
OmniboxAutofocusURLLoaderThrottle(const OmniboxAutofocusURLLoaderThrottle&) =
delete;
OmniboxAutofocusURLLoaderThrottle& operator==(
OmniboxAutofocusURLLoaderThrottle&&) = delete;
OmniboxAutofocusURLLoaderThrottle& operator==(
const OmniboxAutofocusURLLoaderThrottle&) = delete;
// Adds a utility class that calls into the above function on web content
// navigations.
static void AppendThrottleIfNeeded(
std::vector<std::unique_ptr<blink::URLLoaderThrottle>>* throttles);
// blink::URLLoaderThrottle:
void DetachFromCurrentSequence() override;
void WillStartRequest(network::ResourceRequest* request,
bool* defer) override;
void WillRedirectRequest(
net::RedirectInfo* redirect_info,
const network::mojom::URLResponseHead& response_head,
bool* defer,
std::vector<std::string>* to_be_removed_headers,
net::HttpRequestHeaders* modified_headers,
net::HttpRequestHeaders* modified_cors_exempt_headers) override;
};
} // namespace variations
#endif // COMPONENTS_VARIATIONS_NET_OMNIBOX_AUTOFOCUS_URL_LOADER_THROTTLE_H_