| 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 <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/observer_list.h" | 12 #include "base/observer_list.h" |
| 13 #include "base/prefs/pref_member.h" | 13 #include "base/prefs/pref_member.h" |
| 14 #include "base/sequenced_task_runner_helpers.h" | 14 #include "base/sequenced_task_runner_helpers.h" |
| 15 #include "base/synchronization/waitable_event_watcher.h" | 15 #include "base/synchronization/waitable_event_watcher.h" |
| 16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 17 #include "chrome/browser/pepper_flash_settings_manager.h" | 17 #include "chrome/browser/pepper_flash_settings_manager.h" |
| 18 #include "chrome/browser/search_engines/template_url_service.h" | 18 #include "chrome/browser/search_engines/template_url_service.h" |
| 19 #include "chrome/common/cancelable_task_tracker.h" | 19 #include "chrome/common/cancelable_task_tracker.h" |
| 20 #include "url/gurl.h" | 20 #include "url/gurl.h" |
| 21 #include "webkit/common/quota/quota_types.h" | 21 #include "webkit/common/quota/quota_types.h" |
| 22 | 22 |
| 23 class ExtensionSpecialStoragePolicy; | 23 class ExtensionSpecialStoragePolicy; |
| 24 class IOThread; | 24 class IOThread; |
| 25 class Profile; | 25 class Profile; |
| 26 | 26 |
| 27 namespace content { | 27 namespace content { |
| 28 class PluginDataRemover; | 28 class PluginDataRemover; |
| 29 class StoragePartition; |
| 29 } | 30 } |
| 30 | 31 |
| 31 namespace disk_cache { | 32 namespace disk_cache { |
| 32 class Backend; | 33 class Backend; |
| 33 } | 34 } |
| 34 | 35 |
| 35 namespace net { | 36 namespace net { |
| 36 class URLRequestContextGetter; | 37 class URLRequestContextGetter; |
| 37 } | 38 } |
| 38 | 39 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 | 149 |
| 149 // Creates a BrowsingDataRemover bound to a specific period of time (as | 150 // Creates a BrowsingDataRemover bound to a specific period of time (as |
| 150 // defined via a TimePeriod). Returns a raw pointer, as BrowsingDataRemover | 151 // defined via a TimePeriod). Returns a raw pointer, as BrowsingDataRemover |
| 151 // retains ownership of itself, and deletes itself once finished. | 152 // retains ownership of itself, and deletes itself once finished. |
| 152 static BrowsingDataRemover* CreateForPeriod(Profile* profile, | 153 static BrowsingDataRemover* CreateForPeriod(Profile* profile, |
| 153 TimePeriod period); | 154 TimePeriod period); |
| 154 | 155 |
| 155 // Calculate the begin time for the deletion range specified by |time_period|. | 156 // Calculate the begin time for the deletion range specified by |time_period|. |
| 156 static base::Time CalculateBeginDeleteTime(TimePeriod time_period); | 157 static base::Time CalculateBeginDeleteTime(TimePeriod time_period); |
| 157 | 158 |
| 158 // Quota managed data uses a different bitmask for types than | |
| 159 // BrowsingDataRemover uses. This method generates that mask. | |
| 160 static int GenerateQuotaClientMask(int remove_mask); | |
| 161 | |
| 162 // Is the BrowsingDataRemover currently in the process of removing data? | 159 // Is the BrowsingDataRemover currently in the process of removing data? |
| 163 static bool is_removing() { return is_removing_; } | 160 static bool is_removing() { return is_removing_; } |
| 164 | 161 |
| 165 // Removes the specified items related to browsing for all origins that match | 162 // Removes the specified items related to browsing for all origins that match |
| 166 // the provided |origin_set_mask| (see BrowsingDataHelper::OriginSetMask). | 163 // the provided |origin_set_mask| (see BrowsingDataHelper::OriginSetMask). |
| 167 void Remove(int remove_mask, int origin_set_mask); | 164 void Remove(int remove_mask, int origin_set_mask); |
| 168 | 165 |
| 169 void AddObserver(Observer* observer); | 166 void AddObserver(Observer* observer); |
| 170 void RemoveObserver(Observer* observer); | 167 void RemoveObserver(Observer* observer); |
| 171 | 168 |
| 172 // Called when history deletion is done. | 169 // Called when history deletion is done. |
| 173 void OnHistoryDeletionDone(); | 170 void OnHistoryDeletionDone(); |
| 174 | 171 |
| 175 // Used for testing. | 172 // Used for testing. |
| 176 void OverrideQuotaManagerForTesting(quota::QuotaManager* quota_manager); | 173 void OverrideStoragePartitionForTesting( |
| 174 content::StoragePartition* storage_partition); |
| 177 | 175 |
| 178 private: | 176 private: |
| 179 // The clear API needs to be able to toggle removing_ in order to test that | 177 // The clear API needs to be able to toggle removing_ in order to test that |
| 180 // only one BrowsingDataRemover instance can be called at a time. | 178 // only one BrowsingDataRemover instance can be called at a time. |
| 181 FRIEND_TEST_ALL_PREFIXES(ExtensionBrowsingDataTest, OneAtATime); | 179 FRIEND_TEST_ALL_PREFIXES(ExtensionBrowsingDataTest, OneAtATime); |
| 182 | 180 |
| 183 // The BrowsingDataRemover tests need to be able to access the implementation | 181 // The BrowsingDataRemover tests need to be able to access the implementation |
| 184 // of Remove(), as it exposes details that aren't yet available in the public | 182 // of Remove(), as it exposes details that aren't yet available in the public |
| 185 // API. As soon as those details are exposed via new methods, this should be | 183 // API. As soon as those details are exposed via new methods, this should be |
| 186 // removed. | 184 // removed. |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 // NotifyAndDeleteIfDone. | 288 // NotifyAndDeleteIfDone. |
| 291 void ClearedPnaclCache(); | 289 void ClearedPnaclCache(); |
| 292 | 290 |
| 293 // Invokes ClearedPnaclCacheOn on the UI thread. | 291 // Invokes ClearedPnaclCacheOn on the UI thread. |
| 294 void ClearedPnaclCacheOnIOThread(); | 292 void ClearedPnaclCacheOnIOThread(); |
| 295 | 293 |
| 296 // Invoked on the IO thread to delete entries in the PNaCl translation cache. | 294 // Invoked on the IO thread to delete entries in the PNaCl translation cache. |
| 297 void ClearPnaclCacheOnIOThread(base::Time begin, base::Time end); | 295 void ClearPnaclCacheOnIOThread(base::Time begin, base::Time end); |
| 298 #endif | 296 #endif |
| 299 | 297 |
| 300 // Invoked on the UI thread to delete local storage. | |
| 301 void ClearLocalStorageOnUIThread(); | |
| 302 | |
| 303 // Callback to deal with the list gathered in ClearLocalStorageOnUIThread. | |
| 304 void OnGotLocalStorageUsageInfo( | |
| 305 const std::vector<content::LocalStorageUsageInfo>& infos); | |
| 306 | |
| 307 // Invoked on the UI thread to delete session storage. | |
| 308 void ClearSessionStorageOnUIThread(); | |
| 309 | |
| 310 // Callback to deal with the list gathered in ClearSessionStorageOnUIThread. | |
| 311 void OnGotSessionStorageUsageInfo( | |
| 312 const std::vector<content::SessionStorageUsageInfo>& infos); | |
| 313 | |
| 314 // Invoked on the IO thread to delete all storage types managed by the quota | |
| 315 // system: AppCache, Databases, FileSystems. | |
| 316 void ClearQuotaManagedDataOnIOThread(); | |
| 317 | |
| 318 // Callback to respond to QuotaManager::GetOriginsModifiedSince, which is the | |
| 319 // core of 'ClearQuotaManagedDataOnIOThread'. | |
| 320 void OnGotQuotaManagedOrigins(const std::set<GURL>& origins, | |
| 321 quota::StorageType type); | |
| 322 | |
| 323 // Callback responding to deletion of a single quota managed origin's | |
| 324 // persistent data | |
| 325 void OnQuotaManagedOriginDeletion(const GURL& origin, | |
| 326 quota::StorageType type, | |
| 327 quota::QuotaStatusCode); | |
| 328 | |
| 329 // Called to check whether all temporary and persistent origin data that | |
| 330 // should be deleted has been deleted. If everything's good to go, invokes | |
| 331 // OnQuotaManagedDataDeleted on the UI thread. | |
| 332 void CheckQuotaManagedDataDeletionStatus(); | |
| 333 | |
| 334 // Completion handler that runs on the UI thread once persistent data has been | |
| 335 // deleted. Updates the waiting flag and invokes NotifyAndDeleteIfDone. | |
| 336 void OnQuotaManagedDataDeleted(); | |
| 337 | |
| 338 // Callback for when Cookies has been deleted. Invokes NotifyAndDeleteIfDone. | 298 // Callback for when Cookies has been deleted. Invokes NotifyAndDeleteIfDone. |
| 339 void OnClearedCookies(int num_deleted); | 299 void OnClearedCookies(int num_deleted); |
| 340 | 300 |
| 341 // Invoked on the IO thread to delete cookies. | 301 // Invoked on the IO thread to delete cookies. |
| 342 void ClearCookiesOnIOThread(net::URLRequestContextGetter* rq_context); | 302 void ClearCookiesOnIOThread(net::URLRequestContextGetter* rq_context); |
| 343 | 303 |
| 344 // Invoked on the IO thread to delete server bound certs. | 304 // Invoked on the IO thread to delete server bound certs. |
| 345 void ClearServerBoundCertsOnIOThread( | 305 void ClearServerBoundCertsOnIOThread( |
| 346 net::URLRequestContextGetter* rq_context); | 306 net::URLRequestContextGetter* rq_context); |
| 347 | 307 |
| 348 // Callback on IO Thread when server bound certs have been deleted. Clears SSL | 308 // Callback on IO Thread when server bound certs have been deleted. Clears SSL |
| 349 // connection pool and posts to UI thread to run OnClearedServerBoundCerts. | 309 // connection pool and posts to UI thread to run OnClearedServerBoundCerts. |
| 350 void OnClearedServerBoundCertsOnIOThread( | 310 void OnClearedServerBoundCertsOnIOThread( |
| 351 net::URLRequestContextGetter* rq_context); | 311 net::URLRequestContextGetter* rq_context); |
| 352 | 312 |
| 353 // Callback for when server bound certs have been deleted. Invokes | 313 // Callback for when server bound certs have been deleted. Invokes |
| 354 // NotifyAndDeleteIfDone. | 314 // NotifyAndDeleteIfDone. |
| 355 void OnClearedServerBoundCerts(); | 315 void OnClearedServerBoundCerts(); |
| 356 | 316 |
| 357 // Callback from the above method. | 317 // Callback from the above method. |
| 358 void OnClearedFormData(); | 318 void OnClearedFormData(); |
| 359 | 319 |
| 360 // Callback for when the Autofill profile and credit card origin URLs have | 320 // Callback for when the Autofill profile and credit card origin URLs have |
| 361 // been deleted. | 321 // been deleted. |
| 362 void OnClearedAutofillOriginURLs(); | 322 void OnClearedAutofillOriginURLs(); |
| 363 | 323 |
| 364 // Callback for when the shader cache has been deleted. | |
| 365 // Invokes NotifyAndDeleteIfDone. | |
| 366 void ClearedShaderCache(); | |
| 367 | 324 |
| 368 // Invoked on the IO thread to delete from the shader cache. | 325 // Callback on UI thread when the storage partition related data are cleared. |
| 369 void ClearShaderCacheOnUIThread(); | 326 void OnClearedStoragePartitionData(); |
| 370 | |
| 371 // Callback on UI thread when the WebRTC identities are cleared. | |
| 372 void OnClearWebRTCIdentityStore(); | |
| 373 | 327 |
| 374 // Returns true if we're all done. | 328 // Returns true if we're all done. |
| 375 bool AllDone(); | 329 bool AllDone(); |
| 376 | 330 |
| 377 // Profile we're to remove from. | 331 // Profile we're to remove from. |
| 378 Profile* profile_; | 332 Profile* profile_; |
| 379 | 333 |
| 380 // The QuotaManager is owned by the profile; we can use a raw pointer here, | |
| 381 // and rely on the profile to destroy the object whenever it's reasonable. | |
| 382 quota::QuotaManager* quota_manager_; | |
| 383 | |
| 384 // The DOMStorageContext is owned by the profile; we'll store a raw pointer. | |
| 385 content::DOMStorageContext* dom_storage_context_; | |
| 386 | |
| 387 // 'Protected' origins are not subject to data removal. | 334 // 'Protected' origins are not subject to data removal. |
| 388 scoped_refptr<ExtensionSpecialStoragePolicy> special_storage_policy_; | 335 scoped_refptr<ExtensionSpecialStoragePolicy> special_storage_policy_; |
| 389 | 336 |
| 390 // Start time to delete from. | 337 // Start time to delete from. |
| 391 const base::Time delete_begin_; | 338 const base::Time delete_begin_; |
| 392 | 339 |
| 393 // End time to delete to. | 340 // End time to delete to. |
| 394 base::Time delete_end_; | 341 base::Time delete_end_; |
| 395 | 342 |
| 396 // True if Remove has been invoked. | 343 // True if Remove has been invoked. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 416 // True if we're waiting for various data to be deleted. | 363 // True if we're waiting for various data to be deleted. |
| 417 // These may only be accessed from UI thread in order to avoid races! | 364 // These may only be accessed from UI thread in order to avoid races! |
| 418 bool waiting_for_clear_autofill_origin_urls_; | 365 bool waiting_for_clear_autofill_origin_urls_; |
| 419 bool waiting_for_clear_cache_; | 366 bool waiting_for_clear_cache_; |
| 420 bool waiting_for_clear_content_licenses_; | 367 bool waiting_for_clear_content_licenses_; |
| 421 // Non-zero if waiting for cookies to be cleared. | 368 // Non-zero if waiting for cookies to be cleared. |
| 422 int waiting_for_clear_cookies_count_; | 369 int waiting_for_clear_cookies_count_; |
| 423 bool waiting_for_clear_form_; | 370 bool waiting_for_clear_form_; |
| 424 bool waiting_for_clear_history_; | 371 bool waiting_for_clear_history_; |
| 425 bool waiting_for_clear_hostname_resolution_cache_; | 372 bool waiting_for_clear_hostname_resolution_cache_; |
| 426 bool waiting_for_clear_local_storage_; | 373 bool waiting_for_clear_keyword_data_; |
| 427 bool waiting_for_clear_logged_in_predictor_; | 374 bool waiting_for_clear_logged_in_predictor_; |
| 428 bool waiting_for_clear_nacl_cache_; | 375 bool waiting_for_clear_nacl_cache_; |
| 429 bool waiting_for_clear_network_predictor_; | 376 bool waiting_for_clear_network_predictor_; |
| 430 bool waiting_for_clear_networking_history_; | 377 bool waiting_for_clear_networking_history_; |
| 431 bool waiting_for_clear_plugin_data_; | 378 bool waiting_for_clear_plugin_data_; |
| 432 bool waiting_for_clear_pnacl_cache_; | 379 bool waiting_for_clear_pnacl_cache_; |
| 433 bool waiting_for_clear_quota_managed_data_; | 380 bool waiting_for_clear_quota_managed_data_; |
| 434 bool waiting_for_clear_server_bound_certs_; | 381 bool waiting_for_clear_server_bound_certs_; |
| 435 bool waiting_for_clear_session_storage_; | 382 bool waiting_for_clear_storage_partition_data_; |
| 436 bool waiting_for_clear_shader_cache_; | |
| 437 bool waiting_for_clear_webrtc_identity_store_; | |
| 438 bool waiting_for_clear_keyword_data_; | |
| 439 | |
| 440 // Tracking how many origins need to be deleted, and whether we're finished | |
| 441 // gathering origins. | |
| 442 int quota_managed_origins_to_delete_count_; | |
| 443 int quota_managed_storage_types_to_delete_count_; | |
| 444 | 383 |
| 445 // The removal mask for the current removal operation. | 384 // The removal mask for the current removal operation. |
| 446 int remove_mask_; | 385 int remove_mask_; |
| 447 | 386 |
| 448 // The origin for the current removal operation. | 387 // The origin for the current removal operation. |
| 449 GURL remove_origin_; | 388 GURL remove_origin_; |
| 450 | 389 |
| 451 // From which types of origins should we remove data? | 390 // From which types of origins should we remove data? |
| 452 int origin_set_mask_; | 391 int origin_set_mask_; |
| 453 | 392 |
| 454 ObserverList<Observer> observer_list_; | 393 ObserverList<Observer> observer_list_; |
| 455 | 394 |
| 456 // Used if we need to clear history. | 395 // Used if we need to clear history. |
| 457 CancelableTaskTracker history_task_tracker_; | 396 CancelableTaskTracker history_task_tracker_; |
| 458 | 397 |
| 459 scoped_ptr<TemplateURLService::Subscription> template_url_sub_; | 398 scoped_ptr<TemplateURLService::Subscription> template_url_sub_; |
| 460 | 399 |
| 400 // We do not own this. |
| 401 content::StoragePartition* storage_partition_for_testing_; |
| 402 |
| 461 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemover); | 403 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemover); |
| 462 }; | 404 }; |
| 463 | 405 |
| 464 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_H_ | 406 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_H_ |
| OLD | NEW |