#include "components/variations/net/variations_http_headers.h"
#include <utility>
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/string_util.h"
#include "build/build_config.h"
#include "components/google/core/common/google_util.h"
#include "components/variations/net/omnibox_http_headers.h"
#include "components/variations/variations_features.h"
#include "components/variations/variations_ids_provider.h"
#include "net/base/isolation_info.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "net/url_request/redirect_info.h"
#include "services/network/public/cpp/resource_request.h"
#include "services/network/public/cpp/simple_url_loader.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
#include "url/gurl.h"
#if BUILDFLAG(IS_IOS)
#include "base/command_line.h"
#include "components/variations/net/variations_flags.h"
#include "net/base/url_util.h"
#endif
namespace variations {
const char kClientDataHeader[] = …;
namespace {
enum class URLValidationResult { … };
enum RequestContextCategory { … };
void LogRequestContextHistogram(RequestContextCategory result) { … }
URLValidationResult GetUrlValidationResult(const GURL& url) { … }
bool ShouldAppendVariationsHeader(const GURL& url, const std::string& suffix) { … }
bool IsFirstPartyContext(Owner owner,
const network::ResourceRequest& resource_request) { … }
variations::mojom::GoogleWebVisibility GetVisibilityKey(
Owner owner,
const network::ResourceRequest& resource_request) { … }
std::string SelectVariationsHeader(
variations::mojom::VariationsHeadersPtr variations_headers,
Owner owner,
const network::ResourceRequest& resource_request) { … }
class VariationsHeaderHelper { … };
}
bool AppendVariationsHeader(const GURL& url,
InIncognito incognito,
SignedIn signed_in,
network::ResourceRequest* request) { … }
bool AppendVariationsHeaderWithCustomValue(
const GURL& url,
InIncognito incognito,
variations::mojom::VariationsHeadersPtr variations_headers,
Owner owner,
network::ResourceRequest* request) { … }
bool AppendVariationsHeaderUnknownSignedIn(const GURL& url,
InIncognito incognito,
network::ResourceRequest* request) { … }
void RemoveVariationsHeaderIfNeeded(
const net::RedirectInfo& redirect_info,
const network::mojom::URLResponseHead& response_head,
std::vector<std::string>* to_be_removed_headers) { … }
std::unique_ptr<network::SimpleURLLoader>
CreateSimpleURLLoaderWithVariationsHeader(
std::unique_ptr<network::ResourceRequest> request,
InIncognito incognito,
SignedIn signed_in,
const net::NetworkTrafficAnnotationTag& annotation_tag) { … }
std::unique_ptr<network::SimpleURLLoader>
CreateSimpleURLLoaderWithVariationsHeaderUnknownSignedIn(
std::unique_ptr<network::ResourceRequest> request,
InIncognito incognito,
const net::NetworkTrafficAnnotationTag& annotation_tag) { … }
bool HasVariationsHeader(const network::ResourceRequest& request) { … }
bool GetVariationsHeader(const network::ResourceRequest& request,
std::string* out) { … }
bool ShouldAppendVariationsHeaderForTesting(
const GURL& url,
const std::string& histogram_suffix) { … }
void UpdateCorsExemptHeaderForVariations(
network::mojom::NetworkContextParams* params) { … }
}