#include "base/threading/thread_restrictions.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/safe_browsing/malware_details.h"
+#include "chrome/browser/safe_browsing/metadata.pb.h"
#include "chrome/browser/safe_browsing/ping_manager.h"
#include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h"
#include "chrome/browser/safe_browsing/safe_browsing_service.h"
// Only report SafeBrowsing related stats when UMA is enabled. User must also
// ensure that safe browsing is enabled from the calling profile.
bool SafeBrowsingUIManager::CanReportStats() const {
- const MetricsService* metrics = g_browser_process->metrics_service();
+ const metrics::MetricsService* metrics = g_browser_process->metrics_service();
return metrics && metrics->reporting_active();
}
const UnsafeResource& resource) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ if (!resource.threat_metadata.empty() &&
+ resource.threat_type == SB_THREAT_TYPE_URL_MALWARE) {
+ safe_browsing::MalwarePatternType proto;
+ // Malware sites tagged as "landing site" should only show a warning for a
+ // main-frame or sub-frame resource. (See "Types of Malware sites" under
+ // https://developers.google.com/safe-browsing/developers_guide_v3#UserWarnings)
+ if (proto.ParseFromString(resource.threat_metadata) &&
+ proto.pattern_type() == safe_browsing::MalwarePatternType::LANDING &&
+ resource.is_subresource && !resource.is_subframe) {
+ if (!resource.callback.is_null()) {
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE, base::Bind(resource.callback, true));
+ }
+ return;
+ }
+ }
+
// Indicate to interested observers that the resource in question matched the
// SB filters. If the resource is already whitelisted, OnSafeBrowsingHit
// won't be called.