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 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
11 #include "content/public/browser/notification_observer.h" | 12 #include "content/public/browser/notification_observer.h" |
12 #include "content/public/browser/notification_registrar.h" | 13 #include "content/public/browser/notification_registrar.h" |
13 | 14 |
14 class Profile; | 15 class Profile; |
15 class TemplateURLService; | 16 class TemplateURLService; |
16 | 17 |
17 // This class allows resetting certain aspects of a profile to default values. | 18 // This class allows resetting certain aspects of a profile to default values. |
18 // It is used in case the profile has been damaged due to malware or bad user | 19 // It is used in case the profile has been damaged due to malware or bad user |
19 // settings. | 20 // settings. |
20 class ProfileResetter : public base::NonThreadSafe, | 21 class ProfileResetter : public base::NonThreadSafe, |
21 public content::NotificationObserver { | 22 public content::NotificationObserver, |
| 23 public BrowsingDataRemover::Observer { |
22 public: | 24 public: |
23 // Flags indicating what aspects of a profile shall be reset. | 25 // Flags indicating what aspects of a profile shall be reset. |
24 enum Resettable { | 26 enum Resettable { |
25 DEFAULT_SEARCH_ENGINE = 1 << 0, | 27 DEFAULT_SEARCH_ENGINE = 1 << 0, |
26 HOMEPAGE = 1 << 1, | 28 HOMEPAGE = 1 << 1, |
27 CONTENT_SETTINGS = 1 << 2, | 29 CONTENT_SETTINGS = 1 << 2, |
28 COOKIES_AND_SITE_DATA = 1 << 3, | 30 COOKIES_AND_SITE_DATA = 1 << 3, |
29 EXTENSIONS = 1 << 4, | 31 EXTENSIONS = 1 << 4, |
30 STARTUP_PAGES = 1 << 5, | 32 STARTUP_PAGES = 1 << 5, |
31 PINNED_TABS = 1 << 6, | 33 PINNED_TABS = 1 << 6, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 void ResetCookiesAndSiteData(); | 65 void ResetCookiesAndSiteData(); |
64 void ResetExtensions(); | 66 void ResetExtensions(); |
65 void ResetStartupPages(); | 67 void ResetStartupPages(); |
66 void ResetPinnedTabs(); | 68 void ResetPinnedTabs(); |
67 | 69 |
68 // content::NotificationObserver: | 70 // content::NotificationObserver: |
69 virtual void Observe(int type, | 71 virtual void Observe(int type, |
70 const content::NotificationSource& source, | 72 const content::NotificationSource& source, |
71 const content::NotificationDetails& details) OVERRIDE; | 73 const content::NotificationDetails& details) OVERRIDE; |
72 | 74 |
| 75 // BrowsingDataRemover::Observer: |
| 76 virtual void OnBrowsingDataRemoverDone() OVERRIDE; |
| 77 |
73 Profile* profile_; | 78 Profile* profile_; |
74 TemplateURLService* template_url_service_; | 79 TemplateURLService* template_url_service_; |
75 | 80 |
76 // Flags of a Resetable indicating which reset operations we are still waiting | 81 // Flags of a Resetable indicating which reset operations we are still waiting |
77 // for. | 82 // for. |
78 ResettableFlags pending_reset_flags_; | 83 ResettableFlags pending_reset_flags_; |
79 | 84 |
80 // Called on UI thread when reset has been completed. | 85 // Called on UI thread when reset has been completed. |
81 base::Closure callback_; | 86 base::Closure callback_; |
82 | 87 |
83 content::NotificationRegistrar registrar_; | 88 content::NotificationRegistrar registrar_; |
84 | 89 |
| 90 // If non-null it means removal is in progress. BrowsingDataRemover takes care |
| 91 // of deleting itself when done. |
| 92 BrowsingDataRemover* cookies_remover_; |
| 93 |
85 DISALLOW_COPY_AND_ASSIGN(ProfileResetter); | 94 DISALLOW_COPY_AND_ASSIGN(ProfileResetter); |
86 }; | 95 }; |
87 | 96 |
88 #endif // CHROME_BROWSER_PROFILE_RESETTER_PROFILE_RESETTER_H_ | 97 #endif // CHROME_BROWSER_PROFILE_RESETTER_PROFILE_RESETTER_H_ |
OLD | NEW |