OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/srt_fetcher_win.h" | 5 #include "chrome/browser/safe_browsing/srt_fetcher_win.h" |
6 | 6 |
7 #include <iterator> | 7 #include <iterator> |
8 #include <memory> | 8 #include <memory> |
9 #include <set> | 9 #include <set> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
14 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
15 #include "base/test/scoped_feature_list.h" | 15 #include "base/test/scoped_feature_list.h" |
16 #include "base/test/test_simple_task_runner.h" | 16 #include "base/test/test_simple_task_runner.h" |
17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
18 #include "chrome/browser/browser_process.h" | 18 #include "chrome/browser/browser_process.h" |
19 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
20 #include "chrome/browser/safe_browsing/srt_client_info_win.h" | 20 #include "chrome/browser/safe_browsing/srt_client_info_win.h" |
21 #include "chrome/browser/ui/browser.h" | 21 #include "chrome/browser/ui/browser.h" |
22 #include "chrome/browser/ui/browser_finder.h" | 22 #include "chrome/browser/ui/browser_finder.h" |
23 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
24 #include "chrome/test/base/in_process_browser_test.h" | 24 #include "chrome/test/base/in_process_browser_test.h" |
25 #include "components/component_updater/pref_names.h" | 25 #include "components/component_updater/pref_names.h" |
26 #include "components/prefs/pref_service.h" | 26 #include "components/prefs/pref_service.h" |
| 27 #include "components/safe_browsing_db/safe_browsing_prefs.h" |
27 #include "content/public/test/test_browser_thread_bundle.h" | 28 #include "content/public/test/test_browser_thread_bundle.h" |
28 | 29 |
29 namespace safe_browsing { | 30 namespace safe_browsing { |
30 | 31 |
31 namespace { | 32 namespace { |
32 | 33 |
33 const char* const kExpectedSwitches[] = {kExtendedSafeBrowsingEnabledSwitch, | 34 const char* const kExpectedSwitches[] = {kExtendedSafeBrowsingEnabledSwitch, |
34 kChromeVersionSwitch, | 35 kChromeVersionSwitch, |
35 kChromeChannelSwitch}; | 36 kChromeChannelSwitch}; |
36 | 37 |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 EXPECT_NE(invocation_switches.find(expected_switch), | 306 EXPECT_NE(invocation_switches.find(expected_switch), |
306 invocation_switches.end()); | 307 invocation_switches.end()); |
307 } | 308 } |
308 } | 309 } |
309 | 310 |
310 void EnableSBExtendedReporting() { | 311 void EnableSBExtendedReporting() { |
311 Browser* browser = chrome::FindLastActive(); | 312 Browser* browser = chrome::FindLastActive(); |
312 ASSERT_NE(browser, nullptr); | 313 ASSERT_NE(browser, nullptr); |
313 Profile* profile = browser->profile(); | 314 Profile* profile = browser->profile(); |
314 ASSERT_NE(profile, nullptr); | 315 ASSERT_NE(profile, nullptr); |
315 profile->GetPrefs()->SetBoolean( | 316 profile->GetPrefs()->SetBoolean(GetExtendedReportingPrefName(), true); |
316 prefs::kSafeBrowsingExtendedReportingEnabled, true); | |
317 } | 317 } |
318 | 318 |
319 scoped_refptr<base::TestSimpleTaskRunner> task_runner_; | 319 scoped_refptr<base::TestSimpleTaskRunner> task_runner_; |
320 bool prompt_trigger_called_ = false; | 320 bool prompt_trigger_called_ = false; |
321 int reporter_launch_count_ = 0; | 321 int reporter_launch_count_ = 0; |
322 SwReporterInvocation reporter_launch_parameters_; | 322 SwReporterInvocation reporter_launch_parameters_; |
323 int exit_code_to_report_ = kReporterFailureExitCode; | 323 int exit_code_to_report_ = kReporterFailureExitCode; |
324 | 324 |
325 // This will be set to true when a call to |LaunchAndWaitForExit| is next in | 325 // This will be set to true when a call to |LaunchAndWaitForExit| is next in |
326 // the task queue. | 326 // the task queue. |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 EnableSBExtendedReporting(); | 610 EnableSBExtendedReporting(); |
611 SetLastTimeSentReport(kDaysBetweenReporterLogsSent - 1); | 611 SetLastTimeSentReport(kDaysBetweenReporterLogsSent - 1); |
612 int64_t last_time_sent_logs = GetLastTimeSentReport(); | 612 int64_t last_time_sent_logs = GetLastTimeSentReport(); |
613 RunReporter(); | 613 RunReporter(); |
614 TestReporterLaunchCycle({base::FilePath()}); | 614 TestReporterLaunchCycle({base::FilePath()}); |
615 ExpectLoggingSwitches(std::set<std::string>{/*expect no switches*/}); | 615 ExpectLoggingSwitches(std::set<std::string>{/*expect no switches*/}); |
616 EXPECT_EQ(last_time_sent_logs, GetLastTimeSentReport()); | 616 EXPECT_EQ(last_time_sent_logs, GetLastTimeSentReport()); |
617 } | 617 } |
618 | 618 |
619 } // namespace safe_browsing | 619 } // namespace safe_browsing |
OLD | NEW |