#include "content/browser/attribution_reporting/attribution_internals_handler_impl.h"
#include <stdint.h>
#include <iterator>
#include <optional>
#include <string>
#include <utility>
#include <vector>
#include "base/check.h"
#include "base/check_op.h"
#include "base/containers/flat_map.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/functional/overloaded.h"
#include "base/memory/raw_ref.h"
#include "base/memory/weak_ptr.h"
#include "base/notreached.h"
#include "base/numerics/safe_conversions.h"
#include "base/ranges/algorithm.h"
#include "base/time/time.h"
#include "base/values.h"
#include "components/attribution_reporting/aggregation_keys.h"
#include "components/attribution_reporting/os_registration.h"
#include "components/attribution_reporting/parsing_utils.h"
#include "components/attribution_reporting/source_registration.h"
#include "components/attribution_reporting/suitable_origin.h"
#include "components/attribution_reporting/trigger_config.h"
#include "components/attribution_reporting/trigger_registration.h"
#include "content/browser/attribution_reporting/aggregatable_debug_report.h"
#include "content/browser/attribution_reporting/attribution_debug_report.h"
#include "content/browser/attribution_reporting/attribution_info.h"
#include "content/browser/attribution_reporting/attribution_internals.mojom.h"
#include "content/browser/attribution_reporting/attribution_manager.h"
#include "content/browser/attribution_reporting/attribution_report.h"
#include "content/browser/attribution_reporting/attribution_reporting.mojom-forward.h"
#include "content/browser/attribution_reporting/attribution_trigger.h"
#include "content/browser/attribution_reporting/attribution_utils.h"
#include "content/browser/attribution_reporting/common_source_info.h"
#include "content/browser/attribution_reporting/create_report_result.h"
#include "content/browser/attribution_reporting/os_registration.h"
#include "content/browser/attribution_reporting/send_result.h"
#include "content/browser/attribution_reporting/storable_source.h"
#include "content/browser/attribution_reporting/stored_source.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
#include "content/public/common/content_client.h"
#include "net/base/net_errors.h"
#include "third_party/abseil-cpp/absl/numeric/int128.h"
#include "third_party/abseil-cpp/absl/types/variant.h"
#include "url/gurl.h"
#include "url/origin.h"
namespace content {
namespace {
Attributability;
Empty;
ReportStatus;
ReportStatusPtr;
WebUIAggregatableDebugReport;
WebUIDebugReport;
attribution_internals::mojom::WebUISourcePtr WebUISource(
const StoredSource& source,
Attributability attributability) { … }
std::vector<attribution_internals::mojom::WebUISourcePtr> ToWebUISources(
const std::vector<StoredSource>& active_sources) { … }
attribution_internals::mojom::WebUIReportPtr WebUIReport(
const AttributionReport& report,
bool is_debug_report,
ReportStatusPtr status) { … }
std::vector<attribution_internals::mojom::WebUIReportPtr> ToWebUIReports(
const std::vector<AttributionReport>& pending_reports) { … }
attribution_internals::mojom::NetworkStatusPtr NetworkStatus(int status) { … }
}
AttributionInternalsHandlerImpl::AttributionInternalsHandlerImpl(
WebUI* web_ui,
mojo::PendingRemote<attribution_internals::mojom::Observer> observer,
mojo::PendingReceiver<attribution_internals::mojom::Handler> handler)
: … { … }
AttributionInternalsHandlerImpl::~AttributionInternalsHandlerImpl() = default;
void AttributionInternalsHandlerImpl::IsAttributionReportingEnabled(
attribution_internals::mojom::Handler::IsAttributionReportingEnabledCallback
callback) { … }
void AttributionInternalsHandlerImpl::OnDebugModeChanged(bool debug_mode) { … }
void AttributionInternalsHandlerImpl::OnSourcesChanged() { … }
void AttributionInternalsHandlerImpl::OnReportsChanged() { … }
void AttributionInternalsHandlerImpl::SendReport(
AttributionReport::Id id,
attribution_internals::mojom::Handler::SendReportCallback callback) { … }
void AttributionInternalsHandlerImpl::ClearStorage(
attribution_internals::mojom::Handler::ClearStorageCallback callback) { … }
namespace {
WebUISourceRegistration;
attribution_internals::mojom::WebUIRegistrationPtr GetRegistration(
base::Time time,
const attribution_reporting::SuitableOrigin& context_origin,
const attribution_reporting::SuitableOrigin& reporting_origin,
std::string registration_json,
std::optional<uint64_t> cleared_debug_key) { … }
}
void AttributionInternalsHandlerImpl::OnSourceHandled(
const StorableSource& source,
base::Time source_time,
std::optional<uint64_t> cleared_debug_key,
attribution_reporting::mojom::StoreSourceResult result) { … }
void AttributionInternalsHandlerImpl::OnReportSent(
const AttributionReport& report,
bool is_debug_report,
const SendResult& info) { … }
void AttributionInternalsHandlerImpl::OnDebugReportSent(
const AttributionDebugReport& report,
int status,
base::Time time) { … }
void AttributionInternalsHandlerImpl::OnAggregatableDebugReportSent(
const AggregatableDebugReport& report,
base::ValueView report_body,
attribution_reporting::mojom::ProcessAggregatableDebugReportResult
process_result,
const SendAggregatableDebugReportResult& send_result) { … }
void AttributionInternalsHandlerImpl::OnOsRegistration(
base::Time time,
const attribution_reporting::OsRegistrationItem& registration,
const url::Origin& top_level_origin,
attribution_reporting::mojom::RegistrationType type,
bool is_debug_key_allowed,
attribution_reporting::mojom::OsRegistrationResult result) { … }
void AttributionInternalsHandlerImpl::OnTriggerHandled(
const std::optional<uint64_t> cleared_debug_key,
const CreateReportResult& result) { … }
void AttributionInternalsHandlerImpl::OnObserverDisconnected() { … }
}