| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_PROFILE_RESETTER_PROFILE_RESETTER_H_ | 5 #ifndef CHROME_BROWSER_PROFILE_RESETTER_PROFILE_RESETTER_H_ |
| 6 #define CHROME_BROWSER_PROFILE_RESETTER_PROFILE_RESETTER_H_ | 6 #define CHROME_BROWSER_PROFILE_RESETTER_PROFILE_RESETTER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/threading/non_thread_safe.h" | 10 #include "base/threading/non_thread_safe.h" |
| 11 | 11 |
| 12 class Profile; | 12 class Profile; |
| 13 | 13 |
| 14 // This class allows resetting certain aspects of a profile to default values. | 14 // This class allows resetting certain aspects of a profile to default values. |
| 15 // It is used in case the profile has been damaged due to malware or bad user | 15 // It is used in case the profile has been damaged due to malware or bad user |
| 16 // settings. | 16 // settings. |
| 17 class ProfileResetter : public base::NonThreadSafe { | 17 class ProfileResetter : public base::NonThreadSafe { |
| 18 public: | 18 public: |
| 19 // Flags indicating what aspects of a profile shall be reset. | 19 // Flags indicating what aspects of a profile shall be reset. |
| 20 enum Resettable { | 20 enum Resettable { |
| 21 DEFAULT_SEARCH_ENGINE = 1 << 0, | 21 DEFAULT_SEARCH_ENGINE = 1 << 0, |
| 22 HOMEPAGE = 1 << 1, | 22 HOMEPAGE = 1 << 1, |
| 23 CONTENT_SETTINGS = 1 << 2, | 23 CONTENT_SETTINGS = 1 << 2, |
| 24 COOKIES_AND_SITE_DATA = 1 << 3, | 24 COOKIES_AND_SITE_DATA = 1 << 3, |
| 25 EXTENSIONS = 1 << 4, | 25 EXTENSIONS = 1 << 4, |
| 26 STARTUP_PAGE = 1 << 5, |
| 26 // Update ALL if you add new values and check whether the type of | 27 // Update ALL if you add new values and check whether the type of |
| 27 // ResettableFlags needs to be enlarged. | 28 // ResettableFlags needs to be enlarged. |
| 28 ALL = DEFAULT_SEARCH_ENGINE | HOMEPAGE | CONTENT_SETTINGS | | 29 ALL = DEFAULT_SEARCH_ENGINE | HOMEPAGE | CONTENT_SETTINGS | |
| 29 COOKIES_AND_SITE_DATA | EXTENSIONS | 30 COOKIES_AND_SITE_DATA | EXTENSIONS | STARTUP_PAGE |
| 30 }; | 31 }; |
| 31 | 32 |
| 32 // How to handle extensions that shall be reset. | 33 // How to handle extensions that shall be reset. |
| 33 enum ExtensionHandling { | 34 enum ExtensionHandling { |
| 34 DISABLE_EXTENSIONS, | 35 DISABLE_EXTENSIONS, |
| 35 UNINSTALL_EXTENSIONS | 36 UNINSTALL_EXTENSIONS |
| 36 }; | 37 }; |
| 37 | 38 |
| 38 // Bit vector for Resettable enum. | 39 // Bit vector for Resettable enum. |
| 39 typedef uint32 ResettableFlags; | 40 typedef uint32 ResettableFlags; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 54 private: | 55 private: |
| 55 // Marks |resettable| as done and triggers |callback_| if all pending jobs | 56 // Marks |resettable| as done and triggers |callback_| if all pending jobs |
| 56 // have completed. | 57 // have completed. |
| 57 void MarkAsDone(Resettable resettable); | 58 void MarkAsDone(Resettable resettable); |
| 58 | 59 |
| 59 void ResetDefaultSearchEngine(); | 60 void ResetDefaultSearchEngine(); |
| 60 void ResetHomepage(); | 61 void ResetHomepage(); |
| 61 void ResetContentSettings(); | 62 void ResetContentSettings(); |
| 62 void ResetCookiesAndSiteData(); | 63 void ResetCookiesAndSiteData(); |
| 63 void ResetExtensions(ExtensionHandling extension_handling); | 64 void ResetExtensions(ExtensionHandling extension_handling); |
| 65 void ResetStartPage(); |
| 64 | 66 |
| 65 Profile* profile_; | 67 Profile* profile_; |
| 66 | 68 |
| 67 // Flags of a Resetable indicating which reset operations we are still waiting | 69 // Flags of a Resetable indicating which reset operations we are still waiting |
| 68 // for. | 70 // for. |
| 69 ResettableFlags pending_reset_flags_; | 71 ResettableFlags pending_reset_flags_; |
| 70 | 72 |
| 71 // Called on UI thread when reset has been completed. | 73 // Called on UI thread when reset has been completed. |
| 72 base::Closure callback_; | 74 base::Closure callback_; |
| 73 | 75 |
| 74 DISALLOW_COPY_AND_ASSIGN(ProfileResetter); | 76 DISALLOW_COPY_AND_ASSIGN(ProfileResetter); |
| 75 }; | 77 }; |
| 76 | 78 |
| 77 #endif // CHROME_BROWSER_PROFILE_RESETTER_PROFILE_RESETTER_H_ | 79 #endif // CHROME_BROWSER_PROFILE_RESETTER_PROFILE_RESETTER_H_ |
| OLD | NEW |