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

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: Move main run function to inside the ChromeCleanerRunner class. Created 3 years, 7 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" 16 #include "base/feature_list.h"
Joe Mason 2017/05/19 22:02:26 I don't think this is needed anymore.
alito 2017/05/22 23:26:31 Done.
17 #include "base/process/launch.h"
18 #include "base/process/process.h"
19 #include "base/time/time.h" 17 #include "base/time/time.h"
20 #include "components/chrome_cleaner/public/interfaces/chrome_prompt.mojom.h"
21 18
22 namespace base { 19 namespace base {
23 class FilePath; 20 class FilePath;
24 class TaskRunner; 21 class TaskRunner;
25 class Version; 22 class Version;
26 } 23 }
27 24
28 class Browser; 25 class Browser;
29 26
30 namespace safe_browsing { 27 namespace safe_browsing {
31 28
32 class ChromePromptImpl;
33
34 // A special exit code identifying a failure to run the reporter. 29 // A special exit code identifying a failure to run the reporter.
35 const int kReporterNotLaunchedExitCode = INT_MAX; 30 const int kReporterNotLaunchedExitCode = INT_MAX;
36 31
37 // The number of days to wait before triggering another reporter run. 32 // The number of days to wait before triggering another reporter run.
38 const int kDaysBetweenSuccessfulSwReporterRuns = 7; 33 const int kDaysBetweenSuccessfulSwReporterRuns = 7;
39 const int kDaysBetweenSwReporterRunsForPendingPrompt = 1; 34 const int kDaysBetweenSwReporterRunsForPendingPrompt = 1;
40 // The number of days to wait before sending out reporter logs. 35 // The number of days to wait before sending out reporter logs.
41 const int kDaysBetweenReporterLogsSent = 7; 36 const int kDaysBetweenReporterLogsSent = 7;
42 37
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. 38 // Parameters used to invoke the sw_reporter component.
48 struct SwReporterInvocation { 39 struct SwReporterInvocation {
49 base::CommandLine command_line; 40 base::CommandLine command_line;
50 41
51 // Experimental versions of the reporter will write metrics to registry keys 42 // Experimental versions of the reporter will write metrics to registry keys
52 // ending in |suffix|. Those metrics should be copied to UMA histograms also 43 // ending in |suffix|. Those metrics should be copied to UMA histograms also
53 // ending in |suffix|. For the canonical version, |suffix| will be empty. 44 // ending in |suffix|. For the canonical version, |suffix| will be empty.
54 std::string suffix; 45 std::string suffix;
55 46
56 // Flags to control behaviours the Software Reporter should support by 47 // 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 97 // 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. 98 // run the cleaner, rather than checking if they've run it at all.
108 bool UserHasRunCleaner(); 99 bool UserHasRunCleaner();
109 100
110 // A delegate used by tests to implement test doubles (e.g., stubs, fakes, or 101 // A delegate used by tests to implement test doubles (e.g., stubs, fakes, or
111 // mocks). 102 // mocks).
112 class SwReporterTestingDelegate { 103 class SwReporterTestingDelegate {
113 public: 104 public:
114 virtual ~SwReporterTestingDelegate() {} 105 virtual ~SwReporterTestingDelegate() {}
115 106
116 // Invoked by tests in places of base::LaunchProcess. 107 // Invoked by tests in place of base::LaunchProcess.
117 // See chrome_cleaner::mojom::ChromePromptRequest(). 108 virtual int LaunchReporter(const SwReporterInvocation& invocation) = 0;
118 virtual base::Process LaunchReporter(
119 const SwReporterInvocation& invocation,
120 const base::LaunchOptions& launch_options) = 0;
121 109
122 // Invoked by tests in place of the actual prompting logic. 110 // Invoked by tests in place of the actual prompting logic.
123 // See MaybeFetchSRT(). 111 // See MaybeFetchSRT().
124 virtual void TriggerPrompt(Browser* browser, 112 virtual void TriggerPrompt(Browser* browser,
125 const std::string& reporter_version) = 0; 113 const std::string& reporter_version) = 0;
126 114
127 // Invoked by tests to override the current time. 115 // Invoked by tests to override the current time.
128 // See Now() in reporter_runner_win.cc. 116 // See Now() in reporter_runner_win.cc.
129 virtual base::Time Now() const = 0; 117 virtual base::Time Now() const = 0;
130 118
131 // A task runner used to spawn the reporter process (which blocks). 119 // A task runner used to spawn the reporter process (which blocks).
132 // See ReporterRunner::ScheduleNextInvocation(). 120 // See ReporterRunner::ScheduleNextInvocation().
133 virtual base::TaskRunner* BlockingTaskRunner() const = 0; 121 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 }; 122 };
150 123
151 // Set a delegate for testing. The implementation will not take ownership of 124 // 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 125 // |delegate| - it must remain valid until this function is called again to
153 // reset the delegate. If |delegate| is nullptr, any previous delegate is 126 // reset the delegate. If |delegate| is nullptr, any previous delegate is
154 // cleared. 127 // cleared.
155 void SetSwReporterTestingDelegate(SwReporterTestingDelegate* delegate); 128 void SetSwReporterTestingDelegate(SwReporterTestingDelegate* delegate);
156 129
157 void DisplaySRTPromptForTesting(const base::FilePath& download_path); 130 void DisplaySRTPromptForTesting(const base::FilePath& download_path);
158 131
159 } // namespace safe_browsing 132 } // namespace safe_browsing
160 133
161 #endif // CHROME_BROWSER_SAFE_BROWSING_CHROME_CLEANER_REPORTER_RUNNER_WIN_H_ 134 #endif // CHROME_BROWSER_SAFE_BROWSING_CHROME_CLEANER_REPORTER_RUNNER_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698