Chromium Code Reviews| Index: chrome/browser/interstitials/security_interstitial_page.cc |
| diff --git a/chrome/browser/interstitials/security_interstitial_page.cc b/chrome/browser/interstitials/security_interstitial_page.cc |
| index 8a72d874ac4729d6840b3fb00d87724872b8447e..e3df10c03392dcb95c2b3a59d01128e92f174631 100644 |
| --- a/chrome/browser/interstitials/security_interstitial_page.cc |
| +++ b/chrome/browser/interstitials/security_interstitial_page.cc |
| @@ -5,9 +5,13 @@ |
| #include "chrome/browser/interstitials/security_interstitial_page.h" |
| #include "base/i18n/rtl.h" |
| +#include "base/metrics/histogram.h" |
| +#include "base/prefs/pref_service.h" |
| #include "base/strings/utf_string_conversions.h" |
| #include "base/values.h" |
| #include "chrome/browser/browser_process.h" |
| +#include "chrome/browser/profiles/profile.h" |
| +#include "chrome/common/pref_names.h" |
| #include "chrome/grit/browser_resources.h" |
| #include "content/public/browser/interstitial_page.h" |
| #include "content/public/browser/web_contents.h" |
| @@ -15,6 +19,15 @@ |
| #include "ui/base/webui/jstemplate_builder.h" |
| #include "ui/base/webui/web_ui_util.h" |
| +namespace interstitials { |
| +const char kBoxChecked[] = "boxchecked"; |
| +const char kDisplayCheckBox[] = "displaycheckbox"; |
| +const char kOptInLink[] = "optInLink"; |
| +const char kPrivacyLinkHtml[] = |
| + "<a id=\"privacy-link\" href=\"\" onclick=\"sendCommand('showPrivacy'); " |
| + "return false;\" onmousedown=\"return false;\">%s</a>"; |
| +} |
| + |
| SecurityInterstitialPage::SecurityInterstitialPage( |
| content::WebContents* web_contents, |
| const GURL& request_url) |
| @@ -24,6 +37,8 @@ SecurityInterstitialPage::SecurityInterstitialPage( |
| create_view_(true) { |
| // Creating interstitial_page_ without showing it leaks memory, so don't |
| // create it here. |
| + |
| + certificate_report_callback_for_testing_ = base::Bind(&base::DoNothing); |
| } |
| SecurityInterstitialPage::~SecurityInterstitialPage() { |
| @@ -45,6 +60,11 @@ void SecurityInterstitialPage::DontCreateViewForTesting() { |
| create_view_ = false; |
| } |
| +void SecurityInterstitialPage::SetCertificateReportCallbackForTesting( |
| + base::Callback<void()>& callback) { |
| + certificate_report_callback_for_testing_ = callback; |
| +} |
| + |
| void SecurityInterstitialPage::Show() { |
| DCHECK(!interstitial_page_); |
| interstitial_page_ = content::InterstitialPage::Create( |
| @@ -72,3 +92,17 @@ std::string SecurityInterstitialPage::GetHTMLContents() { |
| webui::AppendWebUiCssTextDefaults(&html); |
| return webui::GetI18nTemplateHtml(html, &load_time_data); |
| } |
| + |
| +void SecurityInterstitialPage::SetReportingPreference(bool report) { |
| + Profile* profile = |
| + Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
| + PrefService* pref = profile->GetPrefs(); |
| + pref->SetBoolean(prefs::kSafeBrowsingExtendedReportingEnabled, report); |
|
mattm
2015/03/04 02:58:41
Should kSafeBrowsingExtendedReportingEnabled be re
felt
2015/03/04 03:05:08
The feature is still referred to as Safe Browsing
|
| + UMA_HISTOGRAM_BOOLEAN("SB2.SetExtendedReportingEnabled", report); |
|
mattm
2015/03/04 02:58:41
Similar comment as above. Should we make a new his
felt
2015/03/13 18:52:37
Yes. Now that this is shared code, perhaps we can
|
| +} |
| + |
| +bool SecurityInterstitialPage::IsPrefEnabled(const char* pref) { |
| + Profile* profile = |
| + Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
| + return profile->GetPrefs()->GetBoolean(pref); |
| +} |