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

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

Issue 2906103002: Post-cleanup settings reset. (Closed)
Patch Set: Use base::DoNothing 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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_CHROME_CLEANER_CONTROLLER_WI N_H_ 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_CHROME_CLEANER_CHROME_CLEANER_CONTROLLER_WI N_H_
6 #define CHROME_BROWSER_SAFE_BROWSING_CHROME_CLEANER_CHROME_CLEANER_CONTROLLER_WI N_H_ 6 #define CHROME_BROWSER_SAFE_BROWSING_CHROME_CLEANER_CHROME_CLEANER_CONTROLLER_WI N_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <set> 9 #include <set>
10 #include <vector>
10 11
12 #include "base/callback.h"
11 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
12 #include "base/macros.h" 14 #include "base/macros.h"
13 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
14 #include "base/observer_list.h" 16 #include "base/observer_list.h"
15 #include "base/threading/thread_checker.h" 17 #include "base/threading/thread_checker.h"
16 #include "chrome/browser/safe_browsing/chrome_cleaner/chrome_cleaner_runner_win. h" 18 #include "chrome/browser/safe_browsing/chrome_cleaner/chrome_cleaner_runner_win. h"
17 #include "chrome/browser/safe_browsing/chrome_cleaner/reporter_runner_win.h" 19 #include "chrome/browser/safe_browsing/chrome_cleaner/reporter_runner_win.h"
18 #include "components/chrome_cleaner/public/interfaces/chrome_prompt.mojom.h" 20 #include "components/chrome_cleaner/public/interfaces/chrome_prompt.mojom.h"
19 21
22 class Profile;
23
20 namespace safe_browsing { 24 namespace safe_browsing {
21 25
22 // Delegate class that provides services to the ChromeCleanerController class 26 // Delegate class that provides services to the ChromeCleanerController class
23 // and can be overridden by tests via 27 // and can be overridden by tests via
24 // SetChromeCleanerControllerDelegateForTesting(). 28 // SetChromeCleanerControllerDelegateForTesting().
25 class ChromeCleanerControllerDelegate { 29 class ChromeCleanerControllerDelegate {
26 public: 30 public:
27 using FetchedCallback = base::OnceCallback<void(base::FilePath)>; 31 using FetchedCallback = base::OnceCallback<void(base::FilePath)>;
28 32
29 ChromeCleanerControllerDelegate(); 33 ChromeCleanerControllerDelegate();
30 virtual ~ChromeCleanerControllerDelegate(); 34 virtual ~ChromeCleanerControllerDelegate();
31 35
32 // Fetches and verifies the Chrome Cleaner binary and passes the name of the 36 // Fetches and verifies the Chrome Cleaner binary and passes the name of the
33 // executable to |fetched_callback|. The file name will have the ".exe" 37 // executable to |fetched_callback|. The file name will have the ".exe"
34 // extension. If the operation fails, the file name passed to 38 // extension. If the operation fails, the file name passed to
35 // |fecthed_callback| will be empty. 39 // |fecthed_callback| will be empty.
36 virtual void FetchAndVerifyChromeCleaner(FetchedCallback fetched_callback); 40 virtual void FetchAndVerifyChromeCleaner(FetchedCallback fetched_callback);
37 virtual bool SafeBrowsingExtendedReportingScoutEnabled(); 41 virtual bool SafeBrowsingExtendedReportingScoutEnabled();
38 virtual bool IsMetricsAndCrashReportingEnabled(); 42 virtual bool IsMetricsAndCrashReportingEnabled();
43
44 // Auxiliary methods for tagging and resetting open profiles.
45 virtual void TagForResetting(Profile* profile);
46 virtual void ResetTaggedProfiles(std::vector<Profile*> profiles,
47 base::OnceClosure continuation);
39 }; 48 };
40 49
41 // Controller class that keeps track of the execution of the Chrome Cleaner and 50 // Controller class that keeps track of the execution of the Chrome Cleaner and
42 // the various states through which the execution will transition. Observers can 51 // the various states through which the execution will transition. Observers can
43 // register themselves to be notified of state changes. Intended to be used by 52 // register themselves to be notified of state changes. Intended to be used by
44 // the Chrome Cleaner webui page and the Chrome Cleaner prompt dialog. 53 // the Chrome Cleaner webui page and the Chrome Cleaner prompt dialog.
45 // 54 //
46 // This class lives on, and all its members should be called only on, the UI 55 // This class lives on, and all its members should be called only on, the UI
47 // thread. 56 // thread.
48 class ChromeCleanerController { 57 class ChromeCleanerController {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 // which found possible harmful software on the system. 140 // which found possible harmful software on the system.
132 // 141 //
133 // A call to Scan() will be a no-op if the controller is not in the kIdle 142 // A call to Scan() will be a no-op if the controller is not in the kIdle
134 // state. This gracefully handles cases where multiple user responses are 143 // state. This gracefully handles cases where multiple user responses are
135 // received, for example if a user manages to click on a "Scan" button 144 // received, for example if a user manages to click on a "Scan" button
136 // multiple times. 145 // multiple times.
137 void Scan(const SwReporterInvocation& reporter_invocation); 146 void Scan(const SwReporterInvocation& reporter_invocation);
138 147
139 // Sends the user's response, as to whether or not they want the Chrome 148 // Sends the user's response, as to whether or not they want the Chrome
140 // Cleaner to remove harmful software that was found, to the Chrome Cleaner 149 // Cleaner to remove harmful software that was found, to the Chrome Cleaner
141 // process. 150 // process. If the user accepted the prompt, then tags |profile| for
151 // post-cleanup settings reset.
142 // 152 //
143 // A call to ReplyWithUserResponse() will be a no-op if the controller is not 153 // A call to ReplyWithUserResponse() will be a no-op if the controller is not
144 // in the kInfected state. This gracefully handles cases where multiple user 154 // in the kInfected state. This gracefully handles cases where multiple user
145 // responses are received, for example if a user manages to click on a 155 // responses are received, for example if a user manages to click on a
146 // "Cleanup" button multiple times. 156 // "Cleanup" button multiple times.
147 void ReplyWithUserResponse(UserResponse user_response); 157 void ReplyWithUserResponse(Profile* profile, UserResponse user_response);
148 158
149 // If the controller is in the kRebootRequired state, initiates a reboot of 159 // If the controller is in the kRebootRequired state, initiates a reboot of
150 // the computer. Call this after obtaining permission from the user to 160 // the computer. Call this after obtaining permission from the user to
151 // reboot. 161 // reboot.
152 // 162 //
153 // If initiating the reboot fails, observers will be notified via a call to 163 // If initiating the reboot fails, observers will be notified via a call to
154 // OnRebootFailed(). 164 // OnRebootFailed().
155 // 165 //
156 // Note that there are no guarantees that the reboot will in fact happen even 166 // Note that there are no guarantees that the reboot will in fact happen even
157 // if the system calls to initiate a reboot return success. 167 // if the system calls to initiate a reboot return success.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 chrome_cleaner::mojom::ChromePrompt::PromptUserCallback 201 chrome_cleaner::mojom::ChromePrompt::PromptUserCallback
192 prompt_user_callback); 202 prompt_user_callback);
193 203
194 void OnPromptUser(std::unique_ptr<std::set<base::FilePath>> files_to_delete, 204 void OnPromptUser(std::unique_ptr<std::set<base::FilePath>> files_to_delete,
195 chrome_cleaner::mojom::ChromePrompt::PromptUserCallback 205 chrome_cleaner::mojom::ChromePrompt::PromptUserCallback
196 prompt_user_callback); 206 prompt_user_callback);
197 void OnConnectionClosed(); 207 void OnConnectionClosed();
198 void OnCleanerProcessDone(ChromeCleanerRunner::ProcessStatus process_status); 208 void OnCleanerProcessDone(ChromeCleanerRunner::ProcessStatus process_status);
199 void InitiateReboot(); 209 void InitiateReboot();
200 210
211 // Invoked once settings reset is done for tagged profiles.
212 void OnSettingsResetCompleted();
213
201 std::unique_ptr<ChromeCleanerControllerDelegate> real_delegate_; 214 std::unique_ptr<ChromeCleanerControllerDelegate> real_delegate_;
202 // Pointer to either real_delegate_ or one set by tests. 215 // Pointer to either real_delegate_ or one set by tests.
203 ChromeCleanerControllerDelegate* delegate_; 216 ChromeCleanerControllerDelegate* delegate_;
204 217
205 State state_ = State::kIdle; 218 State state_ = State::kIdle;
206 IdleReason idle_reason_ = IdleReason::kInitial; 219 IdleReason idle_reason_ = IdleReason::kInitial;
207 std::unique_ptr<SwReporterInvocation> reporter_invocation_; 220 std::unique_ptr<SwReporterInvocation> reporter_invocation_;
208 std::unique_ptr<std::set<base::FilePath>> files_to_delete_; 221 std::unique_ptr<std::set<base::FilePath>> files_to_delete_;
209 // The Mojo callback that should be called to send a response to the Chrome 222 // The Mojo callback that should be called to send a response to the Chrome
210 // Cleaner process. This must be posted to run on the IO thread. 223 // Cleaner process. This must be posted to run on the IO thread.
211 chrome_cleaner::mojom::ChromePrompt::PromptUserCallback prompt_user_callback_; 224 chrome_cleaner::mojom::ChromePrompt::PromptUserCallback prompt_user_callback_;
212 225
213 base::ObserverList<Observer> observer_list_; 226 base::ObserverList<Observer> observer_list_;
214 227
215 THREAD_CHECKER(thread_checker_); 228 THREAD_CHECKER(thread_checker_);
216 229
217 base::WeakPtrFactory<ChromeCleanerController> weak_factory_; 230 base::WeakPtrFactory<ChromeCleanerController> weak_factory_;
218 231
219 DISALLOW_COPY_AND_ASSIGN(ChromeCleanerController); 232 DISALLOW_COPY_AND_ASSIGN(ChromeCleanerController);
220 }; 233 };
221 234
222 } // namespace safe_browsing 235 } // namespace safe_browsing
223 236
224 #endif // CHROME_BROWSER_SAFE_BROWSING_CHROME_CLEANER_CHROME_CLEANER_CONTROLLER _WIN_H_ 237 #endif // CHROME_BROWSER_SAFE_BROWSING_CHROME_CLEANER_CHROME_CLEANER_CONTROLLER _WIN_H_
OLDNEW
« no previous file with comments | « chrome/browser/prefs/browser_prefs.cc ('k') | chrome/browser/safe_browsing/chrome_cleaner/chrome_cleaner_controller_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698