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..2e891cfeb009d5e4bdf29a1829ae337cf795f203 100644 |
--- a/chrome/browser/interstitials/security_interstitial_page.cc |
+++ b/chrome/browser/interstitials/security_interstitial_page.cc |
@@ -5,16 +5,38 @@ |
#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/interstitials/security_interstitial_metrics_helper.h" |
+#include "chrome/browser/net/referrer.h" |
+#include "chrome/browser/profiles/profile.h" |
+#include "chrome/common/pref_names.h" |
#include "chrome/grit/browser_resources.h" |
+#include "chrome/grit/generated_resources.h" |
+#include "components/google/core/browser/google_util.h" |
#include "content/public/browser/interstitial_page.h" |
+#include "content/public/browser/page_navigator.h" |
#include "content/public/browser/web_contents.h" |
+#include "ui/base/l10n/l10n_util.h" |
#include "ui/base/resource/resource_bundle.h" |
#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(%d); " |
+ "return false;\" onmousedown=\"return false;\">%s</a>"; |
+} |
+ |
+using content::OpenURLParams; |
+using content::Referrer; |
+ |
SecurityInterstitialPage::SecurityInterstitialPage( |
content::WebContents* web_contents, |
const GURL& request_url) |
@@ -45,6 +67,11 @@ void SecurityInterstitialPage::DontCreateViewForTesting() { |
create_view_ = false; |
} |
+void SecurityInterstitialPage::SetCertificateReportCallbackForTesting( |
+ const base::Closure& callback) { |
+ certificate_report_callback_for_testing_ = callback; |
+} |
+ |
void SecurityInterstitialPage::Show() { |
DCHECK(!interstitial_page_); |
interstitial_page_ = content::InterstitialPage::Create( |
@@ -54,6 +81,32 @@ void SecurityInterstitialPage::Show() { |
interstitial_page_->Show(); |
} |
+void SecurityInterstitialPage::SetReportingPreference(bool report) { |
+ Profile* profile = |
+ Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
+ PrefService* pref = profile->GetPrefs(); |
+ pref->SetBoolean(prefs::kSafeBrowsingExtendedReportingEnabled, report); |
+ UMA_HISTOGRAM_BOOLEAN("SB2.SetExtendedReportingEnabled", report); |
+} |
+ |
+bool SecurityInterstitialPage::IsPrefEnabled(const char* pref) { |
+ Profile* profile = |
+ Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
+ return profile->GetPrefs()->GetBoolean(pref); |
+} |
+ |
+void SecurityInterstitialPage::OpenExtendedReportingPrivacyPolicy() { |
+ metrics_helper_->RecordUserInteraction( |
+ SecurityInterstitialMetricsHelper::SHOW_PRIVACY_POLICY); |
+ GURL privacy_url( |
+ l10n_util::GetStringUTF8(IDS_SAFE_BROWSING_PRIVACY_POLICY_URL)); |
+ privacy_url = google_util::AppendGoogleLocaleParam( |
+ privacy_url, g_browser_process->GetApplicationLocale()); |
+ OpenURLParams params(privacy_url, Referrer(), CURRENT_TAB, |
+ ui::PAGE_TRANSITION_LINK, false); |
+ web_contents()->OpenURL(params); |
+} |
+ |
base::string16 SecurityInterstitialPage::GetFormattedHostName() const { |
base::string16 host(base::UTF8ToUTF16(request_url_.host())); |
if (base::i18n::IsRTL()) |