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

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

Issue 2906103002: Post-cleanup settings reset. (Closed)
Patch Set: Addressed Nico's comments 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 base { 24 namespace base {
21 template <typename T> 25 template <typename T>
22 struct DefaultSingletonTraits; 26 struct DefaultSingletonTraits;
23 } 27 }
24 28
25 namespace safe_browsing { 29 namespace safe_browsing {
26 30
27 // Delegate class that provides services to the ChromeCleanerController class 31 // Delegate class that provides services to the ChromeCleanerController class
28 // and can be overridden by tests via 32 // and can be overridden by tests via
29 // SetChromeCleanerControllerDelegateForTesting(). 33 // SetChromeCleanerControllerDelegateForTesting().
30 class ChromeCleanerControllerDelegate { 34 class ChromeCleanerControllerDelegate {
31 public: 35 public:
32 using FetchedCallback = base::OnceCallback<void(base::FilePath)>; 36 using FetchedCallback = base::OnceCallback<void(base::FilePath)>;
33 37
34 ChromeCleanerControllerDelegate(); 38 ChromeCleanerControllerDelegate();
35 virtual ~ChromeCleanerControllerDelegate(); 39 virtual ~ChromeCleanerControllerDelegate();
36 40
37 // Fetches and verifies the Chrome Cleaner binary and passes the name of the 41 // Fetches and verifies the Chrome Cleaner binary and passes the name of the
38 // executable to |fetched_callback|. The file name will have the ".exe" 42 // executable to |fetched_callback|. The file name will have the ".exe"
39 // extension. If the operation fails, the file name passed to 43 // extension. If the operation fails, the file name passed to
40 // |fecthed_callback| will be empty. 44 // |fecthed_callback| will be empty.
41 virtual void FetchAndVerifyChromeCleaner(FetchedCallback fetched_callback); 45 virtual void FetchAndVerifyChromeCleaner(FetchedCallback fetched_callback);
42 virtual bool SafeBrowsingExtendedReportingScoutEnabled(); 46 virtual bool SafeBrowsingExtendedReportingScoutEnabled();
43 virtual bool IsMetricsAndCrashReportingEnabled(); 47 virtual bool IsMetricsAndCrashReportingEnabled();
48
49 // Auxiliary methods for tagging and resetting open profiles.
50 virtual void TagForResetting(Profile* profile);
51 virtual void ResetTaggedProfiles(std::vector<Profile*> profiles,
52 base::OnceClosure continuation);
44 }; 53 };
45 54
46 // Controller class that keeps track of the execution of the Chrome Cleaner and 55 // Controller class that keeps track of the execution of the Chrome Cleaner and
47 // the various states through which the execution will transition. Observers can 56 // the various states through which the execution will transition. Observers can
48 // register themselves to be notified of state changes. Intended to be used by 57 // register themselves to be notified of state changes. Intended to be used by
49 // the Chrome Cleaner webui page and the Chrome Cleaner prompt dialog. 58 // the Chrome Cleaner webui page and the Chrome Cleaner prompt dialog.
50 // 59 //
51 // This class lives on, and all its members should be called only on, the UI 60 // This class lives on, and all its members should be called only on, the UI
52 // thread. 61 // thread.
53 class ChromeCleanerController { 62 class ChromeCleanerController {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 // which found possible harmful software on the system. 144 // which found possible harmful software on the system.
136 // 145 //
137 // A call to Scan() will be a no-op if the controller is not in the kIdle 146 // A call to Scan() will be a no-op if the controller is not in the kIdle
138 // state. This gracefully handles cases where multiple user responses are 147 // state. This gracefully handles cases where multiple user responses are
139 // received, for example if a user manages to click on a "Scan" button 148 // received, for example if a user manages to click on a "Scan" button
140 // multiple times. 149 // multiple times.
141 void Scan(const SwReporterInvocation& reporter_invocation); 150 void Scan(const SwReporterInvocation& reporter_invocation);
142 151
143 // Sends the user's response, as to whether or not they want the Chrome 152 // Sends the user's response, as to whether or not they want the Chrome
144 // Cleaner to remove harmful software that was found, to the Chrome Cleaner 153 // Cleaner to remove harmful software that was found, to the Chrome Cleaner
145 // process. 154 // process. If the user accepted the prompt, then tags |profile| for
155 // post-cleanup settings reset.
146 // 156 //
147 // A call to ReplyWithUserResponse() will be a no-op if the controller is not 157 // A call to ReplyWithUserResponse() will be a no-op if the controller is not
148 // in the kInfected state. This gracefully handles cases where multiple user 158 // in the kInfected state. This gracefully handles cases where multiple user
149 // responses are received, for example if a user manages to click on a 159 // responses are received, for example if a user manages to click on a
150 // "Cleanup" button multiple times. 160 // "Cleanup" button multiple times.
151 void ReplyWithUserResponse(UserResponse user_response); 161 void ReplyWithUserResponse(Profile* profile, UserResponse user_response);
152 162
153 // Passing in a nullptr as |delegate| resets the delegate to a default 163 // Passing in a nullptr as |delegate| resets the delegate to a default
154 // production version. 164 // production version.
155 void SetDelegateForTesting(ChromeCleanerControllerDelegate* delegate); 165 void SetDelegateForTesting(ChromeCleanerControllerDelegate* delegate);
156 void DismissRebootForTesting(); 166 void DismissRebootForTesting();
157 167
158 private: 168 private:
159 friend struct base::DefaultSingletonTraits<ChromeCleanerController>; 169 friend struct base::DefaultSingletonTraits<ChromeCleanerController>;
160 170
161 ChromeCleanerController(); 171 ChromeCleanerController();
(...skipping 23 matching lines...) Expand all
185 std::unique_ptr<std::set<base::FilePath>> files_to_delete, 195 std::unique_ptr<std::set<base::FilePath>> files_to_delete,
186 chrome_cleaner::mojom::ChromePrompt::PromptUserCallback 196 chrome_cleaner::mojom::ChromePrompt::PromptUserCallback
187 prompt_user_callback); 197 prompt_user_callback);
188 198
189 void OnPromptUser(std::unique_ptr<std::set<base::FilePath>> files_to_delete, 199 void OnPromptUser(std::unique_ptr<std::set<base::FilePath>> files_to_delete,
190 chrome_cleaner::mojom::ChromePrompt::PromptUserCallback 200 chrome_cleaner::mojom::ChromePrompt::PromptUserCallback
191 prompt_user_callback); 201 prompt_user_callback);
192 void OnConnectionClosed(); 202 void OnConnectionClosed();
193 void OnCleanerProcessDone(ChromeCleanerRunner::ProcessStatus process_status); 203 void OnCleanerProcessDone(ChromeCleanerRunner::ProcessStatus process_status);
194 204
205 // Invoked once settings reset is done for tagged profiles.
206 void OnSettingsResetCompleted();
207
195 std::unique_ptr<ChromeCleanerControllerDelegate> real_delegate_; 208 std::unique_ptr<ChromeCleanerControllerDelegate> real_delegate_;
196 // Pointer to either real_delegate_ or one set by tests. 209 // Pointer to either real_delegate_ or one set by tests.
197 ChromeCleanerControllerDelegate* delegate_; 210 ChromeCleanerControllerDelegate* delegate_;
198 211
199 State state_ = State::kIdle; 212 State state_ = State::kIdle;
200 IdleReason idle_reason_ = IdleReason::kInitial; 213 IdleReason idle_reason_ = IdleReason::kInitial;
201 std::unique_ptr<SwReporterInvocation> reporter_invocation_; 214 std::unique_ptr<SwReporterInvocation> reporter_invocation_;
202 std::unique_ptr<std::set<base::FilePath>> files_to_delete_; 215 std::unique_ptr<std::set<base::FilePath>> files_to_delete_;
203 // The Mojo callback that should be called to send a response to the Chrome 216 // The Mojo callback that should be called to send a response to the Chrome
204 // Cleaner process. This must be posted to run on the IO thread. 217 // Cleaner process. This must be posted to run on the IO thread.
205 chrome_cleaner::mojom::ChromePrompt::PromptUserCallback prompt_user_callback_; 218 chrome_cleaner::mojom::ChromePrompt::PromptUserCallback prompt_user_callback_;
206 219
207 base::ObserverList<Observer> observer_list_; 220 base::ObserverList<Observer> observer_list_;
208 221
209 THREAD_CHECKER(thread_checker_); 222 THREAD_CHECKER(thread_checker_);
210 223
211 base::WeakPtrFactory<ChromeCleanerController> weak_factory_; 224 base::WeakPtrFactory<ChromeCleanerController> weak_factory_;
212 225
213 DISALLOW_COPY_AND_ASSIGN(ChromeCleanerController); 226 DISALLOW_COPY_AND_ASSIGN(ChromeCleanerController);
214 }; 227 };
215 228
216 } // namespace safe_browsing 229 } // namespace safe_browsing
217 230
218 #endif // CHROME_BROWSER_SAFE_BROWSING_CHROME_CLEANER_CHROME_CLEANER_CONTROLLER _WIN_H_ 231 #endif // CHROME_BROWSER_SAFE_BROWSING_CHROME_CLEANER_CHROME_CLEANER_CONTROLLER _WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698