| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_BROWSING_DATA_BROWSING_DATA_REMOVER_H_ | 5 #ifndef CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_H_ |
| 6 #define CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_H_ | 6 #define CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <set> | 10 #include <set> |
| 11 | 11 |
| 12 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
| 13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 17 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
| 18 #include "base/sequenced_task_runner_helpers.h" | 18 #include "base/sequenced_task_runner_helpers.h" |
| 19 #include "base/synchronization/waitable_event_watcher.h" | 19 #include "base/synchronization/waitable_event_watcher.h" |
| 20 #include "base/task/cancelable_task_tracker.h" | 20 #include "base/task/cancelable_task_tracker.h" |
| 21 #include "base/time/time.h" | 21 #include "base/time/time.h" |
| 22 #include "build/build_config.h" | 22 #include "build/build_config.h" |
| 23 #include "chrome/common/features.h" | 23 #include "chrome/common/features.h" |
| 24 #include "components/browsing_data/browsing_data_utils.h" |
| 24 #include "components/content_settings/core/common/content_settings_pattern.h" | 25 #include "components/content_settings/core/common/content_settings_pattern.h" |
| 25 #include "components/content_settings/core/common/content_settings_types.h" | 26 #include "components/content_settings/core/common/content_settings_types.h" |
| 26 #include "components/keyed_service/core/keyed_service.h" | 27 #include "components/keyed_service/core/keyed_service.h" |
| 27 #include "components/offline_pages/offline_page_model.h" | 28 #include "components/offline_pages/offline_page_model.h" |
| 28 #include "components/prefs/pref_member.h" | 29 #include "components/prefs/pref_member.h" |
| 29 #include "components/search_engines/template_url_service.h" | 30 #include "components/search_engines/template_url_service.h" |
| 30 #include "storage/common/quota/quota_types.h" | 31 #include "storage/common/quota/quota_types.h" |
| 31 #include "url/gurl.h" | 32 #include "url/gurl.h" |
| 32 | 33 |
| 33 #if defined(ENABLE_PLUGINS) | 34 #if defined(ENABLE_PLUGINS) |
| (...skipping 29 matching lines...) Expand all Loading... |
| 63 #endif | 64 #endif |
| 64 | 65 |
| 65 // BrowsingDataRemover is responsible for removing data related to browsing: | 66 // BrowsingDataRemover is responsible for removing data related to browsing: |
| 66 // visits in url database, downloads, cookies ... | 67 // visits in url database, downloads, cookies ... |
| 67 class BrowsingDataRemover : public KeyedService | 68 class BrowsingDataRemover : public KeyedService |
| 68 #if defined(ENABLE_PLUGINS) | 69 #if defined(ENABLE_PLUGINS) |
| 69 , public PepperFlashSettingsManager::Client | 70 , public PepperFlashSettingsManager::Client |
| 70 #endif | 71 #endif |
| 71 { | 72 { |
| 72 public: | 73 public: |
| 73 // Time period ranges available when doing browsing data removals. | |
| 74 // TODO(msramek): As this is now reused on Android, we should move it | |
| 75 // to browsing_data_counter_utils.h (and rename appropriately), so that | |
| 76 // all fundamental types related to browsing data on all platforms are in | |
| 77 // one place. | |
| 78 // | |
| 79 // A Java counterpart will be generated for this enum. | |
| 80 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser | |
| 81 enum TimePeriod { | |
| 82 LAST_HOUR = 0, | |
| 83 LAST_DAY, | |
| 84 LAST_WEEK, | |
| 85 FOUR_WEEKS, | |
| 86 EVERYTHING, | |
| 87 TIME_PERIOD_LAST = EVERYTHING | |
| 88 }; | |
| 89 | |
| 90 // Mask used for Remove. | 74 // Mask used for Remove. |
| 91 enum RemoveDataMask { | 75 enum RemoveDataMask { |
| 92 REMOVE_APPCACHE = 1 << 0, | 76 REMOVE_APPCACHE = 1 << 0, |
| 93 REMOVE_CACHE = 1 << 1, | 77 REMOVE_CACHE = 1 << 1, |
| 94 REMOVE_COOKIES = 1 << 2, | 78 REMOVE_COOKIES = 1 << 2, |
| 95 REMOVE_DOWNLOADS = 1 << 3, | 79 REMOVE_DOWNLOADS = 1 << 3, |
| 96 REMOVE_FILE_SYSTEMS = 1 << 4, | 80 REMOVE_FILE_SYSTEMS = 1 << 4, |
| 97 REMOVE_FORM_DATA = 1 << 5, | 81 REMOVE_FORM_DATA = 1 << 5, |
| 98 // In addition to visits, REMOVE_HISTORY removes keywords, last session and | 82 // In addition to visits, REMOVE_HISTORY removes keywords, last session and |
| 99 // passwords UI statistics. | 83 // passwords UI statistics. |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 virtual void OnBrowsingDataRemoverWouldComplete( | 200 virtual void OnBrowsingDataRemoverWouldComplete( |
| 217 BrowsingDataRemover* remover, | 201 BrowsingDataRemover* remover, |
| 218 const base::Closure& continue_to_completion) = 0; | 202 const base::Closure& continue_to_completion) = 0; |
| 219 | 203 |
| 220 protected: | 204 protected: |
| 221 virtual ~CompletionInhibitor() {} | 205 virtual ~CompletionInhibitor() {} |
| 222 }; | 206 }; |
| 223 | 207 |
| 224 static TimeRange Unbounded(); | 208 static TimeRange Unbounded(); |
| 225 | 209 |
| 226 static TimeRange Period(TimePeriod period); | 210 static TimeRange Period(browsing_data::TimePeriod period); |
| 227 | |
| 228 // Calculate the begin time for the deletion range specified by |time_period|. | |
| 229 static base::Time CalculateBeginDeleteTime(TimePeriod time_period); | |
| 230 | 211 |
| 231 // Is the BrowsingDataRemover currently in the process of removing data? | 212 // Is the BrowsingDataRemover currently in the process of removing data? |
| 232 bool is_removing() { return is_removing_; } | 213 bool is_removing() { return is_removing_; } |
| 233 | 214 |
| 234 // Sets a CompletionInhibitor, which will be notified each time an instance is | 215 // Sets a CompletionInhibitor, which will be notified each time an instance is |
| 235 // about to complete a browsing data removal process, and will be able to | 216 // about to complete a browsing data removal process, and will be able to |
| 236 // artificially delay the completion. | 217 // artificially delay the completion. |
| 237 // TODO(crbug.com/483528): Make this non-static. | 218 // TODO(crbug.com/483528): Make this non-static. |
| 238 static void set_completion_inhibitor_for_testing( | 219 static void set_completion_inhibitor_for_testing( |
| 239 CompletionInhibitor* inhibitor) { | 220 CompletionInhibitor* inhibitor) { |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 // not initialised, so the registry must be mocked out. | 497 // not initialised, so the registry must be mocked out. |
| 517 std::unique_ptr<WebappRegistry> webapp_registry_; | 498 std::unique_ptr<WebappRegistry> webapp_registry_; |
| 518 #endif | 499 #endif |
| 519 | 500 |
| 520 base::WeakPtrFactory<BrowsingDataRemover> weak_ptr_factory_; | 501 base::WeakPtrFactory<BrowsingDataRemover> weak_ptr_factory_; |
| 521 | 502 |
| 522 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemover); | 503 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemover); |
| 523 }; | 504 }; |
| 524 | 505 |
| 525 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_H_ | 506 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_H_ |
| OLD | NEW |