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

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

Issue 2418813002: [Reland] Refactoring of SBER preference usage (Closed)
Patch Set: Sync Created 4 years, 2 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/safe_browsing/ui_manager.cc ('k') | chrome/browser/ssl/certificate_reporting_test_utils.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 08d57718d0d0a570c59821b8a5b6968204f20931..092984b0e92b14a2a7e60ed211875022d5e462fb 100644
--- a/chrome/browser/ssl/cert_report_helper.cc
+++ b/chrome/browser/ssl/cert_report_helper.cc
@@ -18,6 +18,7 @@
#include "chrome/common/pref_names.h"
#include "chrome/grit/generated_resources.h"
#include "components/prefs/pref_service.h"
+#include "components/safe_browsing_db/safe_browsing_prefs.h"
#include "components/security_interstitials/core/controller_client.h"
#include "components/security_interstitials/core/metrics_helper.h"
#include "components/variations/variations_associated_data.h"
@@ -25,6 +26,15 @@
#include "content/public/browser/web_contents.h"
#include "ui/base/l10n/l10n_util.h"
+namespace {
+
+// Returns a pointer to the Profile associated with |web_contents|.
+Profile* GetProfile(content::WebContents* web_contents) {
+ return Profile::FromBrowserContext(web_contents->GetBrowserContext());
+}
+
+} // namespace
+
// Constants for the HTTPSErrorReporter Finch experiment
const char CertReportHelper::kFinchExperimentName[] = "ReportCertificateErrors";
const char CertReportHelper::kFinchGroupShowPossiblySend[] =
@@ -63,9 +73,9 @@ void CertReportHelper::PopulateExtendedReportingOption(
if (!show)
return;
- load_time_data->SetBoolean(
- security_interstitials::kBoxChecked,
- IsPrefEnabled(prefs::kSafeBrowsingExtendedReportingEnabled));
+ load_time_data->SetBoolean(security_interstitials::kBoxChecked,
+ safe_browsing::IsExtendedReportingEnabled(
+ *GetProfile(web_contents_)->GetPrefs()));
const std::string privacy_link = base::StringPrintf(
security_interstitials::kPrivacyLinkHtml,
@@ -83,7 +93,8 @@ void CertReportHelper::FinishCertCollection(
if (!ShouldShowCertificateReporterCheckbox())
return;
- if (!IsPrefEnabled(prefs::kSafeBrowsingExtendedReportingEnabled))
+ if (!safe_browsing::IsExtendedReportingEnabled(
+ *GetProfile(web_contents_)->GetPrefs()))
return;
if (metrics_helper_) {
@@ -145,7 +156,5 @@ bool CertReportHelper::ShouldReportCertificateError() {
}
bool CertReportHelper::IsPrefEnabled(const char* pref) {
- Profile* profile =
- Profile::FromBrowserContext(web_contents_->GetBrowserContext());
- return profile->GetPrefs()->GetBoolean(pref);
+ return GetProfile(web_contents_)->GetPrefs()->GetBoolean(pref);
}
« no previous file with comments | « chrome/browser/safe_browsing/ui_manager.cc ('k') | chrome/browser/ssl/certificate_reporting_test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698