Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5267)

Unified Diff: chrome/browser/ssl/cert_report_helper.cc

Issue 2903383002: Limit certificate error reports to running in official builds (Closed)
Patch Set: fix more tests Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ssl/cert_report_helper.h ('k') | chrome/browser/ssl/ssl_browser_tests.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ssl/cert_report_helper.cc
diff --git a/chrome/browser/ssl/cert_report_helper.cc b/chrome/browser/ssl/cert_report_helper.cc
index 053ce92196d6b6c9f2173c934a0c723e0e64c812..418750ad5280fa60daf4e4ca6e547cb53d4aa4b4 100644
--- a/chrome/browser/ssl/cert_report_helper.cc
+++ b/chrome/browser/ssl/cert_report_helper.cc
@@ -29,6 +29,10 @@
namespace {
+// Certificate reports are only sent from official builds, but this flag can be
+// set by tests.
+static bool g_is_fake_official_build_for_testing = false;
+
// Returns a pointer to the Profile associated with |web_contents|.
Profile* GetProfile(content::WebContents* web_contents) {
return Profile::FromBrowserContext(web_contents->GetBrowserContext());
@@ -65,6 +69,11 @@ CertReportHelper::CertReportHelper(
CertReportHelper::~CertReportHelper() {
}
+// static
+void CertReportHelper::SetFakeOfficialBuildForTesting() {
+ g_is_fake_official_build_for_testing = true;
+}
+
void CertReportHelper::PopulateExtendedReportingOption(
base::DictionaryValue* load_time_data) {
// Only show the checkbox if not off-the-record and if this client is
@@ -149,6 +158,15 @@ bool CertReportHelper::ShouldShowCertificateReporterCheckbox() {
bool CertReportHelper::ShouldReportCertificateError() {
DCHECK(ShouldShowCertificateReporterCheckbox());
+
+ bool is_official_build = g_is_fake_official_build_for_testing;
Nathan Parker 2017/05/26 21:34:07 I feel like there could be a better pattern than t
+#if defined(OFFICIAL_BUILD) && defined(GOOGLE_CHROME_BUILD)
+ is_official_build = true;
+#endif
+
+ if (!is_official_build)
+ return false;
+
// Even in case the checkbox was shown, we don't send error reports
// for all of these users. Check the Finch configuration for a sending
// threshold and only send reports in case the threshold isn't exceeded.
« no previous file with comments | « chrome/browser/ssl/cert_report_helper.h ('k') | chrome/browser/ssl/ssl_browser_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698