[email protected] | eb7974c | 2012-01-25 17:38:48 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4 | |
[email protected] | b0cb5e8 | 2012-07-19 19:22:47 | [diff] [blame] | 5 | #ifndef CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_H_ |
| 6 | #define CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_H_ |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 7 | |
[email protected] | bb95acab | 2011-11-16 22:22:27 | [diff] [blame] | 8 | #include <set> |
[email protected] | 654512b | 2010-09-01 02:09:42 | [diff] [blame] | 9 | |
[email protected] | 9226938 | 2012-03-03 09:00:08 | [diff] [blame] | 10 | #include "base/gtest_prod_util.h" |
[email protected] | 3b63f8f4 | 2011-03-28 01:54:15 | [diff] [blame] | 11 | #include "base/memory/ref_counted.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 12 | #include "base/observer_list.h" |
[email protected] | 1ab137b | 2013-03-21 03:33:18 | [diff] [blame] | 13 | #include "base/prefs/pref_member.h" |
[email protected] | fb44196 | 2013-05-08 05:35:24 | [diff] [blame] | 14 | #include "base/sequenced_task_runner_helpers.h" |
[email protected] | c7d58d6 | 2011-01-21 10:27:18 | [diff] [blame] | 15 | #include "base/synchronization/waitable_event_watcher.h" |
[email protected] | e95b717f | 2014-02-06 13:47:13 | [diff] [blame] | 16 | #include "base/task/cancelable_task_tracker.h" |
[email protected] | 4dcb797 | 2013-06-28 15:15:41 | [diff] [blame] | 17 | #include "base/time/time.h" |
[email protected] | 1a55944 | 2012-05-27 07:18:46 | [diff] [blame] | 18 | #include "chrome/browser/pepper_flash_settings_manager.h" |
[email protected] | bf5c532d | 2014-07-05 00:29:53 | [diff] [blame] | 19 | #include "components/search_engines/template_url_service.h" |
[email protected] | 027188c | 2013-11-01 22:51:45 | [diff] [blame] | 20 | #if defined(OS_CHROMEOS) |
| 21 | #include "chromeos/dbus/dbus_method_call_status.h" |
| 22 | #endif |
pilgrim | 1633055 | 2014-09-10 01:32:22 | [diff] [blame] | 23 | #include "storage/common/quota/quota_types.h" |
[email protected] | 761fa470 | 2013-07-02 15:25:15 | [diff] [blame] | 24 | #include "url/gurl.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 25 | |
[email protected] | 19eb8015 | 2011-02-26 00:28:43 | [diff] [blame] | 26 | class ExtensionSpecialStoragePolicy; |
[email protected] | d6f37fc | 2011-02-13 23:58:41 | [diff] [blame] | 27 | class IOThread; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 28 | class Profile; |
| 29 | |
[email protected] | ec49c18 | 2014-06-11 18:03:47 | [diff] [blame] | 30 | namespace chrome_browser_net { |
| 31 | class Predictor; |
| 32 | } |
| 33 | |
[email protected] | d8e68201 | 2011-11-17 18:31:54 | [diff] [blame] | 34 | namespace content { |
| 35 | class PluginDataRemover; |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 36 | class StoragePartition; |
[email protected] | d8e68201 | 2011-11-17 18:31:54 | [diff] [blame] | 37 | } |
| 38 | |
[email protected] | d885bfe | 2010-05-21 18:29:45 | [diff] [blame] | 39 | namespace disk_cache { |
| 40 | class Backend; |
| 41 | } |
| 42 | |
[email protected] | abe2c03 | 2011-03-31 18:49:34 | [diff] [blame] | 43 | namespace net { |
| 44 | class URLRequestContextGetter; |
| 45 | } |
| 46 | |
[email protected] | cd501a7 | 2014-08-22 19:58:31 | [diff] [blame] | 47 | namespace storage { |
[email protected] | 9470417 | 2011-08-01 16:23:40 | [diff] [blame] | 48 | class QuotaManager; |
| 49 | } |
| 50 | |
[email protected] | 5f2aa72 | 2013-08-07 16:59:41 | [diff] [blame] | 51 | namespace content { |
| 52 | class DOMStorageContext; |
[email protected] | 832c03ac | 2012-11-06 12:43:24 | [diff] [blame] | 53 | struct LocalStorageUsageInfo; |
| 54 | struct SessionStorageUsageInfo; |
| 55 | } |
| 56 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 57 | // BrowsingDataRemover is responsible for removing data related to browsing: |
| 58 | // visits in url database, downloads, cookies ... |
| 59 | |
[email protected] | 3118d34 | 2013-10-08 17:29:03 | [diff] [blame] | 60 | class BrowsingDataRemover |
[email protected] | 6d17f639 | 2012-12-05 05:24:54 | [diff] [blame] | 61 | #if defined(ENABLE_PLUGINS) |
[email protected] | 3118d34 | 2013-10-08 17:29:03 | [diff] [blame] | 62 | : public PepperFlashSettingsManager::Client |
[email protected] | 6d17f639 | 2012-12-05 05:24:54 | [diff] [blame] | 63 | #endif |
[email protected] | 3118d34 | 2013-10-08 17:29:03 | [diff] [blame] | 64 | { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 65 | public: |
[email protected] | 25364e1 | 2009-05-22 01:37:19 | [diff] [blame] | 66 | // Time period ranges available when doing browsing data removals. |
| 67 | enum TimePeriod { |
[email protected] | 5c7d310 | 2010-02-11 00:25:44 | [diff] [blame] | 68 | LAST_HOUR = 0, |
| 69 | LAST_DAY, |
[email protected] | 25364e1 | 2009-05-22 01:37:19 | [diff] [blame] | 70 | LAST_WEEK, |
| 71 | FOUR_WEEKS, |
| 72 | EVERYTHING |
| 73 | }; |
| 74 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 75 | // Mask used for Remove. |
[email protected] | cf5db4c | 2011-06-20 21:02:57 | [diff] [blame] | 76 | enum RemoveDataMask { |
[email protected] | dceaa91 | 2011-09-06 17:17:23 | [diff] [blame] | 77 | REMOVE_APPCACHE = 1 << 0, |
| 78 | REMOVE_CACHE = 1 << 1, |
[email protected] | cf5db4c | 2011-06-20 21:02:57 | [diff] [blame] | 79 | REMOVE_COOKIES = 1 << 2, |
[email protected] | dceaa91 | 2011-09-06 17:17:23 | [diff] [blame] | 80 | REMOVE_DOWNLOADS = 1 << 3, |
| 81 | REMOVE_FILE_SYSTEMS = 1 << 4, |
| 82 | REMOVE_FORM_DATA = 1 << 5, |
| 83 | // In addition to visits, REMOVE_HISTORY removes keywords and last session. |
| 84 | REMOVE_HISTORY = 1 << 6, |
| 85 | REMOVE_INDEXEDDB = 1 << 7, |
| 86 | REMOVE_LOCAL_STORAGE = 1 << 8, |
[email protected] | 59eca0f | 2011-12-13 19:16:39 | [diff] [blame] | 87 | REMOVE_PLUGIN_DATA = 1 << 9, |
[email protected] | dceaa91 | 2011-09-06 17:17:23 | [diff] [blame] | 88 | REMOVE_PASSWORDS = 1 << 10, |
| 89 | REMOVE_WEBSQL = 1 << 11, |
[email protected] | 6b8a3c74 | 2014-07-25 00:25:35 | [diff] [blame] | 90 | REMOVE_CHANNEL_IDS = 1 << 12, |
[email protected] | 18a4d63c8 | 2012-05-25 23:37:03 | [diff] [blame] | 91 | REMOVE_CONTENT_LICENSES = 1 << 13, |
[email protected] | 1f19f12 | 2014-08-11 20:22:13 | [diff] [blame] | 92 | REMOVE_SERVICE_WORKERS = 1 << 14, |
[email protected] | 17ee2cc2 | 2014-02-08 00:32:58 | [diff] [blame] | 93 | #if defined(OS_ANDROID) |
[email protected] | 1f19f12 | 2014-08-11 20:22:13 | [diff] [blame] | 94 | REMOVE_APP_BANNER_DATA = 1 << 15, |
[email protected] | 17ee2cc2 | 2014-02-08 00:32:58 | [diff] [blame] | 95 | #endif |
[email protected] | c1c8bc9 | 2013-02-15 15:47:37 | [diff] [blame] | 96 | // The following flag is used only in tests. In normal usage, hosted app |
| 97 | // data is controlled by the REMOVE_COOKIES flag, applied to the |
| 98 | // protected-web origin. |
| 99 | REMOVE_HOSTED_APP_DATA_TESTONLY = 1 << 31, |
[email protected] | dceaa91 | 2011-09-06 17:17:23 | [diff] [blame] | 100 | |
| 101 | // "Site data" includes cookies, appcache, file systems, indexedDBs, local |
[email protected] | 1f19f12 | 2014-08-11 20:22:13 | [diff] [blame] | 102 | // storage, webSQL, service workers, and plugin data. |
| 103 | REMOVE_SITE_DATA = REMOVE_APPCACHE | REMOVE_COOKIES | REMOVE_FILE_SYSTEMS | |
[email protected] | 17ee2cc2 | 2014-02-08 00:32:58 | [diff] [blame] | 104 | REMOVE_INDEXEDDB | |
| 105 | REMOVE_LOCAL_STORAGE | |
| 106 | REMOVE_PLUGIN_DATA | |
[email protected] | 1f19f12 | 2014-08-11 20:22:13 | [diff] [blame] | 107 | REMOVE_SERVICE_WORKERS | |
[email protected] | 17ee2cc2 | 2014-02-08 00:32:58 | [diff] [blame] | 108 | REMOVE_WEBSQL | |
| 109 | #if defined(OS_ANDROID) |
| 110 | REMOVE_APP_BANNER_DATA | |
| 111 | #endif |
[email protected] | 6b8a3c74 | 2014-07-25 00:25:35 | [diff] [blame] | 112 | REMOVE_CHANNEL_IDS, |
[email protected] | 1cfad750 | 2013-07-29 22:17:40 | [diff] [blame] | 113 | |
| 114 | // Includes all the available remove options. Meant to be used by clients |
| 115 | // that wish to wipe as much data as possible from a Profile, to make it |
| 116 | // look like a new Profile. |
[email protected] | 1f19f12 | 2014-08-11 20:22:13 | [diff] [blame] | 117 | REMOVE_ALL = REMOVE_SITE_DATA | REMOVE_CACHE | REMOVE_DOWNLOADS | |
[email protected] | 17ee2cc2 | 2014-02-08 00:32:58 | [diff] [blame] | 118 | REMOVE_FORM_DATA | |
| 119 | REMOVE_HISTORY | |
| 120 | REMOVE_PASSWORDS | |
| 121 | REMOVE_CONTENT_LICENSES, |
[email protected] | cf5db4c | 2011-06-20 21:02:57 | [diff] [blame] | 122 | }; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 123 | |
[email protected] | 8d7554d8 | 2011-12-13 17:11:08 | [diff] [blame] | 124 | // When BrowsingDataRemover successfully removes data, a notification of type |
| 125 | // NOTIFICATION_BROWSING_DATA_REMOVED is triggered with a Details object of |
| 126 | // this type. |
| 127 | struct NotificationDetails { |
| 128 | NotificationDetails(); |
| 129 | NotificationDetails(const NotificationDetails& details); |
| 130 | NotificationDetails(base::Time removal_begin, |
[email protected] | 009cf7d7 | 2012-06-14 13:21:46 | [diff] [blame] | 131 | int removal_mask, |
| 132 | int origin_set_mask); |
[email protected] | 8d7554d8 | 2011-12-13 17:11:08 | [diff] [blame] | 133 | ~NotificationDetails(); |
| 134 | |
| 135 | // The beginning of the removal time range. |
| 136 | base::Time removal_begin; |
| 137 | |
[email protected] | 009cf7d7 | 2012-06-14 13:21:46 | [diff] [blame] | 138 | // The removal mask (see the RemoveDataMask enum for details). |
[email protected] | 8d7554d8 | 2011-12-13 17:11:08 | [diff] [blame] | 139 | int removal_mask; |
[email protected] | 009cf7d7 | 2012-06-14 13:21:46 | [diff] [blame] | 140 | |
| 141 | // The origin set mask (see BrowsingDataHelper::OriginSetMask for details). |
| 142 | int origin_set_mask; |
[email protected] | 8d7554d8 | 2011-12-13 17:11:08 | [diff] [blame] | 143 | }; |
| 144 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 145 | // Observer is notified when the removal is done. Done means keywords have |
| 146 | // been deleted, cache cleared and all other tasks scheduled. |
| 147 | class Observer { |
| 148 | public: |
| 149 | virtual void OnBrowsingDataRemoverDone() = 0; |
[email protected] | 135fd3b6 | 2009-12-16 01:07:08 | [diff] [blame] | 150 | |
| 151 | protected: |
| 152 | virtual ~Observer() {} |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 153 | }; |
| 154 | |
sque | df2e50a | 2015-01-26 21:19:57 | [diff] [blame] | 155 | using Callback = base::Callback<void(const NotificationDetails&)>; |
| 156 | using CallbackSubscription = scoped_ptr< |
| 157 | base::CallbackList<void(const NotificationDetails&)>::Subscription>; |
| 158 | |
[email protected] | a6b511a7 | 2014-04-17 23:51:34 | [diff] [blame] | 159 | // The completion inhibitor can artificially delay completion of the browsing |
| 160 | // data removal process. It is used during testing to simulate scenarios in |
| 161 | // which the deletion stalls or takes a very long time. |
| 162 | class CompletionInhibitor { |
| 163 | public: |
| 164 | // Invoked when a |remover| is just about to complete clearing browser data, |
| 165 | // and will be prevented from completing until after the callback |
| 166 | // |continue_to_completion| is run. |
| 167 | virtual void OnBrowsingDataRemoverWouldComplete( |
| 168 | BrowsingDataRemover* remover, |
| 169 | const base::Closure& continue_to_completion) = 0; |
| 170 | |
| 171 | protected: |
| 172 | virtual ~CompletionInhibitor() {} |
| 173 | }; |
| 174 | |
[email protected] | 38b892b4 | 2012-09-04 13:25:47 | [diff] [blame] | 175 | // Creates a BrowsingDataRemover object that removes data regardless of the |
| 176 | // time it was last modified. Returns a raw pointer, as BrowsingDataRemover |
| 177 | // retains ownership of itself, and deletes itself once finished. |
| 178 | static BrowsingDataRemover* CreateForUnboundedRange(Profile* profile); |
[email protected] | 25364e1 | 2009-05-22 01:37:19 | [diff] [blame] | 179 | |
[email protected] | 38b892b4 | 2012-09-04 13:25:47 | [diff] [blame] | 180 | // Creates a BrowsingDataRemover object bound on both sides by a time. Returns |
| 181 | // a raw pointer, as BrowsingDataRemover retains ownership of itself, and |
| 182 | // deletes itself once finished. |
| 183 | static BrowsingDataRemover* CreateForRange(Profile* profile, |
| 184 | base::Time delete_begin, |
| 185 | base::Time delete_end); |
| 186 | |
| 187 | // Creates a BrowsingDataRemover bound to a specific period of time (as |
| 188 | // defined via a TimePeriod). Returns a raw pointer, as BrowsingDataRemover |
| 189 | // retains ownership of itself, and deletes itself once finished. |
| 190 | static BrowsingDataRemover* CreateForPeriod(Profile* profile, |
| 191 | TimePeriod period); |
| 192 | |
[email protected] | c606b46 | 2013-02-04 10:51:10 | [diff] [blame] | 193 | // Calculate the begin time for the deletion range specified by |time_period|. |
| 194 | static base::Time CalculateBeginDeleteTime(TimePeriod time_period); |
| 195 | |
[email protected] | 38b892b4 | 2012-09-04 13:25:47 | [diff] [blame] | 196 | // Is the BrowsingDataRemover currently in the process of removing data? |
| 197 | static bool is_removing() { return is_removing_; } |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 198 | |
[email protected] | a6b511a7 | 2014-04-17 23:51:34 | [diff] [blame] | 199 | // Sets a CompletionInhibitor, which will be notified each time an instance is |
| 200 | // about to complete a browsing data removal process, and will be able to |
| 201 | // artificially delay the completion. |
| 202 | static void set_completion_inhibitor_for_testing( |
| 203 | CompletionInhibitor* inhibitor) { |
| 204 | completion_inhibitor_ = inhibitor; |
| 205 | } |
| 206 | |
sque | df2e50a | 2015-01-26 21:19:57 | [diff] [blame] | 207 | // Add a callback to the list of callbacks to be called during a browsing data |
| 208 | // removal event. Returns a subscription object that can be used to |
| 209 | // un-register the callback. |
| 210 | static CallbackSubscription RegisterOnBrowsingDataRemovedCallback( |
| 211 | const Callback& callback); |
| 212 | |
[email protected] | 3d4d4cf | 2012-06-04 10:40:55 | [diff] [blame] | 213 | // Removes the specified items related to browsing for all origins that match |
| 214 | // the provided |origin_set_mask| (see BrowsingDataHelper::OriginSetMask). |
| 215 | void Remove(int remove_mask, int origin_set_mask); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 216 | |
| 217 | void AddObserver(Observer* observer); |
| 218 | void RemoveObserver(Observer* observer); |
| 219 | |
| 220 | // Called when history deletion is done. |
| 221 | void OnHistoryDeletionDone(); |
| 222 | |
[email protected] | 55eb70e76 | 2012-02-20 17:38:39 | [diff] [blame] | 223 | // Used for testing. |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 224 | void OverrideStoragePartitionForTesting( |
| 225 | content::StoragePartition* storage_partition); |
[email protected] | 55eb70e76 | 2012-02-20 17:38:39 | [diff] [blame] | 226 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 227 | private: |
[email protected] | 6093d74 | 2011-08-26 16:37:18 | [diff] [blame] | 228 | // The clear API needs to be able to toggle removing_ in order to test that |
| 229 | // only one BrowsingDataRemover instance can be called at a time. |
[email protected] | 8f5090a5 | 2012-02-10 11:36:21 | [diff] [blame] | 230 | FRIEND_TEST_ALL_PREFIXES(ExtensionBrowsingDataTest, OneAtATime); |
[email protected] | 6093d74 | 2011-08-26 16:37:18 | [diff] [blame] | 231 | |
[email protected] | 8d4ec68 | 2012-02-17 12:20:17 | [diff] [blame] | 232 | // The BrowsingDataRemover tests need to be able to access the implementation |
| 233 | // of Remove(), as it exposes details that aren't yet available in the public |
| 234 | // API. As soon as those details are exposed via new methods, this should be |
| 235 | // removed. |
| 236 | // |
| 237 | // TODO(mkwst): See http://crbug.com/113621 |
| 238 | friend class BrowsingDataRemoverTest; |
| 239 | |
[email protected] | d885bfe | 2010-05-21 18:29:45 | [diff] [blame] | 240 | enum CacheState { |
| 241 | STATE_NONE, |
| 242 | STATE_CREATE_MAIN, |
| 243 | STATE_CREATE_MEDIA, |
| 244 | STATE_DELETE_MAIN, |
| 245 | STATE_DELETE_MEDIA, |
| 246 | STATE_DONE |
| 247 | }; |
| 248 | |
[email protected] | 38b892b4 | 2012-09-04 13:25:47 | [diff] [blame] | 249 | // Setter for |is_removing_|; DCHECKs that we can only start removing if we're |
| 250 | // not already removing, and vice-versa. |
| 251 | static void set_removing(bool is_removing); |
| 252 | |
| 253 | // Creates a BrowsingDataRemover to remove browser data from the specified |
| 254 | // profile in the specified time range. Use Remove to initiate the removal. |
| 255 | BrowsingDataRemover(Profile* profile, |
| 256 | base::Time delete_begin, |
| 257 | base::Time delete_end); |
| 258 | |
[email protected] | a25e59e | 2012-06-21 00:28:16 | [diff] [blame] | 259 | // BrowsingDataRemover deletes itself (using DeleteHelper) and is not supposed |
| 260 | // to be deleted by other objects so make destructor private and DeleteHelper |
[email protected] | 2474031 | 2009-09-30 14:22:54 | [diff] [blame] | 261 | // a friend. |
[email protected] | b1d18328 | 2011-12-30 04:32:58 | [diff] [blame] | 262 | friend class base::DeleteHelper<BrowsingDataRemover>; |
dcheng | d2d1920 | 2014-10-22 00:06:00 | [diff] [blame] | 263 | |
| 264 | // When plugins aren't enabled, there is no base class, so adding an override |
| 265 | // specifier would result in a compile error. |
| 266 | #if defined(ENABLE_PLUGINS) |
| 267 | ~BrowsingDataRemover() override; |
| 268 | #else |
| 269 | ~BrowsingDataRemover(); |
| 270 | #endif |
[email protected] | 2474031 | 2009-09-30 14:22:54 | [diff] [blame] | 271 | |
[email protected] | 3118d34 | 2013-10-08 17:29:03 | [diff] [blame] | 272 | // Callback for when TemplateURLService has finished loading. Clears the data, |
| 273 | // clears the respective waiting flag, and invokes NotifyAndDeleteIfDone. |
| 274 | void OnKeywordsLoaded(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 275 | |
tommycli | e86b298 | 2015-03-16 20:16:45 | [diff] [blame^] | 276 | // Called when plugin data has been cleared. Invokes NotifyAndDeleteIfDone. |
[email protected] | 329be05 | 2013-02-04 18:14:28 | [diff] [blame] | 277 | void OnWaitableEventSignaled(base::WaitableEvent* waitable_event); |
[email protected] | c7d58d6 | 2011-01-21 10:27:18 | [diff] [blame] | 278 | |
[email protected] | 6d17f639 | 2012-12-05 05:24:54 | [diff] [blame] | 279 | #if defined(ENABLE_PLUGINS) |
[email protected] | 1a55944 | 2012-05-27 07:18:46 | [diff] [blame] | 280 | // PepperFlashSettingsManager::Client implementation. |
dcheng | d2d1920 | 2014-10-22 00:06:00 | [diff] [blame] | 281 | void OnDeauthorizeContentLicensesCompleted(uint32 request_id, |
| 282 | bool success) override; |
[email protected] | 6d17f639 | 2012-12-05 05:24:54 | [diff] [blame] | 283 | #endif |
[email protected] | 1a55944 | 2012-05-27 07:18:46 | [diff] [blame] | 284 | |
[email protected] | 027188c | 2013-11-01 22:51:45 | [diff] [blame] | 285 | #if defined (OS_CHROMEOS) |
| 286 | void OnClearPlatformKeys(chromeos::DBusMethodCallStatus call_status, |
| 287 | bool result); |
| 288 | #endif |
| 289 | |
[email protected] | 8d4ec68 | 2012-02-17 12:20:17 | [diff] [blame] | 290 | // Removes the specified items related to browsing for a specific host. If the |
[email protected] | 3d4d4cf | 2012-06-04 10:40:55 | [diff] [blame] | 291 | // provided |origin| is empty, data is removed for all origins. The |
| 292 | // |origin_set_mask| parameter defines the set of origins from which data |
| 293 | // should be removed (protected, unprotected, or both). |
[email protected] | 8d4ec68 | 2012-02-17 12:20:17 | [diff] [blame] | 294 | void RemoveImpl(int remove_mask, |
| 295 | const GURL& origin, |
[email protected] | 3d4d4cf | 2012-06-04 10:40:55 | [diff] [blame] | 296 | int origin_set_mask); |
[email protected] | 8d4ec68 | 2012-02-17 12:20:17 | [diff] [blame] | 297 | |
[email protected] | a6b511a7 | 2014-04-17 23:51:34 | [diff] [blame] | 298 | // Notifies observers and deletes this object. |
| 299 | void NotifyAndDelete(); |
| 300 | |
| 301 | // Checks if we are all done, and if so, calls NotifyAndDelete(). |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 302 | void NotifyAndDeleteIfDone(); |
| 303 | |
[email protected] | 3118d34 | 2013-10-08 17:29:03 | [diff] [blame] | 304 | // Callback for when the hostname resolution cache has been cleared. |
[email protected] | e0e1fc2 | 2012-11-05 20:25:36 | [diff] [blame] | 305 | // Clears the respective waiting flag and invokes NotifyAndDeleteIfDone. |
| 306 | void OnClearedHostnameResolutionCache(); |
[email protected] | d6f37fc | 2011-02-13 23:58:41 | [diff] [blame] | 307 | |
[email protected] | e0e1fc2 | 2012-11-05 20:25:36 | [diff] [blame] | 308 | // Invoked on the IO thread to clear the hostname resolution cache. |
| 309 | void ClearHostnameResolutionCacheOnIOThread(IOThread* io_thread); |
| 310 | |
[email protected] | 3118d34 | 2013-10-08 17:29:03 | [diff] [blame] | 311 | // Callback for when the LoggedIn Predictor has been cleared. |
[email protected] | 20a47b97 | 2013-04-17 17:26:39 | [diff] [blame] | 312 | // Clears the respective waiting flag and invokes NotifyAndDeleteIfDone. |
| 313 | void OnClearedLoggedInPredictor(); |
| 314 | |
| 315 | // Clears the LoggedIn Predictor. |
| 316 | void ClearLoggedInPredictor(); |
| 317 | |
[email protected] | 3118d34 | 2013-10-08 17:29:03 | [diff] [blame] | 318 | // Callback for when speculative data in the network Predictor has been |
| 319 | // cleared. Clears the respective waiting flag and invokes |
| 320 | // NotifyAndDeleteIfDone. |
[email protected] | e0e1fc2 | 2012-11-05 20:25:36 | [diff] [blame] | 321 | void OnClearedNetworkPredictor(); |
| 322 | |
| 323 | // Invoked on the IO thread to clear speculative data related to hostname |
| 324 | // pre-resolution from the network Predictor. |
[email protected] | ec49c18 | 2014-06-11 18:03:47 | [diff] [blame] | 325 | void ClearNetworkPredictorOnIOThread( |
| 326 | chrome_browser_net::Predictor* predictor); |
[email protected] | e0e1fc2 | 2012-11-05 20:25:36 | [diff] [blame] | 327 | |
[email protected] | 3118d34 | 2013-10-08 17:29:03 | [diff] [blame] | 328 | // Callback for when network related data in ProfileIOData has been cleared. |
[email protected] | e0e1fc2 | 2012-11-05 20:25:36 | [diff] [blame] | 329 | // Clears the respective waiting flag and invokes NotifyAndDeleteIfDone. |
| 330 | void OnClearedNetworkingHistory(); |
[email protected] | d6f37fc | 2011-02-13 23:58:41 | [diff] [blame] | 331 | |
[email protected] | 3118d34 | 2013-10-08 17:29:03 | [diff] [blame] | 332 | // Callback for when the cache has been deleted. Invokes |
| 333 | // NotifyAndDeleteIfDone. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 334 | void ClearedCache(); |
| 335 | |
| 336 | // Invoked on the IO thread to delete from the cache. |
[email protected] | d885bfe | 2010-05-21 18:29:45 | [diff] [blame] | 337 | void ClearCacheOnIOThread(); |
| 338 | |
| 339 | // Performs the actual work to delete the cache. |
| 340 | void DoClearCache(int rv); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 341 | |
[email protected] | 43e497fd | 2012-06-14 21:14:52 | [diff] [blame] | 342 | #if !defined(DISABLE_NACL) |
| 343 | // Callback for when the NaCl cache has been deleted. Invokes |
| 344 | // NotifyAndDeleteIfDone. |
| 345 | void ClearedNaClCache(); |
| 346 | |
| 347 | // Invokes the ClearedNaClCache on the UI thread. |
| 348 | void ClearedNaClCacheOnIOThread(); |
| 349 | |
| 350 | // Invoked on the IO thread to delete the NaCl cache. |
| 351 | void ClearNaClCacheOnIOThread(); |
[email protected] | abc31ee | 2013-08-09 07:25:35 | [diff] [blame] | 352 | |
| 353 | // Callback for when the PNaCl translation cache has been deleted. Invokes |
| 354 | // NotifyAndDeleteIfDone. |
| 355 | void ClearedPnaclCache(); |
| 356 | |
| 357 | // Invokes ClearedPnaclCacheOn on the UI thread. |
| 358 | void ClearedPnaclCacheOnIOThread(); |
| 359 | |
| 360 | // Invoked on the IO thread to delete entries in the PNaCl translation cache. |
| 361 | void ClearPnaclCacheOnIOThread(base::Time begin, base::Time end); |
[email protected] | 43e497fd | 2012-06-14 21:14:52 | [diff] [blame] | 362 | #endif |
| 363 | |
[email protected] | 3118d34 | 2013-10-08 17:29:03 | [diff] [blame] | 364 | // Callback for when Cookies has been deleted. Invokes NotifyAndDeleteIfDone. |
[email protected] | ade9abe | 2011-09-02 17:29:12 | [diff] [blame] | 365 | void OnClearedCookies(int num_deleted); |
| 366 | |
| 367 | // Invoked on the IO thread to delete cookies. |
| 368 | void ClearCookiesOnIOThread(net::URLRequestContextGetter* rq_context); |
| 369 | |
[email protected] | 6b8a3c74 | 2014-07-25 00:25:35 | [diff] [blame] | 370 | // Invoked on the IO thread to delete channel IDs. |
| 371 | void ClearChannelIDsOnIOThread( |
[email protected] | eb7974c | 2012-01-25 17:38:48 | [diff] [blame] | 372 | net::URLRequestContextGetter* rq_context); |
| 373 | |
[email protected] | 6b8a3c74 | 2014-07-25 00:25:35 | [diff] [blame] | 374 | // Callback on IO Thread when channel IDs have been deleted. Clears SSL |
| 375 | // connection pool and posts to UI thread to run OnClearedChannelIDs. |
| 376 | void OnClearedChannelIDsOnIOThread( |
[email protected] | 646a620 | 2013-01-25 03:57:30 | [diff] [blame] | 377 | net::URLRequestContextGetter* rq_context); |
| 378 | |
[email protected] | 6b8a3c74 | 2014-07-25 00:25:35 | [diff] [blame] | 379 | // Callback for when channel IDs have been deleted. Invokes |
[email protected] | eb7974c | 2012-01-25 17:38:48 | [diff] [blame] | 380 | // NotifyAndDeleteIfDone. |
[email protected] | 6b8a3c74 | 2014-07-25 00:25:35 | [diff] [blame] | 381 | void OnClearedChannelIDs(); |
[email protected] | eb7974c | 2012-01-25 17:38:48 | [diff] [blame] | 382 | |
[email protected] | 1696d7a | 2012-08-22 17:06:40 | [diff] [blame] | 383 | // Callback from the above method. |
| 384 | void OnClearedFormData(); |
| 385 | |
[email protected] | 3118d34 | 2013-10-08 17:29:03 | [diff] [blame] | 386 | // Callback for when the Autofill profile and credit card origin URLs have |
| 387 | // been deleted. |
[email protected] | 4dacf9a | 2013-05-22 01:06:49 | [diff] [blame] | 388 | void OnClearedAutofillOriginURLs(); |
| 389 | |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 390 | // Callback on UI thread when the storage partition related data are cleared. |
| 391 | void OnClearedStoragePartitionData(); |
[email protected] | ec346e0 | 2013-08-08 22:03:53 | [diff] [blame] | 392 | |
[email protected] | 25021cfb | 2014-03-25 17:20:35 | [diff] [blame] | 393 | #if defined(ENABLE_WEBRTC) |
| 394 | // Callback on UI thread when the WebRTC logs have been deleted. |
| 395 | void OnClearedWebRtcLogs(); |
| 396 | #endif |
| 397 | |
[email protected] | 9b203403 | 2014-05-11 18:10:31 | [diff] [blame] | 398 | void OnClearedDomainReliabilityMonitor(); |
| 399 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 400 | // Returns true if we're all done. |
[email protected] | 43e497fd | 2012-06-14 21:14:52 | [diff] [blame] | 401 | bool AllDone(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 402 | |
| 403 | // Profile we're to remove from. |
| 404 | Profile* profile_; |
| 405 | |
| 406 | // Start time to delete from. |
[email protected] | e1acf6f | 2008-10-27 20:43:33 | [diff] [blame] | 407 | const base::Time delete_begin_; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 408 | |
| 409 | // End time to delete to. |
[email protected] | 2c1765f7 | 2012-08-08 10:07:37 | [diff] [blame] | 410 | base::Time delete_end_; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 411 | |
| 412 | // True if Remove has been invoked. |
[email protected] | 38b892b4 | 2012-09-04 13:25:47 | [diff] [blame] | 413 | static bool is_removing_; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 414 | |
[email protected] | a6b511a7 | 2014-04-17 23:51:34 | [diff] [blame] | 415 | // If non-NULL, the |completion_inhibitor_| is notified each time an instance |
| 416 | // is about to complete a browsing data removal process, and has the ability |
| 417 | // to artificially delay completion. Used for testing. |
| 418 | static CompletionInhibitor* completion_inhibitor_; |
| 419 | |
[email protected] | d885bfe | 2010-05-21 18:29:45 | [diff] [blame] | 420 | CacheState next_cache_state_; |
| 421 | disk_cache::Backend* cache_; |
[email protected] | d6f37fc | 2011-02-13 23:58:41 | [diff] [blame] | 422 | |
[email protected] | 9470417 | 2011-08-01 16:23:40 | [diff] [blame] | 423 | // Used to delete data from HTTP cache. |
[email protected] | abe2c03 | 2011-03-31 18:49:34 | [diff] [blame] | 424 | scoped_refptr<net::URLRequestContextGetter> main_context_getter_; |
| 425 | scoped_refptr<net::URLRequestContextGetter> media_context_getter_; |
[email protected] | d885bfe | 2010-05-21 18:29:45 | [diff] [blame] | 426 | |
[email protected] | c3cdc73 | 2012-12-07 09:16:56 | [diff] [blame] | 427 | #if defined(ENABLE_PLUGINS) |
[email protected] | 09d81f8 | 2010-12-15 16:46:42 | [diff] [blame] | 428 | // Used to delete plugin data. |
[email protected] | d8e68201 | 2011-11-17 18:31:54 | [diff] [blame] | 429 | scoped_ptr<content::PluginDataRemover> plugin_data_remover_; |
[email protected] | c7d58d6 | 2011-01-21 10:27:18 | [diff] [blame] | 430 | base::WaitableEventWatcher watcher_; |
[email protected] | 09d81f8 | 2010-12-15 16:46:42 | [diff] [blame] | 431 | |
[email protected] | 1a55944 | 2012-05-27 07:18:46 | [diff] [blame] | 432 | // Used to deauthorize content licenses for Pepper Flash. |
| 433 | scoped_ptr<PepperFlashSettingsManager> pepper_flash_settings_manager_; |
[email protected] | 6d17f639 | 2012-12-05 05:24:54 | [diff] [blame] | 434 | #endif |
[email protected] | 1a55944 | 2012-05-27 07:18:46 | [diff] [blame] | 435 | |
[email protected] | 6d17f639 | 2012-12-05 05:24:54 | [diff] [blame] | 436 | uint32 deauthorize_content_licenses_request_id_; |
[email protected] | d68a4fc6 | 2010-03-05 23:40:02 | [diff] [blame] | 437 | // True if we're waiting for various data to be deleted. |
[email protected] | dcdf7a71 | 2011-09-06 11:46:17 | [diff] [blame] | 438 | // These may only be accessed from UI thread in order to avoid races! |
[email protected] | 4dacf9a | 2013-05-22 01:06:49 | [diff] [blame] | 439 | bool waiting_for_clear_autofill_origin_urls_; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 440 | bool waiting_for_clear_cache_; |
[email protected] | 6b8a3c74 | 2014-07-25 00:25:35 | [diff] [blame] | 441 | bool waiting_for_clear_channel_ids_; |
[email protected] | e0e1fc2 | 2012-11-05 20:25:36 | [diff] [blame] | 442 | bool waiting_for_clear_content_licenses_; |
[email protected] | dde7a5a | 2012-02-22 23:16:34 | [diff] [blame] | 443 | // Non-zero if waiting for cookies to be cleared. |
| 444 | int waiting_for_clear_cookies_count_; |
[email protected] | 9b203403 | 2014-05-11 18:10:31 | [diff] [blame] | 445 | bool waiting_for_clear_domain_reliability_monitor_; |
[email protected] | e0e1fc2 | 2012-11-05 20:25:36 | [diff] [blame] | 446 | bool waiting_for_clear_form_; |
[email protected] | eb7974c | 2012-01-25 17:38:48 | [diff] [blame] | 447 | bool waiting_for_clear_history_; |
[email protected] | e0e1fc2 | 2012-11-05 20:25:36 | [diff] [blame] | 448 | bool waiting_for_clear_hostname_resolution_cache_; |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 449 | bool waiting_for_clear_keyword_data_; |
[email protected] | 20a47b97 | 2013-04-17 17:26:39 | [diff] [blame] | 450 | bool waiting_for_clear_logged_in_predictor_; |
[email protected] | e0e1fc2 | 2012-11-05 20:25:36 | [diff] [blame] | 451 | bool waiting_for_clear_nacl_cache_; |
| 452 | bool waiting_for_clear_network_predictor_; |
[email protected] | eb7974c | 2012-01-25 17:38:48 | [diff] [blame] | 453 | bool waiting_for_clear_networking_history_; |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 454 | bool waiting_for_clear_platform_keys_; |
[email protected] | 59eca0f | 2011-12-13 19:16:39 | [diff] [blame] | 455 | bool waiting_for_clear_plugin_data_; |
[email protected] | abc31ee | 2013-08-09 07:25:35 | [diff] [blame] | 456 | bool waiting_for_clear_pnacl_cache_; |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 457 | bool waiting_for_clear_storage_partition_data_; |
[email protected] | 25021cfb | 2014-03-25 17:20:35 | [diff] [blame] | 458 | #if defined(ENABLE_WEBRTC) |
| 459 | bool waiting_for_clear_webrtc_logs_; |
| 460 | #endif |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 461 | |
[email protected] | 8d7554d8 | 2011-12-13 17:11:08 | [diff] [blame] | 462 | // The removal mask for the current removal operation. |
| 463 | int remove_mask_; |
| 464 | |
[email protected] | 8d4ec68 | 2012-02-17 12:20:17 | [diff] [blame] | 465 | // The origin for the current removal operation. |
| 466 | GURL remove_origin_; |
| 467 | |
[email protected] | 3d4d4cf | 2012-06-04 10:40:55 | [diff] [blame] | 468 | // From which types of origins should we remove data? |
| 469 | int origin_set_mask_; |
[email protected] | 8d4ec68 | 2012-02-17 12:20:17 | [diff] [blame] | 470 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 471 | ObserverList<Observer> observer_list_; |
| 472 | |
| 473 | // Used if we need to clear history. |
[email protected] | e95b717f | 2014-02-06 13:47:13 | [diff] [blame] | 474 | base::CancelableTaskTracker history_task_tracker_; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 475 | |
[email protected] | 3118d34 | 2013-10-08 17:29:03 | [diff] [blame] | 476 | scoped_ptr<TemplateURLService::Subscription> template_url_sub_; |
| 477 | |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 478 | // We do not own this. |
| 479 | content::StoragePartition* storage_partition_for_testing_; |
| 480 | |
[email protected] | bfd04a6 | 2009-02-01 18:16:56 | [diff] [blame] | 481 | DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemover); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 482 | }; |
| 483 | |
[email protected] | b0cb5e8 | 2012-07-19 19:22:47 | [diff] [blame] | 484 | #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_H_ |