OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/incident_reporting/last_download_finder.h
" | 5 #include "chrome/browser/safe_browsing/incident_reporting/last_download_finder.h
" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
(...skipping 17 matching lines...) Expand all Loading... |
28 #include "build/build_config.h" | 28 #include "build/build_config.h" |
29 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 29 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
30 #include "chrome/browser/history/chrome_history_client.h" | 30 #include "chrome/browser/history/chrome_history_client.h" |
31 #include "chrome/browser/history/history_service_factory.h" | 31 #include "chrome/browser/history/history_service_factory.h" |
32 #include "chrome/browser/history/web_history_service_factory.h" | 32 #include "chrome/browser/history/web_history_service_factory.h" |
33 #include "chrome/browser/prefs/browser_prefs.h" | 33 #include "chrome/browser/prefs/browser_prefs.h" |
34 #include "chrome/browser/profiles/profile_manager.h" | 34 #include "chrome/browser/profiles/profile_manager.h" |
35 #include "chrome/common/chrome_constants.h" | 35 #include "chrome/common/chrome_constants.h" |
36 #include "chrome/common/pref_names.h" | 36 #include "chrome/common/pref_names.h" |
37 #include "chrome/common/safe_browsing/csd.pb.h" | 37 #include "chrome/common/safe_browsing/csd.pb.h" |
| 38 #include "chrome/common/safe_browsing/file_type_policies.h" |
38 #include "chrome/test/base/testing_browser_process.h" | 39 #include "chrome/test/base/testing_browser_process.h" |
39 #include "chrome/test/base/testing_profile.h" | 40 #include "chrome/test/base/testing_profile.h" |
40 #include "chrome/test/base/testing_profile_manager.h" | 41 #include "chrome/test/base/testing_profile_manager.h" |
41 #include "components/history/content/browser/content_visit_delegate.h" | 42 #include "components/history/content/browser/content_visit_delegate.h" |
42 #include "components/history/content/browser/download_constants_utils.h" | 43 #include "components/history/content/browser/download_constants_utils.h" |
43 #include "components/history/content/browser/history_database_helper.h" | 44 #include "components/history/content/browser/history_database_helper.h" |
44 #include "components/history/core/browser/download_constants.h" | 45 #include "components/history/core/browser/download_constants.h" |
45 #include "components/history/core/browser/download_row.h" | 46 #include "components/history/core/browser/download_row.h" |
46 #include "components/history/core/browser/history_constants.h" | 47 #include "components/history/core/browser/history_constants.h" |
47 #include "components/history/core/browser/history_database_params.h" | 48 #include "components/history/core/browser/history_database_params.h" |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 void GetDownloadDetails( | 317 void GetDownloadDetails( |
317 content::BrowserContext* context, | 318 content::BrowserContext* context, |
318 const DownloadMetadataManager::GetDownloadDetailsCallback& callback) { | 319 const DownloadMetadataManager::GetDownloadDetailsCallback& callback) { |
319 callback.Run(std::unique_ptr<ClientIncidentReport_DownloadDetails>()); | 320 callback.Run(std::unique_ptr<ClientIncidentReport_DownloadDetails>()); |
320 } | 321 } |
321 | 322 |
322 int profile_number_; | 323 int profile_number_; |
323 | 324 |
324 // Incremented on every download addition to avoid downloads with the same id. | 325 // Incremented on every download addition to avoid downloads with the same id. |
325 int download_id_; | 326 int download_id_; |
| 327 |
| 328 // This manages the lifetime of FileTypePolicies::GlobalInstance() |
| 329 FileTypePoliciesManager file_type_policies_manager_; |
326 }; | 330 }; |
327 | 331 |
328 // Tests that nothing happens if there are no profiles at all. | 332 // Tests that nothing happens if there are no profiles at all. |
329 TEST_F(LastDownloadFinderTest, NoProfiles) { | 333 TEST_F(LastDownloadFinderTest, NoProfiles) { |
330 std::unique_ptr<ClientIncidentReport_DownloadDetails> last_binary_download; | 334 std::unique_ptr<ClientIncidentReport_DownloadDetails> last_binary_download; |
331 std::unique_ptr<ClientIncidentReport_NonBinaryDownloadDetails> | 335 std::unique_ptr<ClientIncidentReport_NonBinaryDownloadDetails> |
332 last_non_binary_download; | 336 last_non_binary_download; |
333 RunLastDownloadFinder(&last_binary_download, &last_non_binary_download); | 337 RunLastDownloadFinder(&last_binary_download, &last_non_binary_download); |
334 EXPECT_FALSE(last_binary_download); | 338 EXPECT_FALSE(last_binary_download); |
335 EXPECT_FALSE(last_non_binary_download); | 339 EXPECT_FALSE(last_non_binary_download); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 base::Bind(&LastDownloadFinderTest::OnLastDownload, | 467 base::Bind(&LastDownloadFinderTest::OnLastDownload, |
464 base::Unretained(this), &last_binary_download, | 468 base::Unretained(this), &last_binary_download, |
465 &last_non_binary_download, run_loop.QuitClosure()))); | 469 &last_non_binary_download, run_loop.QuitClosure()))); |
466 | 470 |
467 run_loop.Run(); | 471 run_loop.Run(); |
468 | 472 |
469 ASSERT_TRUE(last_binary_download); | 473 ASSERT_TRUE(last_binary_download); |
470 } | 474 } |
471 | 475 |
472 } // namespace safe_browsing | 476 } // namespace safe_browsing |
OLD | NEW |