| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <utility> | 11 #include <utility> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
| 16 #include "base/macros.h" | 16 #include "base/macros.h" |
| 17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
| 18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
| 19 #include "base/strings/string16.h" | 19 #include "base/strings/string16.h" |
| 20 #include "base/threading/non_thread_safe.h" | 20 #include "base/threading/non_thread_safe.h" |
| 21 #include "chrome/browser/browsing_data/browsing_data_remover.h" | |
| 22 #include "chrome/browser/profile_resetter/brandcoded_default_settings.h" | 21 #include "chrome/browser/profile_resetter/brandcoded_default_settings.h" |
| 23 #include "components/search_engines/template_url_service.h" | 22 #include "components/search_engines/template_url_service.h" |
| 23 #include "content/public/browser/browsing_data_remover.h" |
| 24 | 24 |
| 25 class Profile; | 25 class Profile; |
| 26 | 26 |
| 27 namespace base { | 27 namespace base { |
| 28 class CancellationFlag; | 28 class CancellationFlag; |
| 29 } | 29 } |
| 30 | 30 |
| 31 // This class allows resetting certain aspects of a profile to default values. | 31 // This class allows resetting certain aspects of a profile to default values. |
| 32 // It is used in case the profile has been damaged due to malware or bad user | 32 // It is used in case the profile has been damaged due to malware or bad user |
| 33 // settings. | 33 // settings. |
| 34 class ProfileResetter : public base::NonThreadSafe, | 34 class ProfileResetter : public base::NonThreadSafe, |
| 35 public BrowsingDataRemover::Observer { | 35 public content::BrowsingDataRemover::Observer { |
| 36 public: | 36 public: |
| 37 // Flags indicating what aspects of a profile shall be reset. | 37 // Flags indicating what aspects of a profile shall be reset. |
| 38 enum Resettable { | 38 enum Resettable { |
| 39 DEFAULT_SEARCH_ENGINE = 1 << 0, | 39 DEFAULT_SEARCH_ENGINE = 1 << 0, |
| 40 HOMEPAGE = 1 << 1, | 40 HOMEPAGE = 1 << 1, |
| 41 CONTENT_SETTINGS = 1 << 2, | 41 CONTENT_SETTINGS = 1 << 2, |
| 42 COOKIES_AND_SITE_DATA = 1 << 3, | 42 COOKIES_AND_SITE_DATA = 1 << 3, |
| 43 EXTENSIONS = 1 << 4, | 43 EXTENSIONS = 1 << 4, |
| 44 STARTUP_PAGES = 1 << 5, | 44 STARTUP_PAGES = 1 << 5, |
| 45 PINNED_TABS = 1 << 6, | 45 PINNED_TABS = 1 << 6, |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 | 95 |
| 96 // Flags of a Resetable indicating which reset operations we are still waiting | 96 // Flags of a Resetable indicating which reset operations we are still waiting |
| 97 // for. | 97 // for. |
| 98 ResettableFlags pending_reset_flags_; | 98 ResettableFlags pending_reset_flags_; |
| 99 | 99 |
| 100 // Called on UI thread when reset has been completed. | 100 // Called on UI thread when reset has been completed. |
| 101 base::Closure callback_; | 101 base::Closure callback_; |
| 102 | 102 |
| 103 // If non-null it means removal is in progress. BrowsingDataRemover takes care | 103 // If non-null it means removal is in progress. BrowsingDataRemover takes care |
| 104 // of deleting itself when done. | 104 // of deleting itself when done. |
| 105 BrowsingDataRemover* cookies_remover_; | 105 content::BrowsingDataRemover* cookies_remover_; |
| 106 | 106 |
| 107 std::unique_ptr<TemplateURLService::Subscription> template_url_service_sub_; | 107 std::unique_ptr<TemplateURLService::Subscription> template_url_service_sub_; |
| 108 | 108 |
| 109 base::WeakPtrFactory<ProfileResetter> weak_ptr_factory_; | 109 base::WeakPtrFactory<ProfileResetter> weak_ptr_factory_; |
| 110 | 110 |
| 111 DISALLOW_COPY_AND_ASSIGN(ProfileResetter); | 111 DISALLOW_COPY_AND_ASSIGN(ProfileResetter); |
| 112 }; | 112 }; |
| 113 | 113 |
| 114 // Path to shortcut and command line arguments. | 114 // Path to shortcut and command line arguments. |
| 115 typedef std::pair<base::FilePath, base::string16> ShortcutCommand; | 115 typedef std::pair<base::FilePath, base::string16> ShortcutCommand; |
| 116 | 116 |
| 117 typedef base::RefCountedData<base::CancellationFlag> SharedCancellationFlag; | 117 typedef base::RefCountedData<base::CancellationFlag> SharedCancellationFlag; |
| 118 | 118 |
| 119 // On Windows returns all the shortcuts which launch Chrome and corresponding | 119 // On Windows returns all the shortcuts which launch Chrome and corresponding |
| 120 // arguments. |cancel| can be passed to abort the operation earlier. | 120 // arguments. |cancel| can be passed to abort the operation earlier. |
| 121 // Call on FILE thread. | 121 // Call on FILE thread. |
| 122 std::vector<ShortcutCommand> GetChromeLaunchShortcuts( | 122 std::vector<ShortcutCommand> GetChromeLaunchShortcuts( |
| 123 const scoped_refptr<SharedCancellationFlag>& cancel); | 123 const scoped_refptr<SharedCancellationFlag>& cancel); |
| 124 | 124 |
| 125 #endif // CHROME_BROWSER_PROFILE_RESETTER_PROFILE_RESETTER_H_ | 125 #endif // CHROME_BROWSER_PROFILE_RESETTER_PROFILE_RESETTER_H_ |
| OLD | NEW |