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

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

Issue 2450993003: Componentize safe_browsing [1]: create component, move messages, constants and switches. (Closed)
Patch Set: rebase + more fixes Created 4 years, 1 month 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 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 15 matching lines...) Expand all
26 #include "base/sha1.h" 26 #include "base/sha1.h"
27 #include "base/single_thread_task_runner.h" 27 #include "base/single_thread_task_runner.h"
28 #include "base/strings/string_number_conversions.h" 28 #include "base/strings/string_number_conversions.h"
29 #include "base/threading/sequenced_worker_pool.h" 29 #include "base/threading/sequenced_worker_pool.h"
30 #include "base/threading/thread_task_runner_handle.h" 30 #include "base/threading/thread_task_runner_handle.h"
31 #include "chrome/browser/history/history_service_factory.h" 31 #include "chrome/browser/history/history_service_factory.h"
32 #include "chrome/browser/safe_browsing/download_feedback_service.h" 32 #include "chrome/browser/safe_browsing/download_feedback_service.h"
33 #include "chrome/browser/safe_browsing/incident_reporting/incident_reporting_ser vice.h" 33 #include "chrome/browser/safe_browsing/incident_reporting/incident_reporting_ser vice.h"
34 #include "chrome/browser/safe_browsing/local_database_manager.h" 34 #include "chrome/browser/safe_browsing/local_database_manager.h"
35 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 35 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
36 #include "chrome/common/chrome_switches.h"
37 #include "chrome/common/safe_browsing/binary_feature_extractor.h" 36 #include "chrome/common/safe_browsing/binary_feature_extractor.h"
38 #include "chrome/common/safe_browsing/csd.pb.h" 37 #include "chrome/common/safe_browsing/csd.pb.h"
39 #include "chrome/common/safe_browsing/file_type_policies_test_util.h" 38 #include "chrome/common/safe_browsing/file_type_policies_test_util.h"
40 #include "chrome/test/base/testing_profile.h" 39 #include "chrome/test/base/testing_profile.h"
41 #include "components/history/core/browser/history_service.h" 40 #include "components/history/core/browser/history_service.h"
42 #include "components/prefs/pref_service.h" 41 #include "components/prefs/pref_service.h"
42 #include "components/safe_browsing/common/safebrowsing_switches.h"
43 #include "components/safe_browsing_db/database_manager.h" 43 #include "components/safe_browsing_db/database_manager.h"
44 #include "components/safe_browsing_db/safe_browsing_prefs.h" 44 #include "components/safe_browsing_db/safe_browsing_prefs.h"
45 #include "components/safe_browsing_db/test_database_manager.h" 45 #include "components/safe_browsing_db/test_database_manager.h"
46 #include "content/public/browser/download_danger_type.h" 46 #include "content/public/browser/download_danger_type.h"
47 #include "content/public/browser/page_navigator.h" 47 #include "content/public/browser/page_navigator.h"
48 #include "content/public/test/mock_download_item.h" 48 #include "content/public/test/mock_download_item.h"
49 #include "content/public/test/test_browser_thread_bundle.h" 49 #include "content/public/test/test_browser_thread_bundle.h"
50 #include "content/public/test/test_utils.h" 50 #include "content/public/test/test_utils.h"
51 #include "net/base/url_util.h" 51 #include "net/base/url_util.h"
52 #include "net/cert/x509_certificate.h" 52 #include "net/cert/x509_certificate.h"
(...skipping 2240 matching lines...) Expand 10 before | Expand all | Expand 10 after
2293 // Matches unsigned.exe within zipfile_one_unsigned_binary.zip 2293 // Matches unsigned.exe within zipfile_one_unsigned_binary.zip
2294 : blacklisted_hash_hex_("1e954d9ce0389e2ba7447216f21761f98d1e6540c2abecdbe cff570e36c493db") {} 2294 : blacklisted_hash_hex_("1e954d9ce0389e2ba7447216f21761f98d1e6540c2abecdbe cff570e36c493db") {}
2295 2295
2296 void SetUp() override { 2296 void SetUp() override {
2297 std::vector<uint8_t> bytes; 2297 std::vector<uint8_t> bytes;
2298 ASSERT_TRUE(base::HexStringToBytes(blacklisted_hash_hex_, &bytes) && 2298 ASSERT_TRUE(base::HexStringToBytes(blacklisted_hash_hex_, &bytes) &&
2299 bytes.size() == 32); 2299 bytes.size() == 32);
2300 blacklisted_hash_ = std::string(bytes.begin(), bytes.end()); 2300 blacklisted_hash_ = std::string(bytes.begin(), bytes.end());
2301 2301
2302 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( 2302 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
2303 switches::kSbManualDownloadBlacklist, 2303 safe_browsing::switches::kSbManualDownloadBlacklist,
2304 blacklisted_hash_hex_); 2304 blacklisted_hash_hex_);
2305 2305
2306 DownloadProtectionServiceTest::SetUp(); 2306 DownloadProtectionServiceTest::SetUp();
2307 } 2307 }
2308 2308
2309 // Hex 64 chars 2309 // Hex 64 chars
2310 const std::string blacklisted_hash_hex_; 2310 const std::string blacklisted_hash_hex_;
2311 // Binary 32 bytes 2311 // Binary 32 bytes
2312 std::string blacklisted_hash_; 2312 std::string blacklisted_hash_;
2313 }; 2313 };
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2362 &item, base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, 2362 &item, base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
2363 base::Unretained(this), run_loop.QuitClosure())); 2363 base::Unretained(this), run_loop.QuitClosure()));
2364 run_loop.Run(); 2364 run_loop.Run();
2365 2365
2366 EXPECT_FALSE(HasClientDownloadRequest()); 2366 EXPECT_FALSE(HasClientDownloadRequest());
2367 // Overriden by flag: 2367 // Overriden by flag:
2368 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS)); 2368 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS));
2369 } 2369 }
2370 2370
2371 } // namespace safe_browsing 2371 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698