Chromium Code Reviews| 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 #include <vector> |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 84 kInitial, | 84 kInitial, |
| 85 kScanningFoundNothing, | 85 kScanningFoundNothing, |
| 86 kScanningFailed, | 86 kScanningFailed, |
| 87 kConnectionLost, | 87 kConnectionLost, |
| 88 kUserDeclinedCleanup, | 88 kUserDeclinedCleanup, |
| 89 kCleaningFailed, | 89 kCleaningFailed, |
| 90 kCleaningSucceeded, | 90 kCleaningSucceeded, |
| 91 }; | 91 }; |
| 92 | 92 |
| 93 enum class UserResponse { | 93 enum class UserResponse { |
| 94 // User accepted the cleanup operation. | 94 // User accepted the cleanup operation and logs upload is enabled. |
| 95 kAccepted, | 95 kAcceptedWithLogs, |
| 96 // User accepted the cleanup operation and logs upload is not enabled. | |
| 97 kAcceptedWithoutLogs, | |
| 96 // User explicitly denied the cleanup operation, for example by clicking the | 98 // User explicitly denied the cleanup operation, for example by clicking the |
| 97 // Cleaner dialog's cancel button. | 99 // Cleaner dialog's cancel button. |
| 98 kDenied, | 100 kDenied, |
| 99 // The cleanup operation was denied when the user dismissed the Cleaner | 101 // The cleanup operation was denied when the user dismissed the Cleaner |
| 100 // dialog, for example by pressing the ESC key. | 102 // dialog, for example by pressing the ESC key. |
| 101 kDismissed, | 103 kDismissed, |
| 102 }; | 104 }; |
| 103 | 105 |
| 104 class Observer { | 106 class Observer { |
| 105 public: | 107 public: |
| 106 virtual void OnIdle(IdleReason idle_reason) {} | 108 virtual void OnIdle(IdleReason idle_reason) {} |
| 107 virtual void OnScanning() {} | 109 virtual void OnScanning() {} |
| 108 virtual void OnInfected(const std::set<base::FilePath>& files_to_delete) {} | 110 virtual void OnInfected(const std::set<base::FilePath>& files_to_delete) {} |
| 109 virtual void OnCleaning(const std::set<base::FilePath>& files_to_delete) {} | 111 virtual void OnCleaning(const std::set<base::FilePath>& files_to_delete) {} |
| 110 virtual void OnRebootRequired() {} | 112 virtual void OnRebootRequired() {} |
| 111 virtual void OnRebootFailed() {} | 113 virtual void OnRebootFailed() {} |
| 114 virtual void OnLogsEnabledChanged(bool logs_enabled) {} | |
| 112 | 115 |
| 113 protected: | 116 protected: |
| 114 virtual ~Observer() = default; | 117 virtual ~Observer() = default; |
| 115 }; | 118 }; |
| 116 | 119 |
| 117 // Returns the global controller object. | 120 // Returns the global controller object. |
| 118 static ChromeCleanerController* GetInstance(); | 121 static ChromeCleanerController* GetInstance(); |
| 119 | 122 |
| 120 // Returns whether the Cleanup card in settings should be displayed. | 123 // Returns whether the Cleanup card in settings should be displayed. |
| 121 // Static to prevent instantiation of the global controller object. | 124 // Static to prevent instantiation of the global controller object. |
| 122 static bool ShouldShowCleanupInSettingsUI(); | 125 static bool ShouldShowCleanupInSettingsUI(); |
| 123 | 126 |
| 124 State state() const { return state_; } | 127 State state() const { return state_; } |
| 125 | 128 |
| 129 // Called by Chrome Cleaner's UI when the user changes Cleaner logs upload | |
| 130 // permissions. Observers are notified if |logs_enabled| is different from the | |
| 131 // current permission state. | |
| 132 void SetLogsEnabled(bool logs_enabled); | |
| 133 bool logs_enabled() const { return logs_enabled_; } | |
| 134 | |
| 126 // |AddObserver()| immediately notifies |observer| of the controller's state | 135 // |AddObserver()| immediately notifies |observer| of the controller's state |
| 127 // by calling the corresponding |On*()| function. | 136 // by calling the corresponding |On*()| function. |
| 128 void AddObserver(Observer* observer); | 137 void AddObserver(Observer* observer); |
| 129 void RemoveObserver(Observer* observer); | 138 void RemoveObserver(Observer* observer); |
| 130 | 139 |
| 131 // Downloads the Chrome Cleaner binary, executes it and waits for the Cleaner | 140 // Downloads the Chrome Cleaner binary, executes it and waits for the Cleaner |
| 132 // to communicate with Chrome about harmful software found on the | 141 // to communicate with Chrome about harmful software found on the |
| 133 // system. During this time, the controller will be in the kScanning state. If | 142 // system. During this time, the controller will be in the kScanning state. If |
| 134 // any of the steps fail or if the Cleaner does not find harmful software on | 143 // any of the steps fail or if the Cleaner does not find harmful software on |
| 135 // the system, the controller will transition to the kIdle state, passing to | 144 // the system, the controller will transition to the kIdle state, passing to |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 209 void InitiateReboot(); | 218 void InitiateReboot(); |
| 210 | 219 |
| 211 // Invoked once settings reset is done for tagged profiles. | 220 // Invoked once settings reset is done for tagged profiles. |
| 212 void OnSettingsResetCompleted(); | 221 void OnSettingsResetCompleted(); |
| 213 | 222 |
| 214 std::unique_ptr<ChromeCleanerControllerDelegate> real_delegate_; | 223 std::unique_ptr<ChromeCleanerControllerDelegate> real_delegate_; |
| 215 // Pointer to either real_delegate_ or one set by tests. | 224 // Pointer to either real_delegate_ or one set by tests. |
| 216 ChromeCleanerControllerDelegate* delegate_; | 225 ChromeCleanerControllerDelegate* delegate_; |
| 217 | 226 |
| 218 State state_ = State::kIdle; | 227 State state_ = State::kIdle; |
| 228 // The logs permission checkboxes in the Chrome Clenaer dialog and webui page | |
|
robertshield
2017/06/29 13:47:21
nit: Cleaner
proberge
2017/06/29 13:55:52
s/Clenaer/Cleaner
alito
2017/06/29 17:14:27
Done.
alito
2017/06/29 17:14:27
Done.
| |
| 229 // are meant to be checked by default. | |
|
proberge
2017/06/29 13:55:52
s/meant to be checked by default/opt out
alito
2017/06/29 17:14:27
Ah, thx. That's what I couldn't remember last nigh
| |
| 230 bool logs_enabled_ = true; | |
| 219 IdleReason idle_reason_ = IdleReason::kInitial; | 231 IdleReason idle_reason_ = IdleReason::kInitial; |
| 220 std::unique_ptr<SwReporterInvocation> reporter_invocation_; | 232 std::unique_ptr<SwReporterInvocation> reporter_invocation_; |
| 221 std::unique_ptr<std::set<base::FilePath>> files_to_delete_; | 233 std::unique_ptr<std::set<base::FilePath>> files_to_delete_; |
| 222 // The Mojo callback that should be called to send a response to the Chrome | 234 // The Mojo callback that should be called to send a response to the Chrome |
| 223 // Cleaner process. This must be posted to run on the IO thread. | 235 // Cleaner process. This must be posted to run on the IO thread. |
| 224 chrome_cleaner::mojom::ChromePrompt::PromptUserCallback prompt_user_callback_; | 236 chrome_cleaner::mojom::ChromePrompt::PromptUserCallback prompt_user_callback_; |
| 225 | 237 |
| 226 base::ObserverList<Observer> observer_list_; | 238 base::ObserverList<Observer> observer_list_; |
| 227 | 239 |
| 228 THREAD_CHECKER(thread_checker_); | 240 THREAD_CHECKER(thread_checker_); |
| 229 | 241 |
| 230 base::WeakPtrFactory<ChromeCleanerController> weak_factory_; | 242 base::WeakPtrFactory<ChromeCleanerController> weak_factory_; |
| 231 | 243 |
| 232 DISALLOW_COPY_AND_ASSIGN(ChromeCleanerController); | 244 DISALLOW_COPY_AND_ASSIGN(ChromeCleanerController); |
| 233 }; | 245 }; |
| 234 | 246 |
| 235 } // namespace safe_browsing | 247 } // namespace safe_browsing |
| 236 | 248 |
| 237 #endif // CHROME_BROWSER_SAFE_BROWSING_CHROME_CLEANER_CHROME_CLEANER_CONTROLLER _WIN_H_ | 249 #endif // CHROME_BROWSER_SAFE_BROWSING_CHROME_CLEANER_CHROME_CLEANER_CONTROLLER _WIN_H_ |
| OLD | NEW |