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