Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_CHROME_CLEANER_SETTINGS_RESETTER_WIN_H_ | |
| 6 #define CHROME_BROWSER_SAFE_BROWSING_CHROME_CLEANER_SETTINGS_RESETTER_WIN_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/callback.h" | |
| 12 #include "base/macros.h" | |
| 13 #include "chrome/browser/safe_browsing/settings_reset_prompt/default_settings_fe tcher.h" | |
| 14 | |
| 15 class Profile; | |
| 16 class ProfileResetter; | |
| 17 | |
| 18 namespace user_prefs { | |
| 19 class PrefRegistrySyncable; | |
| 20 } // namespace user_prefs | |
| 21 | |
| 22 namespace safe_browsing { | |
| 23 | |
| 24 class PostCleanupSettingsResetter { | |
| 25 public: | |
| 26 class Delegate { | |
| 27 public: | |
| 28 Delegate(); | |
| 29 virtual ~Delegate(); | |
| 30 | |
| 31 virtual void FetchDefaultSettings( | |
| 32 DefaultSettingsFetcher::SettingsCallback callback); | |
| 33 | |
| 34 virtual std::unique_ptr<ProfileResetter> GetProfileResetter( | |
| 35 Profile* profile); | |
| 36 | |
| 37 private: | |
| 38 DISALLOW_COPY_AND_ASSIGN(Delegate); | |
| 39 }; | |
| 40 | |
| 41 // Registers the settings reset pending tracked preference. | |
| 42 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | |
| 43 | |
| 44 // Returns true if post-cleanup settings reset is enabled. | |
| 45 static bool IsEnabled(); | |
| 46 | |
| 47 // Factory method for this class. Returns null if post-cleanup settings reset | |
| 48 // is disabled. Ownership belongs to the caller that can either directly | |
| 49 // delete it or post a ReleaseClosure() task once the object is no longer | |
| 50 // needed. | |
| 51 static PostCleanupSettingsResetter* Create(); | |
|
alito
2017/06/09 01:52:07
since ownership is being passed to caller, is ther
alito
2017/06/09 01:52:07
Please move this so it is the first function in th
ftirelo
2017/06/09 21:24:55
Done.
ftirelo
2017/06/09 21:24:55
Done.
| |
| 52 | |
| 53 // Returns a closure that releases the current object and runs |continuation|. | |
| 54 base::OnceClosure ReleaseWithContinuationClosure( | |
|
alito
2017/06/09 01:52:07
It seems to me that neither TagForResetting nor Re
ftirelo
2017/06/09 21:24:55
Good point. Added some comments to make sure we do
| |
| 55 base::OnceClosure continuation); | |
| 56 | |
| 57 // Returns a closure that releases the current object. Shorthand for | |
| 58 // ReleaseAndContinueClosure() when no additional code needs to be run once | |
| 59 // the current object is deleted. | |
| 60 base::OnceClosure ReleaseClosure(); | |
| 61 | |
| 62 // Tags |profile| to have its settings reset once the current cleanup | |
| 63 // finishes, by means of ResetPostCleanupSettingsIfTagged(). If a cleanup | |
|
alito
2017/06/09 01:52:07
nit: ResetPostCleanupSettingsIfTagged no longer ex
ftirelo
2017/06/09 21:24:55
Done.
| |
| 64 // doesn't require a reboot and the browser is still running once the cleanup | |
| 65 // finishes, then settings will be reset as soon as the cleaner process | |
| 66 // returns; if the user closes the browser while the cleanup is ongoing, then | |
| 67 // settings will be reset on the first browser restart that happens after the | |
|
alito
2017/06/09 01:52:07
Please update the comment to reflect the fact that
ftirelo
2017/06/09 21:24:55
Done.
| |
| 68 // cleaner process ends. If the cleanup requires a reboot, then settings will | |
| 69 // be reset on the first browser restart that happens after reboot. | |
| 70 void TagForResetting(Profile* profile); | |
| 71 | |
| 72 // Resets settings for the profiles in |profiles| there are tagged for | |
| 73 // resetting and a cleanup has completed. If a cleanup doesn't require a | |
|
alito
2017/06/09 01:52:07
nit: "and a cleanup" -> "if cleanup"
alito
2017/06/09 01:52:07
The part of the comment that starts with "If a cle
ftirelo
2017/06/09 21:24:55
Done.
ftirelo
2017/06/09 21:24:55
Done.
| |
| 74 // reboot and the session that started the cleanup is still alive, then | |
| 75 // the settings for all open profiles will be reset at once. Otherwise, | |
| 76 // for each profile that was open when the cleanup started, this will be | |
| 77 // called the next a browser is launched for the profile. | |
| 78 void ResetTaggedProfiles( | |
| 79 std::vector<Profile*> profiles, | |
| 80 base::OnceClosure continuation, | |
| 81 std::unique_ptr<PostCleanupSettingsResetter::Delegate> delegate = | |
| 82 nullptr); | |
| 83 | |
| 84 protected: | |
| 85 PostCleanupSettingsResetter(); | |
| 86 | |
| 87 bool CopyProfilesToReset(const std::vector<Profile*>& profiles, | |
|
alito
2017/06/09 01:52:07
Please move this to the unnamed namespace in the .
ftirelo
2017/06/09 21:24:55
Done.
| |
| 88 std::vector<Profile*>* profiles_to_reset); | |
| 89 | |
| 90 private: | |
| 91 DISALLOW_COPY_AND_ASSIGN(PostCleanupSettingsResetter); | |
| 92 }; | |
| 93 | |
| 94 } // namespace safe_browsing | |
| 95 | |
| 96 #endif // CHROME_BROWSER_SAFE_BROWSING_CHROME_CLEANER_SETTINGS_RESETTER_WIN_H_ | |
| OLD | NEW |