| 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 22 matching lines...) Expand all Loading... |
| 33 #include "chrome/browser/browser_process.h" | 33 #include "chrome/browser/browser_process.h" |
| 34 #include "chrome/browser/history/history_service_factory.h" | 34 #include "chrome/browser/history/history_service_factory.h" |
| 35 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" | 35 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" |
| 36 #include "chrome/browser/profiles/profile.h" | 36 #include "chrome/browser/profiles/profile.h" |
| 37 #include "chrome/browser/profiles/profile_manager.h" | 37 #include "chrome/browser/profiles/profile_manager.h" |
| 38 #include "chrome/browser/safe_browsing/download_feedback_service.h" | 38 #include "chrome/browser/safe_browsing/download_feedback_service.h" |
| 39 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 39 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 40 #include "chrome/browser/safe_browsing/sandboxed_zip_analyzer.h" | 40 #include "chrome/browser/safe_browsing/sandboxed_zip_analyzer.h" |
| 41 #include "chrome/browser/ui/browser.h" | 41 #include "chrome/browser/ui/browser.h" |
| 42 #include "chrome/browser/ui/browser_list.h" | 42 #include "chrome/browser/ui/browser_list.h" |
| 43 #include "chrome/common/chrome_switches.h" | |
| 44 #include "chrome/common/pref_names.h" | 43 #include "chrome/common/pref_names.h" |
| 45 #include "chrome/common/safe_browsing/binary_feature_extractor.h" | 44 #include "chrome/common/safe_browsing/binary_feature_extractor.h" |
| 46 #include "chrome/common/safe_browsing/csd.pb.h" | 45 #include "chrome/common/safe_browsing/csd.pb.h" |
| 47 #include "chrome/common/safe_browsing/download_protection_util.h" | 46 #include "chrome/common/safe_browsing/download_protection_util.h" |
| 48 #include "chrome/common/safe_browsing/file_type_policies.h" | 47 #include "chrome/common/safe_browsing/file_type_policies.h" |
| 49 #include "chrome/common/safe_browsing/zip_analyzer_results.h" | 48 #include "chrome/common/safe_browsing/zip_analyzer_results.h" |
| 50 #include "chrome/common/url_constants.h" | 49 #include "chrome/common/url_constants.h" |
| 51 #include "components/data_use_measurement/core/data_use_user_data.h" | 50 #include "components/data_use_measurement/core/data_use_user_data.h" |
| 52 #include "components/google/core/browser/google_util.h" | 51 #include "components/google/core/browser/google_util.h" |
| 53 #include "components/history/core/browser/history_service.h" | 52 #include "components/history/core/browser/history_service.h" |
| 54 #include "components/prefs/pref_service.h" | 53 #include "components/prefs/pref_service.h" |
| 54 #include "components/safe_browsing/common/safebrowsing_switches.h" |
| 55 #include "components/safe_browsing_db/safe_browsing_prefs.h" | 55 #include "components/safe_browsing_db/safe_browsing_prefs.h" |
| 56 #include "content/public/browser/browser_thread.h" | 56 #include "content/public/browser/browser_thread.h" |
| 57 #include "content/public/browser/download_item.h" | 57 #include "content/public/browser/download_item.h" |
| 58 #include "content/public/browser/page_navigator.h" | 58 #include "content/public/browser/page_navigator.h" |
| 59 #include "crypto/sha2.h" | 59 #include "crypto/sha2.h" |
| 60 #include "google_apis/google_api_keys.h" | 60 #include "google_apis/google_api_keys.h" |
| 61 #include "net/base/escape.h" | 61 #include "net/base/escape.h" |
| 62 #include "net/base/load_flags.h" | 62 #include "net/base/load_flags.h" |
| 63 #include "net/base/url_util.h" | 63 #include "net/base/url_util.h" |
| 64 #include "net/cert/x509_cert_types.h" | 64 #include "net/cert/x509_cert_types.h" |
| (...skipping 1475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1540 return; | 1540 return; |
| 1541 } | 1541 } |
| 1542 enabled_ = enabled; | 1542 enabled_ = enabled; |
| 1543 if (!enabled_) { | 1543 if (!enabled_) { |
| 1544 CancelPendingRequests(); | 1544 CancelPendingRequests(); |
| 1545 } | 1545 } |
| 1546 } | 1546 } |
| 1547 | 1547 |
| 1548 void DownloadProtectionService::ParseManualBlacklistFlag() { | 1548 void DownloadProtectionService::ParseManualBlacklistFlag() { |
| 1549 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 1549 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 1550 if (!command_line->HasSwitch(switches::kSbManualDownloadBlacklist)) | 1550 if (!command_line->HasSwitch( |
| 1551 safe_browsing::switches::kSbManualDownloadBlacklist)) |
| 1551 return; | 1552 return; |
| 1552 | 1553 |
| 1553 std::string flag_val = | 1554 std::string flag_val = command_line->GetSwitchValueASCII( |
| 1554 command_line->GetSwitchValueASCII(switches::kSbManualDownloadBlacklist); | 1555 safe_browsing::switches::kSbManualDownloadBlacklist); |
| 1555 for (const std::string& hash_hex : base::SplitString( | 1556 for (const std::string& hash_hex : base::SplitString( |
| 1556 flag_val, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY)) { | 1557 flag_val, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY)) { |
| 1557 std::vector<uint8_t> bytes; | 1558 std::vector<uint8_t> bytes; |
| 1558 if (base::HexStringToBytes(hash_hex, &bytes) && bytes.size() == 32) { | 1559 if (base::HexStringToBytes(hash_hex, &bytes) && bytes.size() == 32) { |
| 1559 manual_blacklist_hashes_.insert( | 1560 manual_blacklist_hashes_.insert( |
| 1560 std::string(bytes.begin(), bytes.end())); | 1561 std::string(bytes.begin(), bytes.end())); |
| 1561 } else { | 1562 } else { |
| 1562 LOG(FATAL) << "Bad sha256 hex value '" << hash_hex << "' found in --" | 1563 LOG(FATAL) << "Bad sha256 hex value '" << hash_hex << "' found in --" |
| 1563 << switches::kSbManualDownloadBlacklist; | 1564 << safe_browsing::switches::kSbManualDownloadBlacklist; |
| 1564 } | 1565 } |
| 1565 } | 1566 } |
| 1566 } | 1567 } |
| 1567 | 1568 |
| 1568 bool DownloadProtectionService::IsHashManuallyBlacklisted( | 1569 bool DownloadProtectionService::IsHashManuallyBlacklisted( |
| 1569 const std::string& sha256_hash) const { | 1570 const std::string& sha256_hash) const { |
| 1570 return manual_blacklist_hashes_.count(sha256_hash) > 0; | 1571 return manual_blacklist_hashes_.count(sha256_hash) > 0; |
| 1571 } | 1572 } |
| 1572 | 1573 |
| 1573 void DownloadProtectionService::CheckClientDownload( | 1574 void DownloadProtectionService::CheckClientDownload( |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1781 GURL DownloadProtectionService::GetDownloadRequestUrl() { | 1782 GURL DownloadProtectionService::GetDownloadRequestUrl() { |
| 1782 GURL url(kDownloadRequestUrl); | 1783 GURL url(kDownloadRequestUrl); |
| 1783 std::string api_key = google_apis::GetAPIKey(); | 1784 std::string api_key = google_apis::GetAPIKey(); |
| 1784 if (!api_key.empty()) | 1785 if (!api_key.empty()) |
| 1785 url = url.Resolve("?key=" + net::EscapeQueryParamValue(api_key, true)); | 1786 url = url.Resolve("?key=" + net::EscapeQueryParamValue(api_key, true)); |
| 1786 | 1787 |
| 1787 return url; | 1788 return url; |
| 1788 } | 1789 } |
| 1789 | 1790 |
| 1790 } // namespace safe_browsing | 1791 } // namespace safe_browsing |
| OLD | NEW |