OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/download_protection_service.h" | 5 #include "chrome/browser/safe_browsing/download_protection_service.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/callback_helpers.h" | 12 #include "base/callback_helpers.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
15 #include "base/format_macros.h" | 15 #include "base/format_macros.h" |
16 #include "base/macros.h" | 16 #include "base/macros.h" |
| 17 #include "base/memory/ptr_util.h" |
17 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
18 #include "base/metrics/field_trial.h" | 19 #include "base/metrics/field_trial.h" |
19 #include "base/metrics/histogram_macros.h" | 20 #include "base/metrics/histogram_macros.h" |
20 #include "base/metrics/sparse_histogram.h" | 21 #include "base/metrics/sparse_histogram.h" |
21 #include "base/rand_util.h" | 22 #include "base/rand_util.h" |
22 #include "base/scoped_observer.h" | 23 #include "base/scoped_observer.h" |
23 #include "base/sequenced_task_runner_helpers.h" | 24 #include "base/sequenced_task_runner_helpers.h" |
24 #include "base/sha1.h" | 25 #include "base/sha1.h" |
25 #include "base/stl_util.h" | 26 #include "base/stl_util.h" |
26 #include "base/strings/string_number_conversions.h" | 27 #include "base/strings/string_number_conversions.h" |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled(); | 294 ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled(); |
294 | 295 |
295 ui_manager_->MaybeReportSafeBrowsingHit(hit_report); | 296 ui_manager_->MaybeReportSafeBrowsingHit(hit_report); |
296 } | 297 } |
297 | 298 |
298 void IdentifyReferrerChain() { | 299 void IdentifyReferrerChain() { |
299 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 300 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
300 if (!item_) | 301 if (!item_) |
301 return; | 302 return; |
302 | 303 |
303 item_->SetUserData(kDownloadReferrerChainDataKey, | 304 item_->SetUserData( |
304 new ReferrerChainData( | 305 kDownloadReferrerChainDataKey, |
305 service_->IdentifyReferrerChain( | 306 base::MakeUnique<ReferrerChainData>(service_->IdentifyReferrerChain( |
306 item_->GetURL(), item_->GetWebContents()))); | 307 item_->GetURL(), item_->GetWebContents()))); |
307 } | 308 } |
308 | 309 |
309 void UpdateDownloadCheckStats(SBStatsType stat_type) { | 310 void UpdateDownloadCheckStats(SBStatsType stat_type) { |
310 UMA_HISTOGRAM_ENUMERATION("SB2.DownloadChecks", | 311 UMA_HISTOGRAM_ENUMERATION("SB2.DownloadChecks", |
311 stat_type, | 312 stat_type, |
312 DOWNLOAD_CHECKS_MAX); | 313 DOWNLOAD_CHECKS_MAX); |
313 } | 314 } |
314 | 315 |
315 // The DownloadItem we are checking. Must be accessed only on UI thread. | 316 // The DownloadItem we are checking. Must be accessed only on UI thread. |
316 content::DownloadItem* item_; | 317 content::DownloadItem* item_; |
(...skipping 1518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1835 learn_more_url, "ctx", | 1836 learn_more_url, "ctx", |
1836 base::IntToString(static_cast<int>(item.GetDangerType()))); | 1837 base::IntToString(static_cast<int>(item.GetDangerType()))); |
1837 navigator->OpenURL( | 1838 navigator->OpenURL( |
1838 content::OpenURLParams(learn_more_url, content::Referrer(), | 1839 content::OpenURLParams(learn_more_url, content::Referrer(), |
1839 WindowOpenDisposition::NEW_FOREGROUND_TAB, | 1840 WindowOpenDisposition::NEW_FOREGROUND_TAB, |
1840 ui::PAGE_TRANSITION_LINK, false)); | 1841 ui::PAGE_TRANSITION_LINK, false)); |
1841 } | 1842 } |
1842 | 1843 |
1843 void DownloadProtectionService::SetDownloadPingToken( | 1844 void DownloadProtectionService::SetDownloadPingToken( |
1844 content::DownloadItem* item, const std::string& token) { | 1845 content::DownloadItem* item, const std::string& token) { |
1845 if (item) | 1846 if (item) { |
1846 item->SetUserData(kDownloadPingTokenKey, new DownloadPingToken(token)); | 1847 item->SetUserData(kDownloadPingTokenKey, |
| 1848 base::MakeUnique<DownloadPingToken>(token)); |
| 1849 } |
1847 } | 1850 } |
1848 | 1851 |
1849 std::string DownloadProtectionService::GetDownloadPingToken( | 1852 std::string DownloadProtectionService::GetDownloadPingToken( |
1850 const content::DownloadItem* item) { | 1853 const content::DownloadItem* item) { |
1851 base::SupportsUserData::Data* token_data = | 1854 base::SupportsUserData::Data* token_data = |
1852 item->GetUserData(kDownloadPingTokenKey); | 1855 item->GetUserData(kDownloadPingTokenKey); |
1853 if (token_data) | 1856 if (token_data) |
1854 return static_cast<DownloadPingToken*>(token_data)->token_string(); | 1857 return static_cast<DownloadPingToken*>(token_data)->token_string(); |
1855 else | 1858 else |
1856 return std::string(); | 1859 return std::string(); |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2001 UMA_HISTOGRAM_COUNTS_100( | 2004 UMA_HISTOGRAM_COUNTS_100( |
2002 "SafeBrowsing.ReferrerURLChainSize.PPAPIDownloadAttribution", | 2005 "SafeBrowsing.ReferrerURLChainSize.PPAPIDownloadAttribution", |
2003 out_request->referrer_chain_size()); | 2006 out_request->referrer_chain_size()); |
2004 UMA_HISTOGRAM_ENUMERATION( | 2007 UMA_HISTOGRAM_ENUMERATION( |
2005 "SafeBrowsing.ReferrerAttributionResult.PPAPIDownloadAttribution", result, | 2008 "SafeBrowsing.ReferrerAttributionResult.PPAPIDownloadAttribution", result, |
2006 SafeBrowsingNavigationObserverManager::ATTRIBUTION_FAILURE_TYPE_MAX); | 2009 SafeBrowsingNavigationObserverManager::ATTRIBUTION_FAILURE_TYPE_MAX); |
2007 out_request->set_download_attribution_finch_enabled(true); | 2010 out_request->set_download_attribution_finch_enabled(true); |
2008 } | 2011 } |
2009 | 2012 |
2010 } // namespace safe_browsing | 2013 } // namespace safe_browsing |
OLD | NEW |