Index: chrome/browser/safe_browsing/safe_browsing_blocking_page.cc |
diff --git a/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc b/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc |
index 1fe998e56aa5859ecd2669fa1eb232a42db569e3..8f4323f4b2f1e74f779f9830cd5ead83fad6ec53 100644 |
--- a/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc |
+++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc |
@@ -68,20 +68,12 @@ const char kLearnMoreMalwareUrlV2[] = |
const char kLearnMorePhishingUrlV2[] = |
"https://www.google.com/transparencyreport/safebrowsing/"; |
-const char kPrivacyLinkHtml[] = |
- "<a id=\"privacy-link\" href=\"\" onclick=\"sendCommand(%d); " |
- "return false;\" onmousedown=\"return false;\">%s</a>"; |
- |
// After a malware interstitial where the user opted-in to the report |
// but clicked "proceed anyway", we delay the call to |
// MalwareDetails::FinishCollection() by this much time (in |
// milliseconds). |
const int64 kMalwareDetailsProceedDelayMilliSeconds = 3000; |
-// Other constants used to communicate with the JavaScript. |
-const char kBoxChecked[] = "boxchecked"; |
-const char kDisplayCheckBox[] = "displaycheckbox"; |
- |
// Constants for the Experience Sampling instrumentation. |
const char kEventNameMalware[] = "safebrowsing_interstitial_"; |
const char kEventNameHarmful[] = "harmful_interstitial_"; |
@@ -248,18 +240,7 @@ void SafeBrowsingBlockingPage::CommandReceived(const std::string& page_cmd) { |
} |
case CMD_OPEN_REPORTING_PRIVACY: { |
// User pressed on the SB Extended Reporting "privacy policy" link. |
- 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); |
+ OpenExtendedReportingPrivacyPolicy(); |
break; |
} |
case CMD_PROCEED: { |
@@ -339,14 +320,6 @@ void SafeBrowsingBlockingPage::OverrideRendererPrefs( |
prefs, profile, web_contents()); |
} |
-void SafeBrowsingBlockingPage::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); |
-} |
- |
void SafeBrowsingBlockingPage::OnProceed() { |
proceeded_ = true; |
// Send the malware details, if we opted to. |
@@ -431,20 +404,17 @@ void SafeBrowsingBlockingPage::FinishMalwareDetails(int64 delay_ms) { |
const bool enabled = |
IsPrefEnabled(prefs::kSafeBrowsingExtendedReportingEnabled); |
- UMA_HISTOGRAM_BOOLEAN("SB2.ExtendedReportingIsEnabled", enabled); |
- if (enabled) { |
- // Finish the malware details collection, send it over. |
- BrowserThread::PostDelayedTask( |
- BrowserThread::IO, FROM_HERE, |
- base::Bind(&MalwareDetails::FinishCollection, malware_details_.get()), |
- base::TimeDelta::FromMilliseconds(delay_ms)); |
- } |
-} |
+ if (!enabled) |
+ return; |
-bool SafeBrowsingBlockingPage::IsPrefEnabled(const char* pref) { |
- Profile* profile = |
- Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
- return profile->GetPrefs()->GetBoolean(pref); |
+ metrics_helper_->RecordUserInteraction( |
+ SecurityInterstitialMetricsHelper:: |
+ EXTENDED_REPORTING_IS_ENABLED_SAFE_BROWSING); |
+ // Finish the malware details collection, send it over. |
+ BrowserThread::PostDelayedTask( |
+ BrowserThread::IO, FROM_HERE, |
+ base::Bind(&MalwareDetails::FinishCollection, malware_details_.get()), |
+ base::TimeDelta::FromMilliseconds(delay_ms)); |
} |
// static |
@@ -588,21 +558,19 @@ void SafeBrowsingBlockingPage::PopulateExtendedReportingOption( |
base::DictionaryValue* load_time_data) { |
// Only show checkbox if !(HTTPS || incognito-mode). |
const bool show = CanShowMalwareDetailsOption(); |
- load_time_data->SetBoolean(kDisplayCheckBox, show); |
+ load_time_data->SetBoolean(interstitials::kDisplayCheckBox, show); |
if (!show) |
return; |
const std::string privacy_link = base::StringPrintf( |
- kPrivacyLinkHtml, |
- CMD_OPEN_REPORTING_PRIVACY, |
- l10n_util::GetStringUTF8( |
- IDS_SAFE_BROWSING_PRIVACY_POLICY_PAGE).c_str()); |
+ interstitials::kPrivacyLinkHtml, CMD_OPEN_REPORTING_PRIVACY, |
+ l10n_util::GetStringUTF8(IDS_SAFE_BROWSING_PRIVACY_POLICY_PAGE).c_str()); |
load_time_data->SetString( |
- "optInLink", |
+ interstitials::kOptInLink, |
l10n_util::GetStringFUTF16(IDS_SAFE_BROWSING_MALWARE_REPORTING_AGREE, |
base::UTF8ToUTF16(privacy_link))); |
load_time_data->SetBoolean( |
- kBoxChecked, |
+ interstitials::kBoxChecked, |
IsPrefEnabled(prefs::kSafeBrowsingExtendedReportingEnabled)); |
} |