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

Unified Diff: chrome/browser/safe_browsing/safe_browsing_blocking_page.cc

Issue 10694037: Add a policy to disable proceeding through the Safe Browsing interstitials. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixed <button>/jstemplate Created 8 years, 6 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
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 1e9f7be9634f14030a2c7b3b343d743f1cbc85aa..fca41dfc0595a710f4d42595d0336123a2c50b3f 100644
--- a/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc
@@ -231,6 +231,8 @@ void SafeBrowsingBlockingPage::PopulateStringDictionary(
strings->SetString("description1", description1);
strings->SetString("description2", description2);
strings->SetString("description3", description3);
+ strings->SetBoolean("proceedDisabled",
+ IsPrefEnabled(prefs::kSafeBrowsingProceedAnywayDisabled));
}
void SafeBrowsingBlockingPage::PopulateMultipleThreatStringDictionary(
@@ -380,19 +382,10 @@ void SafeBrowsingBlockingPage::PopulateMalwareStringDictionary(
l10n_util::GetStringFUTF16(
IDS_SAFE_BROWSING_MALWARE_REPORTING_AGREE,
UTF8ToUTF16(privacy_link)));
-
- Profile* profile = Profile::FromBrowserContext(
- web_contents_->GetBrowserContext());
- const PrefService::Preference* pref =
- profile->GetPrefs()->FindPreference(
- prefs::kSafeBrowsingReportingEnabled);
-
- bool value;
- if (pref && pref->GetValue()->GetAsBoolean(&value) && value) {
+ if (IsPrefEnabled(prefs::kSafeBrowsingReportingEnabled))
strings->SetString(kBoxChecked, "yes");
- } else {
+ else
strings->SetString(kBoxChecked, "");
- }
}
}
@@ -468,18 +461,23 @@ void SafeBrowsingBlockingPage::CommandReceived(const std::string& cmd) {
return;
}
+ bool proceed_blocked = false;
if (command == kProceedCommand) {
- interstitial_page_->Proceed();
- // We are deleted after this.
- return;
+ if (IsPrefEnabled(prefs::kSafeBrowsingProceedAnywayDisabled)) {
+ proceed_blocked = true;
+ } else {
+ interstitial_page_->Proceed();
+ // |this| has been deleted after Proceed() returns.
+ return;
+ }
}
- if (command == kTakeMeBackCommand) {
+ if (command == kTakeMeBackCommand || proceed_blocked) {
if (is_main_frame_load_blocked_) {
// If the load is blocked, we want to close the interstitial and discard
// the pending entry.
interstitial_page_->DontProceed();
- // We are deleted after this.
+ // |this| has been deleted after DontProceed() returns.
return;
}
@@ -680,13 +678,7 @@ void SafeBrowsingBlockingPage::FinishMalwareDetails(int64 delay_ms) {
if (malware_details_ == NULL)
return; // Not all interstitials have malware details (eg phishing).
- Profile* profile = Profile::FromBrowserContext(
- web_contents_->GetBrowserContext());
- const PrefService::Preference* pref =
- profile->GetPrefs()->FindPreference(prefs::kSafeBrowsingReportingEnabled);
-
- bool value;
- if (pref && pref->GetValue()->GetAsBoolean(&value) && value) {
+ if (IsPrefEnabled(prefs::kSafeBrowsingReportingEnabled)) {
// Finish the malware details collection, send it over.
BrowserThread::PostDelayedTask(
BrowserThread::IO, FROM_HERE,
@@ -695,6 +687,12 @@ void SafeBrowsingBlockingPage::FinishMalwareDetails(int64 delay_ms) {
}
}
+bool SafeBrowsingBlockingPage::IsPrefEnabled(const char* pref) {
+ Profile* profile =
+ Profile::FromBrowserContext(web_contents_->GetBrowserContext());
+ return profile->GetPrefs()->GetBoolean(pref);
+}
+
// static
void SafeBrowsingBlockingPage::NotifySafeBrowsingService(
SafeBrowsingService* sb_service,

Powered by Google App Engine
This is Rietveld 408576698