| 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 #ifndef CHROME_BROWSER_SAFE_BROWSING_SRT_FETCHER_WIN_H_ | 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_SRT_FETCHER_WIN_H_ |
| 6 #define CHROME_BROWSER_SAFE_BROWSING_SRT_FETCHER_WIN_H_ | 6 #define CHROME_BROWSER_SAFE_BROWSING_SRT_FETCHER_WIN_H_ |
| 7 | 7 |
| 8 #include <limits.h> | 8 #include <limits.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <queue> | 11 #include <queue> |
| 12 #include <string> | 12 #include <string> |
| 13 | 13 |
| 14 #include "base/callback_forward.h" | |
| 15 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 16 #include "base/feature_list.h" | 15 #include "base/time/time.h" |
| 17 #include "base/memory/ref_counted.h" | |
| 18 #include "base/version.h" | |
| 19 | 16 |
| 20 namespace base { | 17 namespace base { |
| 21 class FilePath; | 18 class FilePath; |
| 22 class TaskRunner; | 19 class TaskRunner; |
| 20 class Version; |
| 23 } | 21 } |
| 24 | 22 |
| 25 class Browser; | 23 class Browser; |
| 26 | 24 |
| 27 namespace safe_browsing { | 25 namespace safe_browsing { |
| 28 | 26 |
| 29 // SRT registry keys and value names. | 27 // SRT registry keys and value names. |
| 30 extern const wchar_t kSoftwareRemovalToolRegistryKey[]; | 28 extern const wchar_t kSoftwareRemovalToolRegistryKey[]; |
| 31 extern const wchar_t kEndTimeValueName[]; | 29 extern const wchar_t kEndTimeValueName[]; |
| 32 extern const wchar_t kStartTimeValueName[]; | 30 extern const wchar_t kStartTimeValueName[]; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 // called multiple times, then multiple sequences of trying to run will happen, | 86 // called multiple times, then multiple sequences of trying to run will happen, |
| 89 // yet only one SwReporterQueue will actually run per specified period (either | 87 // yet only one SwReporterQueue will actually run per specified period (either |
| 90 // |kDaysBetweenSuccessfulSwReporterRuns| or | 88 // |kDaysBetweenSuccessfulSwReporterRuns| or |
| 91 // |kDaysBetweenSwReporterRunsForPendingPrompt|). | 89 // |kDaysBetweenSwReporterRunsForPendingPrompt|). |
| 92 // | 90 // |
| 93 // Each "run" of the sw_reporter component may aggregate the results of several | 91 // Each "run" of the sw_reporter component may aggregate the results of several |
| 94 // executions of the tool with different command lines. |invocations| is the | 92 // executions of the tool with different command lines. |invocations| is the |
| 95 // queue of SwReporters to execute as a single "run". When a new try is | 93 // queue of SwReporters to execute as a single "run". When a new try is |
| 96 // scheduled the entire queue is executed. | 94 // scheduled the entire queue is executed. |
| 97 // | 95 // |
| 98 // |version| is the version of the tool that will run. The task runners are | 96 // |version| is the version of the tool that will run. |
| 99 // provided to allow tests to provide their own. | |
| 100 void RunSwReporters(const SwReporterQueue& invocations, | 97 void RunSwReporters(const SwReporterQueue& invocations, |
| 101 const base::Version& version, | 98 const base::Version& version); |
| 102 scoped_refptr<base::TaskRunner> main_thread_task_runner, | |
| 103 scoped_refptr<base::TaskRunner> blocking_task_runner); | |
| 104 | 99 |
| 105 // Returns true iff Local State is successfully accessed and indicates the most | 100 // Returns true iff Local State is successfully accessed and indicates the most |
| 106 // recent Reporter run terminated with an exit code indicating the presence of | 101 // recent Reporter run terminated with an exit code indicating the presence of |
| 107 // UwS. | 102 // UwS. |
| 108 bool ReporterFoundUws(); | 103 bool ReporterFoundUws(); |
| 109 | 104 |
| 110 // Returns true iff a valid registry key for the SRT Cleaner exists, and that | 105 // Returns true iff a valid registry key for the SRT Cleaner exists, and that |
| 111 // key is nonempty. | 106 // key is nonempty. |
| 112 // TODO(tmartino): Consider changing to check whether the user has recently | 107 // TODO(tmartino): Consider changing to check whether the user has recently |
| 113 // run the cleaner, rather than checking if they've run it at all. | 108 // run the cleaner, rather than checking if they've run it at all. |
| 114 bool UserHasRunCleaner(); | 109 bool UserHasRunCleaner(); |
| 115 | 110 |
| 116 // Mocks and callbacks for the unit tests. | 111 // Mocks and callbacks for the unit tests. |
| 117 class SwReporterTestingDelegate { | 112 class SwReporterTestingDelegate { |
| 118 public: | 113 public: |
| 119 virtual ~SwReporterTestingDelegate() {} | 114 virtual ~SwReporterTestingDelegate() {} |
| 120 | 115 |
| 121 // Test mock for launching the reporter. | 116 // Test mock for launching the reporter. |
| 122 virtual int LaunchReporter(const SwReporterInvocation& invocation) = 0; | 117 virtual int LaunchReporter(const SwReporterInvocation& invocation) = 0; |
| 123 | 118 |
| 124 // Test mock for showing the prompt. | 119 // Test mock for showing the prompt. |
| 125 virtual void TriggerPrompt(Browser* browser, | 120 virtual void TriggerPrompt(Browser* browser, |
| 126 const std::string& reporter_version) = 0; | 121 const std::string& reporter_version) = 0; |
| 127 | 122 |
| 128 // Callback to let the tests know the reporter is ready to launch. | 123 // Returns the test's idea of the current time. |
| 129 virtual void NotifyLaunchReady() = 0; | 124 virtual base::Time Now() const = 0; |
| 130 | 125 |
| 131 // Callback to let the tests know the reporter has finished running. | 126 // A task runner used to spawn the reporter process (which blocks). |
| 132 virtual void NotifyReporterDone() = 0; | 127 virtual base::TaskRunner* BlockingTaskRunner() const = 0; |
| 133 }; | 128 }; |
| 134 | 129 |
| 135 // Set a delegate for testing. The implementation will not take ownership of | 130 // Set a delegate for testing. The implementation will not take ownership of |
| 136 // |delegate| - it must remain valid until this function is called again to | 131 // |delegate| - it must remain valid until this function is called again to |
| 137 // reset the delegate. If |delegate| is nullptr, any previous delegate is | 132 // reset the delegate. If |delegate| is nullptr, any previous delegate is |
| 138 // cleared. | 133 // cleared. |
| 139 void SetSwReporterTestingDelegate(SwReporterTestingDelegate* delegate); | 134 void SetSwReporterTestingDelegate(SwReporterTestingDelegate* delegate); |
| 140 | 135 |
| 141 } // namespace safe_browsing | 136 } // namespace safe_browsing |
| 142 | 137 |
| 143 #endif // CHROME_BROWSER_SAFE_BROWSING_SRT_FETCHER_WIN_H_ | 138 #endif // CHROME_BROWSER_SAFE_BROWSING_SRT_FETCHER_WIN_H_ |
| OLD | NEW |