OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 IOS_CHROME_BROWSER_BROWSING_DATA_IOS_CHROME_BROWSING_DATA_REMOVER_H_ | 5 #ifndef IOS_CHROME_BROWSER_BROWSING_DATA_IOS_CHROME_BROWSING_DATA_REMOVER_H_ |
6 #define IOS_CHROME_BROWSER_BROWSING_DATA_IOS_CHROME_BROWSING_DATA_REMOVER_H_ | 6 #define IOS_CHROME_BROWSER_BROWSING_DATA_IOS_CHROME_BROWSING_DATA_REMOVER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <set> | 9 #include <set> |
10 | 10 |
11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
15 #include "base/sequenced_task_runner_helpers.h" | 15 #include "base/sequenced_task_runner_helpers.h" |
16 #include "base/task/cancelable_task_tracker.h" | 16 #include "base/task/cancelable_task_tracker.h" |
17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
| 18 #include "components/browsing_data/core/browsing_data_utils.h" |
18 #include "components/prefs/pref_member.h" | 19 #include "components/prefs/pref_member.h" |
19 #include "components/search_engines/template_url_service.h" | 20 #include "components/search_engines/template_url_service.h" |
20 #include "url/gurl.h" | 21 #include "url/gurl.h" |
21 #include "url/origin.h" | 22 #include "url/origin.h" |
22 | 23 |
23 namespace ios { | 24 namespace ios { |
24 class ChromeBrowserState; | 25 class ChromeBrowserState; |
25 } | 26 } |
26 | 27 |
27 namespace net { | 28 namespace net { |
28 class URLRequestContextGetter; | 29 class URLRequestContextGetter; |
29 } | 30 } |
30 | 31 |
31 // IOSChromeBrowsingDataRemover is responsible for removing data related to | 32 // IOSChromeBrowsingDataRemover is responsible for removing data related to |
32 // browsing: visits in url database, downloads, cookies ... | 33 // browsing: visits in url database, downloads, cookies ... |
33 | 34 |
34 class IOSChromeBrowsingDataRemover { | 35 class IOSChromeBrowsingDataRemover { |
35 public: | 36 public: |
36 // Time period ranges available when doing browsing data removals. | |
37 enum TimePeriod { EVERYTHING }; | |
38 | |
39 // Mask used for Remove. | 37 // Mask used for Remove. |
40 enum RemoveDataMask { | 38 enum RemoveDataMask { |
41 REMOVE_APPCACHE = 1 << 0, | 39 REMOVE_APPCACHE = 1 << 0, |
42 REMOVE_CACHE = 1 << 1, | 40 REMOVE_CACHE = 1 << 1, |
43 REMOVE_COOKIES = 1 << 2, | 41 REMOVE_COOKIES = 1 << 2, |
44 REMOVE_DOWNLOADS = 1 << 3, | 42 REMOVE_DOWNLOADS = 1 << 3, |
45 REMOVE_FORM_DATA = 1 << 4, | 43 REMOVE_FORM_DATA = 1 << 4, |
46 // In addition to visits, REMOVE_HISTORY removes keywords and last session. | 44 // In addition to visits, REMOVE_HISTORY removes keywords and last session. |
47 REMOVE_HISTORY = 1 << 5, | 45 REMOVE_HISTORY = 1 << 5, |
48 REMOVE_INDEXEDDB = 1 << 6, | 46 REMOVE_INDEXEDDB = 1 << 6, |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 using Callback = base::Callback<void(const NotificationDetails&)>; | 110 using Callback = base::Callback<void(const NotificationDetails&)>; |
113 using CallbackSubscription = std::unique_ptr< | 111 using CallbackSubscription = std::unique_ptr< |
114 base::CallbackList<void(const NotificationDetails&)>::Subscription>; | 112 base::CallbackList<void(const NotificationDetails&)>::Subscription>; |
115 | 113 |
116 // Creates a IOSChromeBrowsingDataRemover bound to a specific period of time | 114 // Creates a IOSChromeBrowsingDataRemover bound to a specific period of time |
117 // (as defined via a TimePeriod). Returns a raw pointer, as | 115 // (as defined via a TimePeriod). Returns a raw pointer, as |
118 // IOSChromeBrowsingDataRemover retains ownership of itself, and deletes | 116 // IOSChromeBrowsingDataRemover retains ownership of itself, and deletes |
119 // itself once finished. | 117 // itself once finished. |
120 static IOSChromeBrowsingDataRemover* CreateForPeriod( | 118 static IOSChromeBrowsingDataRemover* CreateForPeriod( |
121 ios::ChromeBrowserState* browser_state, | 119 ios::ChromeBrowserState* browser_state, |
122 TimePeriod period); | 120 browsing_data::TimePeriod period); |
123 | |
124 // Calculate the begin time for the deletion range specified by |time_period|. | |
125 static base::Time CalculateBeginDeleteTime(TimePeriod time_period); | |
126 | 121 |
127 // Is the IOSChromeBrowsingDataRemover currently in the process of removing | 122 // Is the IOSChromeBrowsingDataRemover currently in the process of removing |
128 // data? | 123 // data? |
129 static bool is_removing() { return is_removing_; } | 124 static bool is_removing() { return is_removing_; } |
130 | 125 |
131 // Add a callback to the list of callbacks to be called during a browsing data | 126 // Add a callback to the list of callbacks to be called during a browsing data |
132 // removal event. Returns a subscription object that can be used to | 127 // removal event. Returns a subscription object that can be used to |
133 // un-register the callback. | 128 // un-register the callback. |
134 static CallbackSubscription RegisterOnBrowsingDataRemovedCallback( | 129 static CallbackSubscription RegisterOnBrowsingDataRemovedCallback( |
135 const Callback& callback); | 130 const Callback& callback); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 | 257 |
263 // Used if we need to clear history. | 258 // Used if we need to clear history. |
264 base::CancelableTaskTracker history_task_tracker_; | 259 base::CancelableTaskTracker history_task_tracker_; |
265 | 260 |
266 std::unique_ptr<TemplateURLService::Subscription> template_url_sub_; | 261 std::unique_ptr<TemplateURLService::Subscription> template_url_sub_; |
267 | 262 |
268 DISALLOW_COPY_AND_ASSIGN(IOSChromeBrowsingDataRemover); | 263 DISALLOW_COPY_AND_ASSIGN(IOSChromeBrowsingDataRemover); |
269 }; | 264 }; |
270 | 265 |
271 #endif // IOS_CHROME_BROWSER_BROWSING_DATA_IOS_CHROME_BROWSING_DATA_REMOVER_H_ | 266 #endif // IOS_CHROME_BROWSER_BROWSING_DATA_IOS_CHROME_BROWSING_DATA_REMOVER_H_ |
OLD | NEW |