Separate parsing from processing Reporting-Endpoints header.

This change is in preparation for proper isolation of reports from
different documents and workers; in subsequent CLs, a reporting source
token will be added to this flow, but for this to happen, we need to
delay adding the reporting endpoints to the cache until the point where
such a token could be generated for a new document.

This is the second in a series of CLs implementing V1 reporting
isolation. A summary of the architectural changes introduced can be
found at
https://docs.google.com/document/d/1RmEz17pGSUQITPoRKV4s3IBgbyHjv-HLZqtVYYZ4lMg/edit

CLs in this series:
https://crrev.com/c/2878175 Update NEL browser tests to require Report-To
https://crrev.com/c/2878376 (This CL) Separate parsing from processing Reporting-Endpoints
https://crrev.com/c/2889833 Add reporting source to worker objects
https://crrev.com/c/2889975 Add reporting source to COOP/COEP reporters
https://crrev.com/c/2889773 Plumb reporting source to network code
https://crrev.com/c/2807776 Isolate reports in ReportingCache

Bug: 1062359
Change-Id: Icea6b742017540ca8e964789977afdf158a43fdb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2878376
Reviewed-by: Matt Menke <[email protected]>
Reviewed-by: Ken Buchanan <[email protected]>
Reviewed-by: Mike West <[email protected]>
Reviewed-by: Joshua Bell <[email protected]>
Reviewed-by: Lily Chen <[email protected]>
Reviewed-by: Rodney Ding <[email protected]>
Commit-Queue: Ian Clelland <[email protected]>
Cr-Commit-Position: refs/heads/master@{#888594}
diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc
index 798f85a..47cb01bf 100644
--- a/net/http/http_network_transaction.cc
+++ b/net/http/http_network_transaction.cc
@@ -1243,13 +1243,14 @@
     return rv;
 
 #if BUILDFLAG(ENABLE_REPORTING)
+  // Note: This just handles the legacy Report-To header, which is still
+  // required for NEL. The newer Reporting-Endpoints header is processed in
+  // network::PopulateParsedHeaders().
+  ProcessReportToHeader();
+
   // Note: Unless there is a pre-existing NEL policy for this origin, any NEL
   // reports generated before the NEL header is processed here will just be
   // dropped by the NetworkErrorLoggingService.
-  ProcessReportToHeader();
-  if (base::FeatureList::IsEnabled(net::features::kDocumentReporting)) {
-    ProcessReportingEndpointsHeader();
-  }
   ProcessNetworkErrorLoggingHeader();
 
   // Generate NEL report here if we have to report an HTTP error (4xx or 5xx
@@ -1382,26 +1383,6 @@
 }
 
 #if BUILDFLAG(ENABLE_REPORTING)
-void HttpNetworkTransaction::ProcessReportingEndpointsHeader() {
-  std::string value;
-  if (!response_.headers->GetNormalizedHeader("Reporting-Endpoints", &value))
-    return;
-
-  ReportingService* service = session_->reporting_service();
-  if (!service)
-    return;
-
-  // Only accept Reporting-Endpoints headers on HTTPS connections that have no
-  // certificate errors.
-  if (!response_.ssl_info.is_valid())
-    return;
-  if (IsCertStatusError(response_.ssl_info.cert_status))
-    return;
-
-  service->ProcessReportingEndpointsHeader(url::Origin::Create(url_),
-                                           network_isolation_key_, value);
-}
-
 void HttpNetworkTransaction::ProcessReportToHeader() {
   std::string value;
   if (!response_.headers->GetNormalizedHeader("Report-To", &value))