Chromium Code Reviews| 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 |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 41 #include "chrome/browser/safe_browsing/download_feedback_service.h" | 41 #include "chrome/browser/safe_browsing/download_feedback_service.h" |
| 42 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 42 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 43 #include "chrome/browser/safe_browsing/sandboxed_zip_analyzer.h" | 43 #include "chrome/browser/safe_browsing/sandboxed_zip_analyzer.h" |
| 44 #include "chrome/browser/sessions/session_tab_helper.h" | 44 #include "chrome/browser/sessions/session_tab_helper.h" |
| 45 #include "chrome/browser/ui/browser.h" | 45 #include "chrome/browser/ui/browser.h" |
| 46 #include "chrome/browser/ui/browser_list.h" | 46 #include "chrome/browser/ui/browser_list.h" |
| 47 #include "chrome/common/pref_names.h" | 47 #include "chrome/common/pref_names.h" |
| 48 #include "chrome/common/safe_browsing/binary_feature_extractor.h" | 48 #include "chrome/common/safe_browsing/binary_feature_extractor.h" |
| 49 #include "chrome/common/safe_browsing/download_protection_util.h" | 49 #include "chrome/common/safe_browsing/download_protection_util.h" |
| 50 #include "chrome/common/safe_browsing/file_type_policies.h" | 50 #include "chrome/common/safe_browsing/file_type_policies.h" |
| 51 #include "chrome/common/safe_browsing/zip_analyzer_results.h" | |
|
vakh (use Gerrit instead)
2017/05/23 17:34:30
Please #include the new file.
You don't want to de
mortonm
2017/05/23 17:53:51
Done.
| |
| 52 #include "chrome/common/url_constants.h" | 51 #include "chrome/common/url_constants.h" |
| 53 #include "components/data_use_measurement/core/data_use_user_data.h" | 52 #include "components/data_use_measurement/core/data_use_user_data.h" |
| 54 #include "components/google/core/browser/google_util.h" | 53 #include "components/google/core/browser/google_util.h" |
| 55 #include "components/history/core/browser/history_service.h" | 54 #include "components/history/core/browser/history_service.h" |
| 56 #include "components/prefs/pref_service.h" | 55 #include "components/prefs/pref_service.h" |
| 57 #include "components/safe_browsing/common/safe_browsing_prefs.h" | 56 #include "components/safe_browsing/common/safe_browsing_prefs.h" |
| 58 #include "components/safe_browsing/common/safebrowsing_switches.h" | 57 #include "components/safe_browsing/common/safebrowsing_switches.h" |
| 59 #include "components/safe_browsing/csd.pb.h" | 58 #include "components/safe_browsing/csd.pb.h" |
| 60 #include "content/public/browser/browser_thread.h" | 59 #include "content/public/browser/browser_thread.h" |
| 61 #include "content/public/browser/download_item.h" | 60 #include "content/public/browser/download_item.h" |
| (...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 713 zip_analysis_start_time_ = base::TimeTicks::Now(); | 712 zip_analysis_start_time_ = base::TimeTicks::Now(); |
| 714 // We give the zip analyzer a weak pointer to this object. Since the | 713 // We give the zip analyzer a weak pointer to this object. Since the |
| 715 // analyzer is refcounted, it might outlive the request. | 714 // analyzer is refcounted, it might outlive the request. |
| 716 analyzer_ = new SandboxedZipAnalyzer( | 715 analyzer_ = new SandboxedZipAnalyzer( |
| 717 item_->GetFullPath(), | 716 item_->GetFullPath(), |
| 718 base::Bind(&CheckClientDownloadRequest::OnZipAnalysisFinished, | 717 base::Bind(&CheckClientDownloadRequest::OnZipAnalysisFinished, |
| 719 weakptr_factory_.GetWeakPtr())); | 718 weakptr_factory_.GetWeakPtr())); |
| 720 analyzer_->Start(); | 719 analyzer_->Start(); |
| 721 } | 720 } |
| 722 | 721 |
| 723 void OnZipAnalysisFinished(const zip_analyzer::Results& results) { | 722 void OnZipAnalysisFinished(const ArchiveAnalyzerResults& results) { |
| 724 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 723 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 725 DCHECK_EQ(ClientDownloadRequest::ZIPPED_EXECUTABLE, type_); | 724 DCHECK_EQ(ClientDownloadRequest::ZIPPED_EXECUTABLE, type_); |
| 726 if (!service_) | 725 if (!service_) |
| 727 return; | 726 return; |
| 728 | 727 |
| 729 // Even if !results.success, some of the zip may have been parsed. | 728 // Even if !results.success, some of the zip may have been parsed. |
| 730 // Some unzippers will successfully unpack archives that we cannot, | 729 // Some unzippers will successfully unpack archives that we cannot, |
| 731 // so we're lenient here. | 730 // so we're lenient here. |
| 732 archive_is_valid_ = | 731 archive_is_valid_ = |
| 733 (results.success ? ArchiveValid::VALID : ArchiveValid::INVALID); | 732 (results.success ? ArchiveValid::VALID : ArchiveValid::INVALID); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 772 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 771 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 773 DCHECK(item_); | 772 DCHECK(item_); |
| 774 dmg_analyzer_ = new SandboxedDMGAnalyzer( | 773 dmg_analyzer_ = new SandboxedDMGAnalyzer( |
| 775 item_->GetFullPath(), | 774 item_->GetFullPath(), |
| 776 base::Bind(&CheckClientDownloadRequest::OnDmgAnalysisFinished, | 775 base::Bind(&CheckClientDownloadRequest::OnDmgAnalysisFinished, |
| 777 weakptr_factory_.GetWeakPtr())); | 776 weakptr_factory_.GetWeakPtr())); |
| 778 dmg_analyzer_->Start(); | 777 dmg_analyzer_->Start(); |
| 779 dmg_analysis_start_time_ = base::TimeTicks::Now(); | 778 dmg_analysis_start_time_ = base::TimeTicks::Now(); |
| 780 } | 779 } |
| 781 | 780 |
| 782 void OnDmgAnalysisFinished(const zip_analyzer::Results& results) { | 781 void OnDmgAnalysisFinished(const ArchiveAnalyzerResults& results) { |
| 783 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 782 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 784 DCHECK_EQ(ClientDownloadRequest::MAC_EXECUTABLE, type_); | 783 DCHECK_EQ(ClientDownloadRequest::MAC_EXECUTABLE, type_); |
| 785 if (!service_) | 784 if (!service_) |
| 786 return; | 785 return; |
| 787 | 786 |
| 788 // Even if !results.success, some of the DMG may have been parsed. | 787 // Even if !results.success, some of the DMG may have been parsed. |
| 789 archive_is_valid_ = | 788 archive_is_valid_ = |
| 790 (results.success ? ArchiveValid::VALID : ArchiveValid::INVALID); | 789 (results.success ? ArchiveValid::VALID : ArchiveValid::INVALID); |
| 791 archived_executable_ = results.has_executable; | 790 archived_executable_ = results.has_executable; |
| 792 archived_binary_.CopyFrom(results.archived_binary); | 791 archived_binary_.CopyFrom(results.archived_binary); |
| (...skipping 1198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1991 out_request->mutable_referrer_chain()); | 1990 out_request->mutable_referrer_chain()); |
| 1992 UMA_HISTOGRAM_COUNTS_100( | 1991 UMA_HISTOGRAM_COUNTS_100( |
| 1993 "SafeBrowsing.ReferrerURLChainSize.PPAPIDownloadAttribution", | 1992 "SafeBrowsing.ReferrerURLChainSize.PPAPIDownloadAttribution", |
| 1994 out_request->referrer_chain_size()); | 1993 out_request->referrer_chain_size()); |
| 1995 UMA_HISTOGRAM_ENUMERATION( | 1994 UMA_HISTOGRAM_ENUMERATION( |
| 1996 "SafeBrowsing.ReferrerAttributionResult.PPAPIDownloadAttribution", result, | 1995 "SafeBrowsing.ReferrerAttributionResult.PPAPIDownloadAttribution", result, |
| 1997 SafeBrowsingNavigationObserverManager::ATTRIBUTION_FAILURE_TYPE_MAX); | 1996 SafeBrowsingNavigationObserverManager::ATTRIBUTION_FAILURE_TYPE_MAX); |
| 1998 } | 1997 } |
| 1999 | 1998 |
| 2000 } // namespace safe_browsing | 1999 } // namespace safe_browsing |
| OLD | NEW |