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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 base::Time removal_begin; | 161 base::Time removal_begin; |
178 | 162 |
179 // The removal mask (see the RemoveDataMask enum for details). | 163 // The removal mask (see the RemoveDataMask enum for details). |
180 int removal_mask; | 164 int removal_mask; |
181 | 165 |
182 // The origin type mask (see BrowsingDataHelper::OriginTypeMask for | 166 // The origin type mask (see BrowsingDataHelper::OriginTypeMask for |
183 // details). | 167 // details). |
184 int origin_type_mask; | 168 int origin_type_mask; |
185 }; | 169 }; |
186 | 170 |
187 struct TimeRange { | |
188 TimeRange(base::Time begin, base::Time end) : begin(begin), end(end) {} | |
189 | |
190 base::Time begin; | |
191 base::Time end; | |
192 }; | |
193 | |
194 // Observer is notified when the removal is done. Done means keywords have | 171 // Observer is notified when the removal is done. Done means keywords have |
195 // been deleted, cache cleared and all other tasks scheduled. | 172 // been deleted, cache cleared and all other tasks scheduled. |
196 class Observer { | 173 class Observer { |
197 public: | 174 public: |
198 virtual void OnBrowsingDataRemoverDone() = 0; | 175 virtual void OnBrowsingDataRemoverDone() = 0; |
199 | 176 |
200 protected: | 177 protected: |
201 virtual ~Observer() {} | 178 virtual ~Observer() {} |
202 }; | 179 }; |
203 | 180 |
(...skipping 10 matching lines...) Expand all Loading... |
214 // and will be prevented from completing until after the callback | 191 // and will be prevented from completing until after the callback |
215 // |continue_to_completion| is run. | 192 // |continue_to_completion| is run. |
216 virtual void OnBrowsingDataRemoverWouldComplete( | 193 virtual void OnBrowsingDataRemoverWouldComplete( |
217 BrowsingDataRemover* remover, | 194 BrowsingDataRemover* remover, |
218 const base::Closure& continue_to_completion) = 0; | 195 const base::Closure& continue_to_completion) = 0; |
219 | 196 |
220 protected: | 197 protected: |
221 virtual ~CompletionInhibitor() {} | 198 virtual ~CompletionInhibitor() {} |
222 }; | 199 }; |
223 | 200 |
224 static TimeRange Unbounded(); | |
225 | |
226 static TimeRange Period(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 | |
231 // Is the BrowsingDataRemover currently in the process of removing data? | 201 // Is the BrowsingDataRemover currently in the process of removing data? |
232 bool is_removing() { return is_removing_; } | 202 bool is_removing() { return is_removing_; } |
233 | 203 |
234 // Sets a CompletionInhibitor, which will be notified each time an instance is | 204 // 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 | 205 // about to complete a browsing data removal process, and will be able to |
236 // artificially delay the completion. | 206 // artificially delay the completion. |
237 // TODO(crbug.com/483528): Make this non-static. | 207 // TODO(crbug.com/483528): Make this non-static. |
238 static void set_completion_inhibitor_for_testing( | 208 static void set_completion_inhibitor_for_testing( |
239 CompletionInhibitor* inhibitor) { | 209 CompletionInhibitor* inhibitor) { |
240 completion_inhibitor_ = inhibitor; | 210 completion_inhibitor_ = inhibitor; |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 // not initialised, so the registry must be mocked out. | 486 // not initialised, so the registry must be mocked out. |
517 std::unique_ptr<WebappRegistry> webapp_registry_; | 487 std::unique_ptr<WebappRegistry> webapp_registry_; |
518 #endif | 488 #endif |
519 | 489 |
520 base::WeakPtrFactory<BrowsingDataRemover> weak_ptr_factory_; | 490 base::WeakPtrFactory<BrowsingDataRemover> weak_ptr_factory_; |
521 | 491 |
522 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemover); | 492 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemover); |
523 }; | 493 }; |
524 | 494 |
525 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_H_ | 495 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_H_ |
OLD | NEW |