Files
cromite/build/patches/Allow-building-without-enable_reporting.patch
2021-10-16 22:28:37 +02:00

212 lines
9.0 KiB
Diff

From: Zoraver Kang <Zoraver@users.noreply.github.com>
Date: Fri, 22 May 2020 22:43:27 -0400
Subject: Allow building without enable_reporting
---
content/browser/BUILD.gn | 8 ++++----
.../common/content_switch_dependent_feature_overrides.cc | 3 +++
third_party/blink/renderer/core/frame/local_frame.cc | 3 +++
third_party/blink/renderer/core/frame/local_frame.h | 6 +++---
.../blink/renderer/core/frame/reporting_context.cc | 9 +++++++++
.../blink/renderer/core/frame/reporting_context.h | 7 +++++--
6 files changed, 27 insertions(+), 9 deletions(-)
diff --git a/content/browser/BUILD.gn b/content/browser/BUILD.gn
--- a/content/browser/BUILD.gn
+++ b/content/browser/BUILD.gn
@@ -1240,6 +1240,10 @@ source_set("browser") {
"net/browser_online_state_observer.cc",
"net/browser_online_state_observer.h",
"net/cookie_store_factory.cc",
+ "net/cross_origin_embedder_policy_reporter.cc",
+ "net/cross_origin_embedder_policy_reporter.h",
+ "net/cross_origin_opener_policy_reporter.cc",
+ "net/cross_origin_opener_policy_reporter.h",
"net/network_errors_listing_ui.cc",
"net/network_errors_listing_ui.h",
"net/network_quality_observer_impl.cc",
@@ -2989,10 +2993,6 @@ source_set("browser") {
if (enable_reporting) {
sources += [
- "net/cross_origin_embedder_policy_reporter.cc",
- "net/cross_origin_embedder_policy_reporter.h",
- "net/cross_origin_opener_policy_reporter.cc",
- "net/cross_origin_opener_policy_reporter.h",
"net/reporting_service_proxy.cc",
"net/reporting_service_proxy.h",
]
diff --git a/content/public/common/content_switch_dependent_feature_overrides.cc b/content/public/common/content_switch_dependent_feature_overrides.cc
--- a/content/public/common/content_switch_dependent_feature_overrides.cc
+++ b/content/public/common/content_switch_dependent_feature_overrides.cc
@@ -7,6 +7,7 @@
#include "content/public/common/content_features.h"
#include "content/public/common/content_switches.h"
#include "net/base/features.h"
+#include "net/net_buildflags.h"
#include "services/network/public/cpp/features.h"
#include "services/network/public/cpp/network_switches.h"
#include "third_party/blink/public/common/features.h"
@@ -46,9 +47,11 @@ GetSwitchDependentFeatureOverrides(const base::CommandLine& command_line) {
{switches::kEnableExperimentalWebPlatformFeatures,
std::cref(features::kDocumentPolicyNegotiation),
base::FeatureList::OVERRIDE_ENABLE_FEATURE},
+#if BUILDFLAG(ENABLE_REPORTING)
{switches::kEnableExperimentalWebPlatformFeatures,
std::cref(net::features::kDocumentReporting),
base::FeatureList::OVERRIDE_ENABLE_FEATURE},
+#endif
{switches::kEnableExperimentalWebPlatformFeatures,
std::cref(features::kExperimentalContentSecurityPolicyFeatures),
base::FeatureList::OVERRIDE_ENABLE_FEATURE},
diff --git a/third_party/blink/renderer/core/frame/local_frame.cc b/third_party/blink/renderer/core/frame/local_frame.cc
--- a/third_party/blink/renderer/core/frame/local_frame.cc
+++ b/third_party/blink/renderer/core/frame/local_frame.cc
@@ -39,6 +39,7 @@
#include "base/values.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
#include "mojo/public/cpp/system/message_pipe.h"
+#include "net/net_buildflags.h"
#include "services/data_decoder/public/mojom/resource_snapshot_for_web_bundle.mojom-blink.h"
#include "services/network/public/cpp/features.h"
#include "services/network/public/mojom/content_security_policy.mojom-blink.h"
@@ -2282,9 +2283,11 @@ const base::UnguessableToken& LocalFrame::GetAgentClusterId() const {
return base::UnguessableToken::Null();
}
+#if BUILDFLAG(ENABLE_REPORTING)
mojom::blink::ReportingServiceProxy* LocalFrame::GetReportingService() {
return mojo_handler_->ReportingService();
}
+#endif
// static
void LocalFrame::NotifyUserActivation(
diff --git a/third_party/blink/renderer/core/frame/local_frame.h b/third_party/blink/renderer/core/frame/local_frame.h
--- a/third_party/blink/renderer/core/frame/local_frame.h
+++ b/third_party/blink/renderer/core/frame/local_frame.h
@@ -33,9 +33,9 @@
#include "base/time/default_tick_clock.h"
#include "base/unguessable_token.h"
-#include "build/build_config.h"
#include "mojo/public/cpp/bindings/pending_associated_receiver.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
+#include "net/net_buildflags.h"
#include "services/device/public/mojom/device_posture_provider.mojom-blink-forward.h"
#include "services/network/public/mojom/fetch_api.mojom-blink-forward.h"
#include "third_party/blink/public/common/frame/frame_ad_evidence.h"
@@ -543,9 +543,9 @@ class CORE_EXPORT LocalFrame final : public Frame,
}
SmoothScrollSequencer& GetSmoothScrollSequencer();
-
+#if BUILDFLAG(ENABLE_REPORTING)
mojom::blink::ReportingServiceProxy* GetReportingService();
-
+#endif
// Returns the frame host ptr. The interface returned is backed by an
// associated interface with the legacy Chrome IPC channel.
mojom::blink::LocalFrameHost& GetLocalFrameHostRemote() const;
diff --git a/third_party/blink/renderer/core/frame/reporting_context.cc b/third_party/blink/renderer/core/frame/reporting_context.cc
--- a/third_party/blink/renderer/core/frame/reporting_context.cc
+++ b/third_party/blink/renderer/core/frame/reporting_context.cc
@@ -4,6 +4,7 @@
#include "third_party/blink/renderer/core/frame/reporting_context.h"
+#include "net/net_buildflags.h"
#include "third_party/blink/public/common/browser_interface_broker_proxy.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/public/platform/task_type.h"
@@ -54,7 +55,9 @@ const char ReportingContext::kSupplementName[] = "ReportingContext";
ReportingContext::ReportingContext(ExecutionContext& context)
: Supplement<ExecutionContext>(context),
execution_context_(context),
+#if BUILDFLAG(ENABLE_REPORTING)
reporting_service_(&context),
+#endif
receiver_(this, &context) {}
// static
@@ -118,7 +121,9 @@ void ReportingContext::Trace(Visitor* visitor) const {
visitor->Trace(observers_);
visitor->Trace(report_buffer_);
visitor->Trace(execution_context_);
+#if BUILDFLAG(ENABLE_REPORTING)
visitor->Trace(reporting_service_);
+#endif
visitor->Trace(receiver_);
Supplement<ExecutionContext>::Trace(visitor);
}
@@ -140,6 +145,7 @@ void ReportingContext::CountReport(Report* report) {
UseCounter::Count(execution_context_, feature);
}
+#if BUILDFLAG(ENABLE_REPORTING)
const HeapMojoRemote<mojom::blink::ReportingServiceProxy>&
ReportingContext::GetReportingService() const {
if (!reporting_service_.is_bound()) {
@@ -149,6 +155,7 @@ ReportingContext::GetReportingService() const {
}
return reporting_service_;
}
+#endif
void ReportingContext::NotifyInternal(Report* report) {
// Buffer the report.
@@ -171,6 +178,7 @@ void ReportingContext::NotifyInternal(Report* report) {
void ReportingContext::SendToReportingAPI(Report* report,
const String& endpoint) const {
+#if BUILDFLAG(ENABLE_REPORTING)
const String& type = report->type();
if (!(type == ReportType::kCSPViolation || type == ReportType::kDeprecation ||
type == ReportType::kPermissionsPolicyViolation ||
@@ -226,6 +234,7 @@ void ReportingContext::SendToReportingAPI(Report* report,
url, endpoint, body->featureId(), body->disposition(), body->message(),
body->sourceFile(), line_number, column_number);
}
+#endif
}
} // namespace blink
diff --git a/third_party/blink/renderer/core/frame/reporting_context.h b/third_party/blink/renderer/core/frame/reporting_context.h
--- a/third_party/blink/renderer/core/frame/reporting_context.h
+++ b/third_party/blink/renderer/core/frame/reporting_context.h
@@ -5,6 +5,7 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_FRAME_REPORTING_CONTEXT_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_FRAME_REPORTING_CONTEXT_H_
+#include "net/net_buildflags.h"
#include "third_party/blink/public/mojom/frame/reporting_observer.mojom-blink.h"
#include "third_party/blink/public/mojom/reporting/reporting.mojom-blink.h"
#include "third_party/blink/renderer/core/core_export.h"
@@ -53,10 +54,10 @@ class CORE_EXPORT ReportingContext : public GarbageCollected<ReportingContext>,
private:
// Counts the use of a report type via UseCounter.
void CountReport(Report*);
-
+#if BUILDFLAG(ENABLE_REPORTING)
const HeapMojoRemote<mojom::blink::ReportingServiceProxy>&
GetReportingService() const;
-
+#endif
void NotifyInternal(Report* report);
// Send |report| via the Reporting API to |endpoint|.
void SendToReportingAPI(Report* report, const String& endpoint) const;
@@ -67,8 +68,10 @@ class CORE_EXPORT ReportingContext : public GarbageCollected<ReportingContext>,
// This is declared mutable so that the service endpoint can be cached by
// const methods.
+#if BUILDFLAG(ENABLE_REPORTING)
mutable HeapMojoRemote<mojom::blink::ReportingServiceProxy>
reporting_service_;
+#endif
HeapMojoReceiver<mojom::blink::ReportingObserver, ReportingContext> receiver_;
};
--
2.17.1