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

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

Issue 4822002: Send malware reports when a user opts-in from the safe browsing interstitial ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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
===================================================================
--- chrome/browser/safe_browsing/safe_browsing_blocking_page.cc (revision 65873)
+++ chrome/browser/safe_browsing/safe_browsing_blocking_page.cc (working copy)
@@ -19,12 +19,16 @@
#include "chrome/browser/dom_ui/new_tab_ui.h"
#include "chrome/browser/google/google_util.h"
#include "chrome/browser/metrics/user_metrics.h"
+#include "chrome/browser/profile.h"
+#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/safe_browsing/safe_browsing_service.h"
+#include "chrome/browser/safe_browsing/malware_report.h"
#include "chrome/browser/tab_contents/navigation_controller.h"
#include "chrome/browser/tab_contents/navigation_entry.h"
#include "chrome/browser/tab_contents/tab_util.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/common/jstemplate_builder.h"
+#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "grit/browser_resources.h"
#include "grit/generated_resources.h"
@@ -101,7 +105,8 @@
unsafe_resources[0].url),
sb_service_(sb_service),
is_main_frame_(IsMainPage(unsafe_resources)),
- unsafe_resources_(unsafe_resources) {
+ unsafe_resources_(unsafe_resources),
+ malware_report_(NULL) {
RecordUserAction(SHOW);
if (!is_main_frame_) {
navigation_entry_index_to_remove_ =
@@ -109,6 +114,15 @@
} else {
navigation_entry_index_to_remove_ = -1;
}
+
+ // Start computing an advanced malware report. It will be sent only
+ // if the user opts-in on the blocking page later.
+ if (unsafe_resources.size() == 1 &&
+ unsafe_resources[0].threat_type == SafeBrowsingService::URL_MALWARE &&
+ malware_report_ == NULL &&
+ !tab()->profile()->IsOffTheRecord()) {
+ malware_report_ = new SafeBrowsingMalwareReport(tab(), unsafe_resources[0]);
+ }
}
SafeBrowsingBlockingPage::~SafeBrowsingBlockingPage() {
@@ -390,6 +404,7 @@
void SafeBrowsingBlockingPage::Proceed() {
RecordUserAction(PROCEED);
+ FinishMalwareReport(); // Send the malware report, if we opted to.
NotifySafeBrowsingService(sb_service_, unsafe_resources_, true);
@@ -427,6 +442,7 @@
}
RecordUserAction(DONT_PROCEED);
+ FinishMalwareReport(); // Send the malware report, if we opted to.
NotifySafeBrowsingService(sb_service_, unsafe_resources_, false);
@@ -492,6 +508,28 @@
UserMetrics::RecordComputedAction(action);
}
+void SafeBrowsingBlockingPage::FinishMalwareReport() {
+ if (malware_report_ == NULL) {
+ // Not all interstitials have reports (eg phishing).
+ return;
+ }
+
+ // Q: Reading from the preference -- should it happen in another thread?
lzheng 2010/11/16 00:18:12 It has to be called on the same thread where pref
panayiotis 2010/11/18 22:04:37 thanks.
+ const PrefService::Preference* pref =
+ tab()->profile()->GetPrefs()->FindPreference(
+ prefs::kSafeBrowsingMalwareReportsEnabled);
+
+ bool value;
+ if (pref && pref->GetValue()->GetAsBoolean(&value) && value) {
+ // Give the report object to the service class, so it can send it.
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ NewRunnableMethod(
+ sb_service_, &SafeBrowsingService::SendMalwareReport,
+ malware_report_));
+ }
+}
+
// static
void SafeBrowsingBlockingPage::NotifySafeBrowsingService(
SafeBrowsingService* sb_service,

Powered by Google App Engine
This is Rietveld 408576698