chromium/net/reporting/reporting_header_parser.cc

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

#include "net/reporting/reporting_header_parser.h"

#include <cstring>
#include <string>
#include <utility>
#include <vector>

#include "base/check.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/json/json_reader.h"
#include "base/metrics/histogram_functions.h"
#include "base/time/time.h"
#include "base/values.h"
#include "net/base/features.h"
#include "net/base/isolation_info.h"
#include "net/base/network_anonymization_key.h"
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
#include "net/reporting/reporting_cache.h"
#include "net/reporting/reporting_context.h"
#include "net/reporting/reporting_delegate.h"
#include "net/reporting/reporting_endpoint.h"
#include "net/reporting/reporting_target_type.h"

namespace net {

namespace {

const char kUrlKey[] =;
const char kIncludeSubdomainsKey[] =;
const char kEndpointsKey[] =;
const char kGroupKey[] =;
const char kDefaultGroupName[] =;
const char kMaxAgeKey[] =;
const char kPriorityKey[] =;
const char kWeightKey[] =;

// Processes a single endpoint url string parsed from header.
//
// |endpoint_url_string| is the string value of the endpoint URL.
// |header_origin_url| is the origin URL that sent the header.
//
// |endpoint_url_out| is the endpoint URL parsed out of the string.
// Returns true on success or false if url was invalid.
bool ProcessEndpointURLString(const std::string& endpoint_url_string,
                              const url::Origin& header_origin,
                              GURL& endpoint_url_out) {}

// Processes a single endpoint tuple received in a Report-To header.
//
// |origin| is the origin that sent the Report-To header.
//
// |value| is the parsed JSON value of the endpoint tuple.
//
// |*endpoint_info_out| will contain the endpoint URL parsed out of the tuple.
// Returns true on success or false if endpoint was discarded.
bool ProcessEndpoint(ReportingDelegate* delegate,
                     const ReportingEndpointGroupKey& group_key,
                     const base::Value& value,
                     ReportingEndpoint::EndpointInfo* endpoint_info_out) {}

// Processes a single endpoint group tuple received in a Report-To header.
//
// |origin| is the origin that sent the Report-To header.
//
// |value| is the parsed JSON value of the endpoint group tuple.
// Returns true on successfully adding a non-empty group, or false if endpoint
// group was discarded or processed as a deletion.
bool ProcessEndpointGroup(
    ReportingDelegate* delegate,
    ReportingCache* cache,
    const NetworkAnonymizationKey& network_anonymization_key,
    const url::Origin& origin,
    const base::Value& value,
    ReportingEndpointGroup* parsed_endpoint_group_out) {}

// Processes a single endpoint tuple received in a Reporting-Endpoints header.
//
// |group_key| is the key for the endpoint group this endpoint belongs.
// |endpoint_url_string| is the endpoint url as received in the header.
//
// |endpoint_info_out| is the endpoint info parsed out of the value.
bool ProcessEndpoint(ReportingDelegate* delegate,
                     const ReportingEndpointGroupKey& group_key,
                     const std::string& endpoint_url_string,
                     ReportingEndpoint::EndpointInfo& endpoint_info_out) {}

// Process a single endpoint received in a Reporting-Endpoints header.
bool ProcessV1Endpoint(ReportingDelegate* delegate,
                       ReportingCache* cache,
                       const base::UnguessableToken& reporting_source,
                       const NetworkAnonymizationKey& network_anonymization_key,
                       const url::Origin& origin,
                       const std::string& endpoint_name,
                       const std::string& endpoint_url_string,
                       ReportingEndpoint& parsed_endpoint_out) {}

}  // namespace

std::optional<base::flat_map<std::string, std::string>> ParseReportingEndpoints(
    const std::string& header) {}

// static
void ReportingHeaderParser::RecordReportingHeaderType(
    ReportingHeaderType header_type) {}

// static
void ReportingHeaderParser::ParseReportToHeader(
    ReportingContext* context,
    const NetworkAnonymizationKey& network_anonymization_key,
    const url::Origin& origin,
    const base::Value::List& list) {}

// static
void ReportingHeaderParser::ProcessParsedReportingEndpointsHeader(
    ReportingContext* context,
    const base::UnguessableToken& reporting_source,
    const IsolationInfo& isolation_info,
    const NetworkAnonymizationKey& network_anonymization_key,
    const url::Origin& origin,
    base::flat_map<std::string, std::string> header) {}

}  // namespace net