| OLD | NEW |
| 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 InvokeTagProfileForResetting(Profile* profile); |
| 51 virtual void InvokeResetPostCleanupSettingsIfTagged( |
| 52 std::vector<Profile*> profiles, |
| 53 base::OnceClosure continuation); |
| 44 }; | 54 }; |
| 45 | 55 |
| 46 // Controller class that keeps track of the execution of the Chrome Cleaner and | 56 // 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 | 57 // 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 | 58 // 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. | 59 // the Chrome Cleaner webui page and the Chrome Cleaner prompt dialog. |
| 50 // | 60 // |
| 51 // This class lives on, and all its members should be called only on, the UI | 61 // This class lives on, and all its members should be called only on, the UI |
| 52 // thread. | 62 // thread. |
| 53 class ChromeCleanerController { | 63 class ChromeCleanerController { |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 const base::WeakPtr<ChromeCleanerController>& controller, | 190 const base::WeakPtr<ChromeCleanerController>& controller, |
| 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); |
| 200 void ChromeCleanerController::OnSettingsResetCompleted(); |
| 190 | 201 |
| 191 std::unique_ptr<ChromeCleanerControllerDelegate> real_delegate_; | 202 std::unique_ptr<ChromeCleanerControllerDelegate> real_delegate_; |
| 192 // Pointer to either real_delegate_ or one set by tests. | 203 // Pointer to either real_delegate_ or one set by tests. |
| 193 ChromeCleanerControllerDelegate* delegate_; | 204 ChromeCleanerControllerDelegate* delegate_; |
| 194 | 205 |
| 195 State state_ = State::kIdle; | 206 State state_ = State::kIdle; |
| 196 IdleReason idle_reason_ = IdleReason::kInitial; | 207 IdleReason idle_reason_ = IdleReason::kInitial; |
| 197 std::unique_ptr<SwReporterInvocation> reporter_invocation_; | 208 std::unique_ptr<SwReporterInvocation> reporter_invocation_; |
| 198 std::unique_ptr<std::set<base::FilePath>> files_to_delete_; | 209 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 | 210 // 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. | 211 // Cleaner process. This must be posted to run on the IO thread. |
| 201 chrome_cleaner::mojom::ChromePrompt::PromptUserCallback prompt_user_callback_; | 212 chrome_cleaner::mojom::ChromePrompt::PromptUserCallback prompt_user_callback_; |
| 202 | 213 |
| 203 base::ObserverList<Observer> observer_list_; | 214 base::ObserverList<Observer> observer_list_; |
| 204 | 215 |
| 205 THREAD_CHECKER(thread_checker_); | 216 THREAD_CHECKER(thread_checker_); |
| 206 | 217 |
| 207 base::WeakPtrFactory<ChromeCleanerController> weak_factory_; | 218 base::WeakPtrFactory<ChromeCleanerController> weak_factory_; |
| 208 | 219 |
| 209 DISALLOW_COPY_AND_ASSIGN(ChromeCleanerController); | 220 DISALLOW_COPY_AND_ASSIGN(ChromeCleanerController); |
| 210 }; | 221 }; |
| 211 | 222 |
| 212 } // namespace safe_browsing | 223 } // namespace safe_browsing |
| 213 | 224 |
| 214 #endif // CHROME_BROWSER_SAFE_BROWSING_CHROME_CLEANER_CHROME_CLEANER_CONTROLLER
_WIN_H_ | 225 #endif // CHROME_BROWSER_SAFE_BROWSING_CHROME_CLEANER_CHROME_CLEANER_CONTROLLER
_WIN_H_ |
| OLD | NEW |