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

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

Issue 2906103002: Post-cleanup settings reset. (Closed)
Patch Set: Code reviews 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 InvokeTagForResetting(Profile* profile);
robertshield 2017/06/12 15:00:04 naming nit: why InvokeFoo() instead of Foo() ? Doe
ftirelo 2017/06/13 18:52:48 Done.
51 virtual void InvokeResetTaggedProfiles(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 77 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 // Passing in a nullptr as |delegate| resets the delegate to a default 159 // Passing in a nullptr as |delegate| resets the delegate to a default
150 // production version. 160 // production version.
151 void SetDelegateForTesting(ChromeCleanerControllerDelegate* delegate); 161 void SetDelegateForTesting(ChromeCleanerControllerDelegate* delegate);
152 void DismissRebootForTesting(); 162 void DismissRebootForTesting();
153 163
154 private: 164 private:
155 friend struct base::DefaultSingletonTraits<ChromeCleanerController>; 165 friend struct base::DefaultSingletonTraits<ChromeCleanerController>;
156 166
157 ChromeCleanerController(); 167 ChromeCleanerController();
(...skipping 23 matching lines...) Expand all
181 std::unique_ptr<std::set<base::FilePath>> files_to_delete, 191 std::unique_ptr<std::set<base::FilePath>> files_to_delete,
182 chrome_cleaner::mojom::ChromePrompt::PromptUserCallback 192 chrome_cleaner::mojom::ChromePrompt::PromptUserCallback
183 prompt_user_callback); 193 prompt_user_callback);
184 194
185 void OnPromptUser(std::unique_ptr<std::set<base::FilePath>> files_to_delete, 195 void OnPromptUser(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 void OnConnectionClosed(); 198 void OnConnectionClosed();
189 void OnCleanerProcessDone(ChromeCleanerRunner::ProcessStatus process_status); 199 void OnCleanerProcessDone(ChromeCleanerRunner::ProcessStatus process_status);
190 200
201 // Invoked once settings reset is done for tagged profiles.
202 void OnSettingsResetCompleted();
203
191 std::unique_ptr<ChromeCleanerControllerDelegate> real_delegate_; 204 std::unique_ptr<ChromeCleanerControllerDelegate> real_delegate_;
192 // Pointer to either real_delegate_ or one set by tests. 205 // Pointer to either real_delegate_ or one set by tests.
193 ChromeCleanerControllerDelegate* delegate_; 206 ChromeCleanerControllerDelegate* delegate_;
194 207
195 State state_ = State::kIdle; 208 State state_ = State::kIdle;
196 IdleReason idle_reason_ = IdleReason::kInitial; 209 IdleReason idle_reason_ = IdleReason::kInitial;
197 std::unique_ptr<SwReporterInvocation> reporter_invocation_; 210 std::unique_ptr<SwReporterInvocation> reporter_invocation_;
198 std::unique_ptr<std::set<base::FilePath>> files_to_delete_; 211 std::unique_ptr<std::set<base::FilePath>> files_to_delete_;
199 // The Mojo callback that should be called to send a response to the Chrome 212 // The Mojo callback that should be called to send a response to the Chrome
200 // Cleaner process. This must be posted to run on the IO thread. 213 // Cleaner process. This must be posted to run on the IO thread.
201 chrome_cleaner::mojom::ChromePrompt::PromptUserCallback prompt_user_callback_; 214 chrome_cleaner::mojom::ChromePrompt::PromptUserCallback prompt_user_callback_;
202 215
203 base::ObserverList<Observer> observer_list_; 216 base::ObserverList<Observer> observer_list_;
204 217
205 THREAD_CHECKER(thread_checker_); 218 THREAD_CHECKER(thread_checker_);
206 219
207 base::WeakPtrFactory<ChromeCleanerController> weak_factory_; 220 base::WeakPtrFactory<ChromeCleanerController> weak_factory_;
208 221
209 DISALLOW_COPY_AND_ASSIGN(ChromeCleanerController); 222 DISALLOW_COPY_AND_ASSIGN(ChromeCleanerController);
210 }; 223 };
211 224
212 } // namespace safe_browsing 225 } // namespace safe_browsing
213 226
214 #endif // CHROME_BROWSER_SAFE_BROWSING_CHROME_CLEANER_CHROME_CLEANER_CONTROLLER _WIN_H_ 227 #endif // CHROME_BROWSER_SAFE_BROWSING_CHROME_CLEANER_CHROME_CLEANER_CONTROLLER _WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698