| Index: chrome/browser/safe_browsing/safe_browsing_blocking_page.cc
|
| ===================================================================
|
| --- chrome/browser/safe_browsing/safe_browsing_blocking_page.cc (revision 66642)
|
| +++ 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/prefs/pref_service.h"
|
| +#include "chrome/browser/profile.h"
|
| +#include "chrome/browser/safe_browsing/malware_report.h"
|
| #include "chrome/browser/safe_browsing/safe_browsing_service.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,8 +114,25 @@
|
| } else {
|
| navigation_entry_index_to_remove_ = -1;
|
| }
|
| +
|
| + // Start computing a detailed malware report. It will be sent only
|
| + // if the user opts-in on the blocking page later.
|
| + // If there's more than one malicious resources, it means the user
|
| + // clicked through the first warning, so we don't prepare additional
|
| + // reports.
|
| + if (unsafe_resources.size() == 1 &&
|
| + unsafe_resources[0].threat_type == SafeBrowsingService::URL_MALWARE &&
|
| + malware_report_ == NULL &&
|
| + CanShowMalwareReportOption()) {
|
| + malware_report_ = new SafeBrowsingMalwareReport(tab(), unsafe_resources[0]);
|
| + }
|
| }
|
|
|
| +bool SafeBrowsingBlockingPage::CanShowMalwareReportOption() {
|
| + return (!tab()->profile()->IsOffTheRecord() &&
|
| + tab()->GetURL().SchemeIs(chrome::kHttpScheme));
|
| +}
|
| +
|
| SafeBrowsingBlockingPage::~SafeBrowsingBlockingPage() {
|
| }
|
|
|
| @@ -390,6 +412,7 @@
|
|
|
| void SafeBrowsingBlockingPage::Proceed() {
|
| RecordUserAction(PROCEED);
|
| + FinishMalwareReport(); // Send the malware report, if we opted to.
|
|
|
| NotifySafeBrowsingService(sb_service_, unsafe_resources_, true);
|
|
|
| @@ -427,6 +450,7 @@
|
| }
|
|
|
| RecordUserAction(DONT_PROCEED);
|
| + FinishMalwareReport(); // Send the malware report, if we opted to.
|
|
|
| NotifySafeBrowsingService(sb_service_, unsafe_resources_, false);
|
|
|
| @@ -492,6 +516,27 @@
|
| UserMetrics::RecordComputedAction(action);
|
| }
|
|
|
| +void SafeBrowsingBlockingPage::FinishMalwareReport() {
|
| + if (malware_report_ == NULL) {
|
| + // Not all interstitials have reports (eg phishing).
|
| + return;
|
| + }
|
| +
|
| + const PrefService::Preference* pref =
|
| + tab()->profile()->GetPrefs()->FindPreference(
|
| + prefs::kSafeBrowsingReportingEnabled);
|
| +
|
| + 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,
|
|
|