OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 5 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 | 233 |
234 // Only report SafeBrowsing related stats when UMA is enabled. User must also | 234 // Only report SafeBrowsing related stats when UMA is enabled. User must also |
235 // ensure that safe browsing is enabled from the calling profile. | 235 // ensure that safe browsing is enabled from the calling profile. |
236 bool SafeBrowsingService::CanReportStats() const { | 236 bool SafeBrowsingService::CanReportStats() const { |
237 const MetricsService* metrics = g_browser_process->metrics_service(); | 237 const MetricsService* metrics = g_browser_process->metrics_service(); |
238 return metrics && metrics->reporting_active(); | 238 return metrics && metrics->reporting_active(); |
239 } | 239 } |
240 | 240 |
241 // Binhash verification is only enabled for UMA users for now. | 241 // Binhash verification is only enabled for UMA users for now. |
242 bool SafeBrowsingService::DownloadBinHashNeeded() const { | 242 bool SafeBrowsingService::DownloadBinHashNeeded() const { |
243 return enable_download_protection_ && CanReportStats(); | 243 return (enable_download_protection_ && CanReportStats()) || |
| 244 (download_protection_service() && |
| 245 download_protection_service()->enabled()); |
244 } | 246 } |
245 | 247 |
246 bool SafeBrowsingService::CheckDownloadUrl(const std::vector<GURL>& url_chain, | 248 bool SafeBrowsingService::CheckDownloadUrl(const std::vector<GURL>& url_chain, |
247 Client* client) { | 249 Client* client) { |
248 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 250 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
249 if (!enabled_ || !enable_download_protection_) | 251 if (!enabled_ || !enable_download_protection_) |
250 return true; | 252 return true; |
251 | 253 |
252 // We need to check the database for url prefix, and later may fetch the url | 254 // We need to check the database for url prefix, and later may fetch the url |
253 // from the safebrowsing backends. These need to be asynchronous. | 255 // from the safebrowsing backends. These need to be asynchronous. |
(...skipping 1092 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1346 Stop(); | 1348 Stop(); |
1347 | 1349 |
1348 if (csd_service_.get()) | 1350 if (csd_service_.get()) |
1349 csd_service_->SetEnabledAndRefreshState(enable); | 1351 csd_service_->SetEnabledAndRefreshState(enable); |
1350 if (download_service_.get()) { | 1352 if (download_service_.get()) { |
1351 download_service_->SetEnabled( | 1353 download_service_->SetEnabled( |
1352 enable && !CommandLine::ForCurrentProcess()->HasSwitch( | 1354 enable && !CommandLine::ForCurrentProcess()->HasSwitch( |
1353 switches::kDisableImprovedDownloadProtection)); | 1355 switches::kDisableImprovedDownloadProtection)); |
1354 } | 1356 } |
1355 } | 1357 } |
OLD | NEW |