| 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 29 matching lines...) Expand all Loading... |
| 40 #include "chrome/test/base/testing_profile_manager.h" | 40 #include "chrome/test/base/testing_profile_manager.h" |
| 41 #include "components/history/content/browser/content_visit_delegate.h" | 41 #include "components/history/content/browser/content_visit_delegate.h" |
| 42 #include "components/history/content/browser/download_constants_utils.h" | 42 #include "components/history/content/browser/download_constants_utils.h" |
| 43 #include "components/history/content/browser/history_database_helper.h" | 43 #include "components/history/content/browser/history_database_helper.h" |
| 44 #include "components/history/core/browser/download_constants.h" | 44 #include "components/history/core/browser/download_constants.h" |
| 45 #include "components/history/core/browser/download_row.h" | 45 #include "components/history/core/browser/download_row.h" |
| 46 #include "components/history/core/browser/history_constants.h" | 46 #include "components/history/core/browser/history_constants.h" |
| 47 #include "components/history/core/browser/history_database_params.h" | 47 #include "components/history/core/browser/history_database_params.h" |
| 48 #include "components/history/core/browser/history_service.h" | 48 #include "components/history/core/browser/history_service.h" |
| 49 #include "components/safe_browsing_db/safe_browsing_prefs.h" | 49 #include "components/safe_browsing_db/safe_browsing_prefs.h" |
| 50 #include "components/syncable_prefs/testing_pref_service_syncable.h" | 50 #include "components/sync_preferences/testing_pref_service_syncable.h" |
| 51 #include "content/public/test/test_browser_thread_bundle.h" | 51 #include "content/public/test/test_browser_thread_bundle.h" |
| 52 #include "content/public/test/test_utils.h" | 52 #include "content/public/test/test_utils.h" |
| 53 #include "testing/gtest/include/gtest/gtest.h" | 53 #include "testing/gtest/include/gtest/gtest.h" |
| 54 | 54 |
| 55 namespace { | 55 namespace { |
| 56 | 56 |
| 57 // A BrowserContextKeyedServiceFactory::TestingFactoryFunction that creates a | 57 // A BrowserContextKeyedServiceFactory::TestingFactoryFunction that creates a |
| 58 // HistoryService for a TestingProfile. | 58 // HistoryService for a TestingProfile. |
| 59 std::unique_ptr<KeyedService> BuildHistoryService( | 59 std::unique_ptr<KeyedService> BuildHistoryService( |
| 60 content::BrowserContext* context) { | 60 content::BrowserContext* context) { |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 // Build up a custom history service. | 187 // Build up a custom history service. |
| 188 factories.push_back(std::make_pair(HistoryServiceFactory::GetInstance(), | 188 factories.push_back(std::make_pair(HistoryServiceFactory::GetInstance(), |
| 189 &BuildHistoryService)); | 189 &BuildHistoryService)); |
| 190 // Suppress WebHistoryService since it makes network requests. | 190 // Suppress WebHistoryService since it makes network requests. |
| 191 factories.push_back(std::make_pair( | 191 factories.push_back(std::make_pair( |
| 192 WebHistoryServiceFactory::GetInstance(), | 192 WebHistoryServiceFactory::GetInstance(), |
| 193 static_cast<BrowserContextKeyedServiceFactory::TestingFactoryFunction>( | 193 static_cast<BrowserContextKeyedServiceFactory::TestingFactoryFunction>( |
| 194 NULL))); | 194 NULL))); |
| 195 | 195 |
| 196 // Create prefs for the profile with safe browsing enabled or not. | 196 // Create prefs for the profile with safe browsing enabled or not. |
| 197 std::unique_ptr<syncable_prefs::TestingPrefServiceSyncable> prefs( | 197 std::unique_ptr<sync_preferences::TestingPrefServiceSyncable> prefs( |
| 198 new syncable_prefs::TestingPrefServiceSyncable); | 198 new sync_preferences::TestingPrefServiceSyncable); |
| 199 chrome::RegisterUserProfilePrefs(prefs->registry()); | 199 chrome::RegisterUserProfilePrefs(prefs->registry()); |
| 200 prefs->SetBoolean(prefs::kSafeBrowsingEnabled, | 200 prefs->SetBoolean(prefs::kSafeBrowsingEnabled, |
| 201 safe_browsing_opt_in != SAFE_BROWSING_OPT_OUT); | 201 safe_browsing_opt_in != SAFE_BROWSING_OPT_OUT); |
| 202 SetExtendedReportingPref(prefs.get(), | 202 SetExtendedReportingPref(prefs.get(), |
| 203 safe_browsing_opt_in == EXTENDED_REPORTING_OPT_IN); | 203 safe_browsing_opt_in == EXTENDED_REPORTING_OPT_IN); |
| 204 | 204 |
| 205 TestingProfile* profile = profile_manager_->CreateTestingProfile( | 205 TestingProfile* profile = profile_manager_->CreateTestingProfile( |
| 206 profile_name, std::move(prefs), | 206 profile_name, std::move(prefs), |
| 207 base::UTF8ToUTF16(profile_name), // user_name | 207 base::UTF8ToUTF16(profile_name), // user_name |
| 208 0, // avatar_id | 208 0, // avatar_id |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 base::Bind(&LastDownloadFinderTest::OnLastDownload, | 465 base::Bind(&LastDownloadFinderTest::OnLastDownload, |
| 466 base::Unretained(this), &last_binary_download, | 466 base::Unretained(this), &last_binary_download, |
| 467 &last_non_binary_download, run_loop.QuitClosure()))); | 467 &last_non_binary_download, run_loop.QuitClosure()))); |
| 468 | 468 |
| 469 run_loop.Run(); | 469 run_loop.Run(); |
| 470 | 470 |
| 471 ASSERT_TRUE(last_binary_download); | 471 ASSERT_TRUE(last_binary_download); |
| 472 } | 472 } |
| 473 | 473 |
| 474 } // namespace safe_browsing | 474 } // namespace safe_browsing |
| OLD | NEW |