Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(472)

Side by Side Diff: chrome/browser/safe_browsing/download_protection_service.cc

Issue 2450993003: Componentize safe_browsing [1]: create component, move messages, constants and switches. (Closed)
Patch Set: fix compile Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 1466 matching lines...) Expand 10 before | Expand all | Expand 10 after
1531 return; 1531 return;
1532 } 1532 }
1533 enabled_ = enabled; 1533 enabled_ = enabled;
1534 if (!enabled_) { 1534 if (!enabled_) {
1535 CancelPendingRequests(); 1535 CancelPendingRequests();
1536 } 1536 }
1537 } 1537 }
1538 1538
1539 void DownloadProtectionService::ParseManualBlacklistFlag() { 1539 void DownloadProtectionService::ParseManualBlacklistFlag() {
1540 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 1540 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
1541 if (!command_line->HasSwitch(switches::kSbManualDownloadBlacklist)) 1541 if (!command_line->HasSwitch(
1542 safe_browsing::switches::kSbManualDownloadBlacklist))
1542 return; 1543 return;
1543 1544
1544 std::string flag_val = 1545 std::string flag_val = command_line->GetSwitchValueASCII(
1545 command_line->GetSwitchValueASCII(switches::kSbManualDownloadBlacklist); 1546 safe_browsing::switches::kSbManualDownloadBlacklist);
1546 for (const std::string& hash_hex : base::SplitString( 1547 for (const std::string& hash_hex : base::SplitString(
1547 flag_val, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY)) { 1548 flag_val, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY)) {
1548 std::vector<uint8_t> bytes; 1549 std::vector<uint8_t> bytes;
1549 if (base::HexStringToBytes(hash_hex, &bytes) && bytes.size() == 32) { 1550 if (base::HexStringToBytes(hash_hex, &bytes) && bytes.size() == 32) {
1550 manual_blacklist_hashes_.insert( 1551 manual_blacklist_hashes_.insert(
1551 std::string(bytes.begin(), bytes.end())); 1552 std::string(bytes.begin(), bytes.end()));
1552 } else { 1553 } else {
1553 LOG(FATAL) << "Bad sha256 hex value '" << hash_hex << "' found in --" 1554 LOG(FATAL) << "Bad sha256 hex value '" << hash_hex << "' found in --"
1554 << switches::kSbManualDownloadBlacklist; 1555 << safe_browsing::switches::kSbManualDownloadBlacklist;
1555 } 1556 }
1556 } 1557 }
1557 } 1558 }
1558 1559
1559 bool DownloadProtectionService::IsHashManuallyBlacklisted( 1560 bool DownloadProtectionService::IsHashManuallyBlacklisted(
1560 const std::string& sha256_hash) const { 1561 const std::string& sha256_hash) const {
1561 return manual_blacklist_hashes_.count(sha256_hash) > 0; 1562 return manual_blacklist_hashes_.count(sha256_hash) > 0;
1562 } 1563 }
1563 1564
1564 void DownloadProtectionService::CheckClientDownload( 1565 void DownloadProtectionService::CheckClientDownload(
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1772 GURL DownloadProtectionService::GetDownloadRequestUrl() { 1773 GURL DownloadProtectionService::GetDownloadRequestUrl() {
1773 GURL url(kDownloadRequestUrl); 1774 GURL url(kDownloadRequestUrl);
1774 std::string api_key = google_apis::GetAPIKey(); 1775 std::string api_key = google_apis::GetAPIKey();
1775 if (!api_key.empty()) 1776 if (!api_key.empty())
1776 url = url.Resolve("?key=" + net::EscapeQueryParamValue(api_key, true)); 1777 url = url.Resolve("?key=" + net::EscapeQueryParamValue(api_key, true));
1777 1778
1778 return url; 1779 return url;
1779 } 1780 }
1780 1781
1781 } // namespace safe_browsing 1782 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698