Reporting: Fill in user_agent field in reports
Per https://github.com/w3c/reporting/issues/52, we are now supposed to
include the User-Agent string of the original request in any reports
generated about that request.
[email protected]
Bug: 865394
Cq-Include-Trybots: luci.chromium.try:linux_mojo
Change-Id: Ib49244399ed05398d598da1d02131153dd509306
Reviewed-on: https://chromium-review.googlesource.com/1140203
Commit-Queue: Douglas Creager <[email protected]>
Reviewed-by: Matt Menke <[email protected]>
Reviewed-by: Misha Efimov <[email protected]>
Cr-Commit-Position: refs/heads/master@{#576599}
diff --git a/content/browser/net/reporting_service_proxy.cc b/content/browser/net/reporting_service_proxy.cc
index b231bd7..6f525514 100644
--- a/content/browser/net/reporting_service_proxy.cc
+++ b/content/browser/net/reporting_service_proxy.cc
@@ -16,6 +16,7 @@
#include "mojo/public/cpp/bindings/strong_binding.h"
#include "net/reporting/reporting_report.h"
#include "net/reporting/reporting_service.h"
+#include "net/url_request/http_user_agent_settings.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_getter.h"
#include "third_party/blink/public/platform/reporting.mojom.h"
@@ -125,7 +126,11 @@
// Depth is only non-zero for NEL reports, and those can't come from the
// renderer.
- reporting_service->QueueReport(url, group, type, std::move(body),
+ std::string user_agent;
+ if (request_context->http_user_agent_settings() != nullptr)
+ user_agent = request_context->http_user_agent_settings()->GetUserAgent();
+ reporting_service->QueueReport(url, user_agent, group, type,
+ std::move(body),
/* depth= */ 0);
}