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/command_line.h" | 14 #include "base/command_line.h" |
15 #include "base/feature_list.h" | 15 #include "base/feature_list.h" |
16 #include "base/process/launch.h" | 16 #include "base/process/launch.h" |
17 #include "base/process/process.h" | 17 #include "base/process/process.h" |
18 #include "base/time/time.h" | 18 #include "base/time/time.h" |
19 #include "chrome/browser/safe_browsing/srt_chrome_prompt_impl.h" | |
grt (UTC plus 2)
2017/04/25 07:06:40
can you replace this with a forward decl for Chrom
ftirelo
2017/04/25 22:24:05
Done.
| |
19 | 20 |
20 namespace base { | 21 namespace base { |
21 class FilePath; | 22 class FilePath; |
22 class TaskRunner; | 23 class TaskRunner; |
23 class Version; | 24 class Version; |
24 } | 25 } |
25 | 26 |
26 class Browser; | 27 class Browser; |
27 | 28 |
28 namespace safe_browsing { | 29 namespace safe_browsing { |
29 | 30 |
30 // A special exit code identifying a failure to run the reporter. | 31 // A special exit code identifying a failure to run the reporter. |
31 const int kReporterFailureExitCode = INT_MAX; | 32 const int kReporterNotLaunchedExitCode = INT_MAX; |
32 | 33 |
33 // The number of days to wait before triggering another reporter run. | 34 // The number of days to wait before triggering another reporter run. |
34 const int kDaysBetweenSuccessfulSwReporterRuns = 7; | 35 const int kDaysBetweenSuccessfulSwReporterRuns = 7; |
35 const int kDaysBetweenSwReporterRunsForPendingPrompt = 1; | 36 const int kDaysBetweenSwReporterRunsForPendingPrompt = 1; |
36 // The number of days to wait before sending out reporter logs. | 37 // The number of days to wait before sending out reporter logs. |
37 const int kDaysBetweenReporterLogsSent = 7; | 38 const int kDaysBetweenReporterLogsSent = 7; |
38 | 39 |
39 // When enabled, moves all user interaction with the Software Reporter and the | 40 // When enabled, moves all user interaction with the Software Reporter and the |
40 // Chrome Cleanup tool to Chrome. | 41 // Chrome Cleanup tool to Chrome. |
41 extern const base::Feature kInBrowserCleanerUIFeature; | 42 extern const base::Feature kInBrowserCleanerUIFeature; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
96 // recent Reporter run terminated with an exit code indicating the presence of | 97 // recent Reporter run terminated with an exit code indicating the presence of |
97 // UwS. | 98 // UwS. |
98 bool ReporterFoundUws(); | 99 bool ReporterFoundUws(); |
99 | 100 |
100 // Returns true iff a valid registry key for the SRT Cleaner exists, and that | 101 // Returns true iff a valid registry key for the SRT Cleaner exists, and that |
101 // key is nonempty. | 102 // key is nonempty. |
102 // TODO(tmartino): Consider changing to check whether the user has recently | 103 // TODO(tmartino): Consider changing to check whether the user has recently |
103 // run the cleaner, rather than checking if they've run it at all. | 104 // run the cleaner, rather than checking if they've run it at all. |
104 bool UserHasRunCleaner(); | 105 bool UserHasRunCleaner(); |
105 | 106 |
106 // Mocks and callbacks for the unit tests. | 107 // Mocks and callbacks for the unit tests. |
grt (UTC plus 2)
2017/04/25 07:06:40
nittynit:
// A delegate used by tests to implemen
ftirelo
2017/04/25 22:24:05
Done.
| |
107 class SwReporterTestingDelegate { | 108 class SwReporterTestingDelegate { |
108 public: | 109 public: |
109 virtual ~SwReporterTestingDelegate() {} | 110 virtual ~SwReporterTestingDelegate() {} |
110 | 111 |
111 // Test mock for launching the reporter. | 112 // Test mock for launching the reporter. |
grt (UTC plus 2)
2017/04/25 07:06:40
the use of "mock" here deviates from normal naming
ftirelo
2017/04/25 22:24:05
Done.
| |
112 virtual base::Process LaunchReporter( | 113 virtual base::Process LaunchReporter( |
113 const SwReporterInvocation& invocation, | 114 const SwReporterInvocation& invocation, |
114 const base::LaunchOptions& launch_options) = 0; | 115 const base::LaunchOptions& launch_options) = 0; |
115 | 116 |
116 // Test mock for showing the prompt. | 117 // Test mock for showing the prompt. |
117 virtual void TriggerPrompt(Browser* browser, | 118 virtual void TriggerPrompt(Browser* browser, |
118 const std::string& reporter_version) = 0; | 119 const std::string& reporter_version) = 0; |
119 | 120 |
120 // Returns the test's idea of the current time. | 121 // Returns the test's idea of the current time. |
121 virtual base::Time Now() const = 0; | 122 virtual base::Time Now() const = 0; |
122 | 123 |
123 // A task runner used to spawn the reporter process (which blocks). | 124 // A task runner used to spawn the reporter process (which blocks). |
124 virtual base::TaskRunner* BlockingTaskRunner() const = 0; | 125 virtual base::TaskRunner* BlockingTaskRunner() const = 0; |
126 | |
127 // Returns a ChromePromptImpl object that keeps track of specific actions | |
128 // during execution. | |
129 virtual std::unique_ptr<ChromePromptImpl> CreateChromePromptImpl( | |
130 chrome_cleaner::mojom::ChromePromptRequest request) = 0; | |
131 | |
132 // Handles the case when the remote end has been closed, by performing the | |
133 // necessary cleanups if the prompt dialog is being shown to the user. | |
134 virtual void OnConnectionClosed() = 0; | |
135 | |
136 // Handles the case when a mojo::ReportBadMessage has been explicitly | |
137 // reported. | |
138 virtual void OnConnectionError(const std::string& message) = 0; | |
125 }; | 139 }; |
126 | 140 |
127 // Set a delegate for testing. The implementation will not take ownership of | 141 // Set a delegate for testing. The implementation will not take ownership of |
128 // |delegate| - it must remain valid until this function is called again to | 142 // |delegate| - it must remain valid until this function is called again to |
129 // reset the delegate. If |delegate| is nullptr, any previous delegate is | 143 // reset the delegate. If |delegate| is nullptr, any previous delegate is |
130 // cleared. | 144 // cleared. |
131 void SetSwReporterTestingDelegate(SwReporterTestingDelegate* delegate); | 145 void SetSwReporterTestingDelegate(SwReporterTestingDelegate* delegate); |
132 | 146 |
133 void DisplaySRTPromptForTesting(const base::FilePath& download_path); | 147 void DisplaySRTPromptForTesting(const base::FilePath& download_path); |
134 | 148 |
135 } // namespace safe_browsing | 149 } // namespace safe_browsing |
136 | 150 |
137 #endif // CHROME_BROWSER_SAFE_BROWSING_SRT_FETCHER_WIN_H_ | 151 #endif // CHROME_BROWSER_SAFE_BROWSING_SRT_FETCHER_WIN_H_ |
OLD | NEW |