Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: chrome/browser/safe_browsing/chrome_cleaner/reporter_runner_win.h

Issue 2890023005: Chrome Cleaner UI: reporter no longer uses mojo. (Closed)
Patch Set: Nits Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_CHROME_CLEANER_REPORTER_RUNNER_WIN_H_ 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_CHROME_CLEANER_REPORTER_RUNNER_WIN_H_
6 #define CHROME_BROWSER_SAFE_BROWSING_CHROME_CLEANER_REPORTER_RUNNER_WIN_H_ 6 #define CHROME_BROWSER_SAFE_BROWSING_CHROME_CLEANER_REPORTER_RUNNER_WIN_H_
7 7
8 #include <limits.h> 8 #include <limits.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <memory> 11 #include <memory>
12 #include <queue> 12 #include <queue>
13 #include <string> 13 #include <string>
14 14
15 #include "base/command_line.h" 15 #include "base/command_line.h"
16 #include "base/feature_list.h"
17 #include "base/process/launch.h"
18 #include "base/process/process.h"
19 #include "base/time/time.h" 16 #include "base/time/time.h"
20 #include "components/chrome_cleaner/public/interfaces/chrome_prompt.mojom.h"
21 17
22 namespace base { 18 namespace base {
23 class FilePath; 19 class FilePath;
24 class TaskRunner; 20 class TaskRunner;
25 class Version; 21 class Version;
26 } 22 }
27 23
28 class Browser; 24 class Browser;
29 25
30 namespace safe_browsing { 26 namespace safe_browsing {
31 27
32 class ChromePromptImpl;
33
34 // A special exit code identifying a failure to run the reporter. 28 // A special exit code identifying a failure to run the reporter.
35 const int kReporterNotLaunchedExitCode = INT_MAX; 29 const int kReporterNotLaunchedExitCode = INT_MAX;
36 30
37 // The number of days to wait before triggering another reporter run. 31 // The number of days to wait before triggering another reporter run.
38 const int kDaysBetweenSuccessfulSwReporterRuns = 7; 32 const int kDaysBetweenSuccessfulSwReporterRuns = 7;
39 const int kDaysBetweenSwReporterRunsForPendingPrompt = 1; 33 const int kDaysBetweenSwReporterRunsForPendingPrompt = 1;
40 // The number of days to wait before sending out reporter logs. 34 // The number of days to wait before sending out reporter logs.
41 const int kDaysBetweenReporterLogsSent = 7; 35 const int kDaysBetweenReporterLogsSent = 7;
42 36
43 // When enabled, moves all user interaction with the Software Reporter and the
44 // Chrome Cleanup tool to Chrome.
45 extern const base::Feature kInBrowserCleanerUIFeature;
46
47 // Parameters used to invoke the sw_reporter component. 37 // Parameters used to invoke the sw_reporter component.
48 struct SwReporterInvocation { 38 struct SwReporterInvocation {
49 base::CommandLine command_line; 39 base::CommandLine command_line;
50 40
51 // Experimental versions of the reporter will write metrics to registry keys 41 // Experimental versions of the reporter will write metrics to registry keys
52 // ending in |suffix|. Those metrics should be copied to UMA histograms also 42 // ending in |suffix|. Those metrics should be copied to UMA histograms also
53 // ending in |suffix|. For the canonical version, |suffix| will be empty. 43 // ending in |suffix|. For the canonical version, |suffix| will be empty.
54 std::string suffix; 44 std::string suffix;
55 45
56 // Flags to control behaviours the Software Reporter should support by 46 // Flags to control behaviours the Software Reporter should support by
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 // TODO(tmartino): Consider changing to check whether the user has recently 96 // TODO(tmartino): Consider changing to check whether the user has recently
107 // run the cleaner, rather than checking if they've run it at all. 97 // run the cleaner, rather than checking if they've run it at all.
108 bool UserHasRunCleaner(); 98 bool UserHasRunCleaner();
109 99
110 // A delegate used by tests to implement test doubles (e.g., stubs, fakes, or 100 // A delegate used by tests to implement test doubles (e.g., stubs, fakes, or
111 // mocks). 101 // mocks).
112 class SwReporterTestingDelegate { 102 class SwReporterTestingDelegate {
113 public: 103 public:
114 virtual ~SwReporterTestingDelegate() {} 104 virtual ~SwReporterTestingDelegate() {}
115 105
116 // Invoked by tests in places of base::LaunchProcess. 106 // Invoked by tests in place of base::LaunchProcess.
117 // See chrome_cleaner::mojom::ChromePromptRequest(). 107 virtual int LaunchReporter(const SwReporterInvocation& invocation) = 0;
118 virtual base::Process LaunchReporter(
119 const SwReporterInvocation& invocation,
120 const base::LaunchOptions& launch_options) = 0;
121 108
122 // Invoked by tests in place of the actual prompting logic. 109 // Invoked by tests in place of the actual prompting logic.
123 // See MaybeFetchSRT(). 110 // See MaybeFetchSRT().
124 virtual void TriggerPrompt(Browser* browser, 111 virtual void TriggerPrompt(Browser* browser,
125 const std::string& reporter_version) = 0; 112 const std::string& reporter_version) = 0;
126 113
127 // Invoked by tests to override the current time. 114 // Invoked by tests to override the current time.
128 // See Now() in reporter_runner_win.cc. 115 // See Now() in reporter_runner_win.cc.
129 virtual base::Time Now() const = 0; 116 virtual base::Time Now() const = 0;
130 117
131 // A task runner used to spawn the reporter process (which blocks). 118 // A task runner used to spawn the reporter process (which blocks).
132 // See ReporterRunner::ScheduleNextInvocation(). 119 // See ReporterRunner::ScheduleNextInvocation().
133 virtual base::TaskRunner* BlockingTaskRunner() const = 0; 120 virtual base::TaskRunner* BlockingTaskRunner() const = 0;
134
135 // Returns a ChromePromptImpl object that keeps track of specific
136 // actions during tests. Replaces the object returned by
137 // SwReporterProcess::CreateChromePromptImpl().
138 // See SwReporterProcess::LaunchConnectedReporterProcess().
139 virtual std::unique_ptr<ChromePromptImpl> CreateChromePromptImpl(
140 chrome_cleaner::mojom::ChromePromptRequest request) = 0;
141
142 // Connection closed callback defined by tests in place of the default
143 // error handler. See ReporterRunnerTest::CreateChromePromptImpl().
144 virtual void OnConnectionClosed() = 0;
145
146 // Bad message handler callback defined by tests in place of the default
147 // error handler. See SwReporterProcess::LaunchConnectedReporterProcess().
148 virtual void OnConnectionError(const std::string& message) = 0;
149 }; 121 };
150 122
151 // Set a delegate for testing. The implementation will not take ownership of 123 // Set a delegate for testing. The implementation will not take ownership of
152 // |delegate| - it must remain valid until this function is called again to 124 // |delegate| - it must remain valid until this function is called again to
153 // reset the delegate. If |delegate| is nullptr, any previous delegate is 125 // reset the delegate. If |delegate| is nullptr, any previous delegate is
154 // cleared. 126 // cleared.
155 void SetSwReporterTestingDelegate(SwReporterTestingDelegate* delegate); 127 void SetSwReporterTestingDelegate(SwReporterTestingDelegate* delegate);
156 128
157 void DisplaySRTPromptForTesting(const base::FilePath& download_path); 129 void DisplaySRTPromptForTesting(const base::FilePath& download_path);
158 130
159 } // namespace safe_browsing 131 } // namespace safe_browsing
160 132
161 #endif // CHROME_BROWSER_SAFE_BROWSING_CHROME_CLEANER_REPORTER_RUNNER_WIN_H_ 133 #endif // CHROME_BROWSER_SAFE_BROWSING_CHROME_CLEANER_REPORTER_RUNNER_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698