| 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/common/cancelable_task_tracker.h" | 19 #include "chrome/common/cancelable_task_tracker.h" |
| 19 #include "content/public/browser/notification_observer.h" | |
| 20 #include "content/public/browser/notification_registrar.h" | |
| 21 #include "url/gurl.h" | 20 #include "url/gurl.h" |
| 22 #include "webkit/common/quota/quota_types.h" | 21 #include "webkit/common/quota/quota_types.h" |
| 23 | 22 |
| 24 class ExtensionSpecialStoragePolicy; | 23 class ExtensionSpecialStoragePolicy; |
| 25 class IOThread; | 24 class IOThread; |
| 26 class Profile; | 25 class Profile; |
| 27 | 26 |
| 28 namespace content { | 27 namespace content { |
| 29 class PluginDataRemover; | 28 class PluginDataRemover; |
| 30 } | 29 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 43 | 42 |
| 44 namespace content { | 43 namespace content { |
| 45 class DOMStorageContext; | 44 class DOMStorageContext; |
| 46 struct LocalStorageUsageInfo; | 45 struct LocalStorageUsageInfo; |
| 47 struct SessionStorageUsageInfo; | 46 struct SessionStorageUsageInfo; |
| 48 } | 47 } |
| 49 | 48 |
| 50 // BrowsingDataRemover is responsible for removing data related to browsing: | 49 // BrowsingDataRemover is responsible for removing data related to browsing: |
| 51 // visits in url database, downloads, cookies ... | 50 // visits in url database, downloads, cookies ... |
| 52 | 51 |
| 53 class BrowsingDataRemover : public content::NotificationObserver | 52 class BrowsingDataRemover |
| 54 #if defined(ENABLE_PLUGINS) | 53 #if defined(ENABLE_PLUGINS) |
| 55 , public PepperFlashSettingsManager::Client | 54 : public PepperFlashSettingsManager::Client |
| 56 #endif | 55 #endif |
| 57 { | 56 { |
| 58 public: | 57 public: |
| 59 // Time period ranges available when doing browsing data removals. | 58 // Time period ranges available when doing browsing data removals. |
| 60 enum TimePeriod { | 59 enum TimePeriod { |
| 61 LAST_HOUR = 0, | 60 LAST_HOUR = 0, |
| 62 LAST_DAY, | 61 LAST_DAY, |
| 63 LAST_WEEK, | 62 LAST_WEEK, |
| 64 FOUR_WEEKS, | 63 FOUR_WEEKS, |
| 65 EVERYTHING | 64 EVERYTHING |
| 66 }; | 65 }; |
| 67 | 66 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 BrowsingDataRemover(Profile* profile, | 206 BrowsingDataRemover(Profile* profile, |
| 208 base::Time delete_begin, | 207 base::Time delete_begin, |
| 209 base::Time delete_end); | 208 base::Time delete_end); |
| 210 | 209 |
| 211 // BrowsingDataRemover deletes itself (using DeleteHelper) and is not supposed | 210 // BrowsingDataRemover deletes itself (using DeleteHelper) and is not supposed |
| 212 // to be deleted by other objects so make destructor private and DeleteHelper | 211 // to be deleted by other objects so make destructor private and DeleteHelper |
| 213 // a friend. | 212 // a friend. |
| 214 friend class base::DeleteHelper<BrowsingDataRemover>; | 213 friend class base::DeleteHelper<BrowsingDataRemover>; |
| 215 virtual ~BrowsingDataRemover(); | 214 virtual ~BrowsingDataRemover(); |
| 216 | 215 |
| 217 // content::NotificationObserver method. Callback when TemplateURLService has | 216 // Callback for when TemplateURLService has finished loading. Clears the data, |
| 218 // finished loading. Deletes the entries from the model, and if we're not | 217 // clears the respective waiting flag, and invokes NotifyAndDeleteIfDone. |
| 219 // waiting on anything else notifies observers and deletes this | 218 void OnKeywordsLoaded(); |
| 220 // BrowsingDataRemover. | |
| 221 virtual void Observe(int type, | |
| 222 const content::NotificationSource& source, | |
| 223 const content::NotificationDetails& details) OVERRIDE; | |
| 224 | 219 |
| 225 // Called when plug-in data has been cleared. Invokes NotifyAndDeleteIfDone. | 220 // Called when plug-in data has been cleared. Invokes NotifyAndDeleteIfDone. |
| 226 void OnWaitableEventSignaled(base::WaitableEvent* waitable_event); | 221 void OnWaitableEventSignaled(base::WaitableEvent* waitable_event); |
| 227 | 222 |
| 228 #if defined(ENABLE_PLUGINS) | 223 #if defined(ENABLE_PLUGINS) |
| 229 // PepperFlashSettingsManager::Client implementation. | 224 // PepperFlashSettingsManager::Client implementation. |
| 230 virtual void OnDeauthorizeContentLicensesCompleted(uint32 request_id, | 225 virtual void OnDeauthorizeContentLicensesCompleted(uint32 request_id, |
| 231 bool success) OVERRIDE; | 226 bool success) OVERRIDE; |
| 232 #endif | 227 #endif |
| 233 | 228 |
| 234 // Removes the specified items related to browsing for a specific host. If the | 229 // Removes the specified items related to browsing for a specific host. If the |
| 235 // provided |origin| is empty, data is removed for all origins. The | 230 // provided |origin| is empty, data is removed for all origins. The |
| 236 // |origin_set_mask| parameter defines the set of origins from which data | 231 // |origin_set_mask| parameter defines the set of origins from which data |
| 237 // should be removed (protected, unprotected, or both). | 232 // should be removed (protected, unprotected, or both). |
| 238 void RemoveImpl(int remove_mask, | 233 void RemoveImpl(int remove_mask, |
| 239 const GURL& origin, | 234 const GURL& origin, |
| 240 int origin_set_mask); | 235 int origin_set_mask); |
| 241 | 236 |
| 242 // If we're not waiting on anything, notifies observers and deletes this | 237 // If we're not waiting on anything, notifies observers and deletes this |
| 243 // object. | 238 // object. |
| 244 void NotifyAndDeleteIfDone(); | 239 void NotifyAndDeleteIfDone(); |
| 245 | 240 |
| 246 // Callback when the hostname resolution cache has been cleared. | 241 // Callback for when the hostname resolution cache has been cleared. |
| 247 // Clears the respective waiting flag and invokes NotifyAndDeleteIfDone. | 242 // Clears the respective waiting flag and invokes NotifyAndDeleteIfDone. |
| 248 void OnClearedHostnameResolutionCache(); | 243 void OnClearedHostnameResolutionCache(); |
| 249 | 244 |
| 250 // Invoked on the IO thread to clear the hostname resolution cache. | 245 // Invoked on the IO thread to clear the hostname resolution cache. |
| 251 void ClearHostnameResolutionCacheOnIOThread(IOThread* io_thread); | 246 void ClearHostnameResolutionCacheOnIOThread(IOThread* io_thread); |
| 252 | 247 |
| 253 // Callback when the LoggedIn Predictor has been cleared. | 248 // Callback for when the LoggedIn Predictor has been cleared. |
| 254 // Clears the respective waiting flag and invokes NotifyAndDeleteIfDone. | 249 // Clears the respective waiting flag and invokes NotifyAndDeleteIfDone. |
| 255 void OnClearedLoggedInPredictor(); | 250 void OnClearedLoggedInPredictor(); |
| 256 | 251 |
| 257 // Clears the LoggedIn Predictor. | 252 // Clears the LoggedIn Predictor. |
| 258 void ClearLoggedInPredictor(); | 253 void ClearLoggedInPredictor(); |
| 259 | 254 |
| 260 // Callback when speculative data in the network Predictor has been cleared. | 255 // Callback for when speculative data in the network Predictor has been |
| 261 // Clears the respective waiting flag and invokes NotifyAndDeleteIfDone. | 256 // cleared. Clears the respective waiting flag and invokes |
| 257 // NotifyAndDeleteIfDone. |
| 262 void OnClearedNetworkPredictor(); | 258 void OnClearedNetworkPredictor(); |
| 263 | 259 |
| 264 // Invoked on the IO thread to clear speculative data related to hostname | 260 // Invoked on the IO thread to clear speculative data related to hostname |
| 265 // pre-resolution from the network Predictor. | 261 // pre-resolution from the network Predictor. |
| 266 void ClearNetworkPredictorOnIOThread(); | 262 void ClearNetworkPredictorOnIOThread(); |
| 267 | 263 |
| 268 // Callback when network related data in ProfileIOData has been cleared. | 264 // Callback for when network related data in ProfileIOData has been cleared. |
| 269 // Clears the respective waiting flag and invokes NotifyAndDeleteIfDone. | 265 // Clears the respective waiting flag and invokes NotifyAndDeleteIfDone. |
| 270 void OnClearedNetworkingHistory(); | 266 void OnClearedNetworkingHistory(); |
| 271 | 267 |
| 272 // Callback when the cache has been deleted. Invokes NotifyAndDeleteIfDone. | 268 // Callback for when the cache has been deleted. Invokes |
| 269 // NotifyAndDeleteIfDone. |
| 273 void ClearedCache(); | 270 void ClearedCache(); |
| 274 | 271 |
| 275 // Invoked on the IO thread to delete from the cache. | 272 // Invoked on the IO thread to delete from the cache. |
| 276 void ClearCacheOnIOThread(); | 273 void ClearCacheOnIOThread(); |
| 277 | 274 |
| 278 // Performs the actual work to delete the cache. | 275 // Performs the actual work to delete the cache. |
| 279 void DoClearCache(int rv); | 276 void DoClearCache(int rv); |
| 280 | 277 |
| 281 #if !defined(DISABLE_NACL) | 278 #if !defined(DISABLE_NACL) |
| 282 // Callback for when the NaCl cache has been deleted. Invokes | 279 // Callback for when the NaCl cache has been deleted. Invokes |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 | 328 |
| 332 // Called to check whether all temporary and persistent origin data that | 329 // Called to check whether all temporary and persistent origin data that |
| 333 // should be deleted has been deleted. If everything's good to go, invokes | 330 // should be deleted has been deleted. If everything's good to go, invokes |
| 334 // OnQuotaManagedDataDeleted on the UI thread. | 331 // OnQuotaManagedDataDeleted on the UI thread. |
| 335 void CheckQuotaManagedDataDeletionStatus(); | 332 void CheckQuotaManagedDataDeletionStatus(); |
| 336 | 333 |
| 337 // Completion handler that runs on the UI thread once persistent data has been | 334 // Completion handler that runs on the UI thread once persistent data has been |
| 338 // deleted. Updates the waiting flag and invokes NotifyAndDeleteIfDone. | 335 // deleted. Updates the waiting flag and invokes NotifyAndDeleteIfDone. |
| 339 void OnQuotaManagedDataDeleted(); | 336 void OnQuotaManagedDataDeleted(); |
| 340 | 337 |
| 341 // Callback when Cookies has been deleted. Invokes NotifyAndDeleteIfDone. | 338 // Callback for when Cookies has been deleted. Invokes NotifyAndDeleteIfDone. |
| 342 void OnClearedCookies(int num_deleted); | 339 void OnClearedCookies(int num_deleted); |
| 343 | 340 |
| 344 // Invoked on the IO thread to delete cookies. | 341 // Invoked on the IO thread to delete cookies. |
| 345 void ClearCookiesOnIOThread(net::URLRequestContextGetter* rq_context); | 342 void ClearCookiesOnIOThread(net::URLRequestContextGetter* rq_context); |
| 346 | 343 |
| 347 // Invoked on the IO thread to delete server bound certs. | 344 // Invoked on the IO thread to delete server bound certs. |
| 348 void ClearServerBoundCertsOnIOThread( | 345 void ClearServerBoundCertsOnIOThread( |
| 349 net::URLRequestContextGetter* rq_context); | 346 net::URLRequestContextGetter* rq_context); |
| 350 | 347 |
| 351 // Callback on IO Thread when server bound certs have been deleted. Clears SSL | 348 // Callback on IO Thread when server bound certs have been deleted. Clears SSL |
| 352 // connection pool and posts to UI thread to run OnClearedServerBoundCerts. | 349 // connection pool and posts to UI thread to run OnClearedServerBoundCerts. |
| 353 void OnClearedServerBoundCertsOnIOThread( | 350 void OnClearedServerBoundCertsOnIOThread( |
| 354 net::URLRequestContextGetter* rq_context); | 351 net::URLRequestContextGetter* rq_context); |
| 355 | 352 |
| 356 // Callback when server bound certs have been deleted. Invokes | 353 // Callback for when server bound certs have been deleted. Invokes |
| 357 // NotifyAndDeleteIfDone. | 354 // NotifyAndDeleteIfDone. |
| 358 void OnClearedServerBoundCerts(); | 355 void OnClearedServerBoundCerts(); |
| 359 | 356 |
| 360 // Callback from the above method. | 357 // Callback from the above method. |
| 361 void OnClearedFormData(); | 358 void OnClearedFormData(); |
| 362 | 359 |
| 363 // Callback when the Autofill profile and credit card origin URLs have been | 360 // Callback for when the Autofill profile and credit card origin URLs have |
| 364 // deleted. | 361 // been deleted. |
| 365 void OnClearedAutofillOriginURLs(); | 362 void OnClearedAutofillOriginURLs(); |
| 366 | 363 |
| 367 // Callback when the shader cache has been deleted. | 364 // Callback for when the shader cache has been deleted. |
| 368 // Invokes NotifyAndDeleteIfDone. | 365 // Invokes NotifyAndDeleteIfDone. |
| 369 void ClearedShaderCache(); | 366 void ClearedShaderCache(); |
| 370 | 367 |
| 371 // Invoked on the IO thread to delete from the shader cache. | 368 // Invoked on the IO thread to delete from the shader cache. |
| 372 void ClearShaderCacheOnUIThread(); | 369 void ClearShaderCacheOnUIThread(); |
| 373 | 370 |
| 374 // Callback on UI thread when the WebRTC identities are cleared. | 371 // Callback on UI thread when the WebRTC identities are cleared. |
| 375 void OnClearWebRTCIdentityStore(); | 372 void OnClearWebRTCIdentityStore(); |
| 376 | 373 |
| 377 // Returns true if we're all done. | 374 // Returns true if we're all done. |
| 378 bool AllDone(); | 375 bool AllDone(); |
| 379 | 376 |
| 380 content::NotificationRegistrar registrar_; | |
| 381 | |
| 382 // Profile we're to remove from. | 377 // Profile we're to remove from. |
| 383 Profile* profile_; | 378 Profile* profile_; |
| 384 | 379 |
| 385 // The QuotaManager is owned by the profile; we can use a raw pointer here, | 380 // The QuotaManager is owned by the profile; we can use a raw pointer here, |
| 386 // and rely on the profile to destroy the object whenever it's reasonable. | 381 // and rely on the profile to destroy the object whenever it's reasonable. |
| 387 quota::QuotaManager* quota_manager_; | 382 quota::QuotaManager* quota_manager_; |
| 388 | 383 |
| 389 // The DOMStorageContext is owned by the profile; we'll store a raw pointer. | 384 // The DOMStorageContext is owned by the profile; we'll store a raw pointer. |
| 390 content::DOMStorageContext* dom_storage_context_; | 385 content::DOMStorageContext* dom_storage_context_; |
| 391 | 386 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 bool waiting_for_clear_nacl_cache_; | 428 bool waiting_for_clear_nacl_cache_; |
| 434 bool waiting_for_clear_network_predictor_; | 429 bool waiting_for_clear_network_predictor_; |
| 435 bool waiting_for_clear_networking_history_; | 430 bool waiting_for_clear_networking_history_; |
| 436 bool waiting_for_clear_plugin_data_; | 431 bool waiting_for_clear_plugin_data_; |
| 437 bool waiting_for_clear_pnacl_cache_; | 432 bool waiting_for_clear_pnacl_cache_; |
| 438 bool waiting_for_clear_quota_managed_data_; | 433 bool waiting_for_clear_quota_managed_data_; |
| 439 bool waiting_for_clear_server_bound_certs_; | 434 bool waiting_for_clear_server_bound_certs_; |
| 440 bool waiting_for_clear_session_storage_; | 435 bool waiting_for_clear_session_storage_; |
| 441 bool waiting_for_clear_shader_cache_; | 436 bool waiting_for_clear_shader_cache_; |
| 442 bool waiting_for_clear_webrtc_identity_store_; | 437 bool waiting_for_clear_webrtc_identity_store_; |
| 438 bool waiting_for_clear_keyword_data_; |
| 443 | 439 |
| 444 // Tracking how many origins need to be deleted, and whether we're finished | 440 // Tracking how many origins need to be deleted, and whether we're finished |
| 445 // gathering origins. | 441 // gathering origins. |
| 446 int quota_managed_origins_to_delete_count_; | 442 int quota_managed_origins_to_delete_count_; |
| 447 int quota_managed_storage_types_to_delete_count_; | 443 int quota_managed_storage_types_to_delete_count_; |
| 448 | 444 |
| 449 // The removal mask for the current removal operation. | 445 // The removal mask for the current removal operation. |
| 450 int remove_mask_; | 446 int remove_mask_; |
| 451 | 447 |
| 452 // The origin for the current removal operation. | 448 // The origin for the current removal operation. |
| 453 GURL remove_origin_; | 449 GURL remove_origin_; |
| 454 | 450 |
| 455 // From which types of origins should we remove data? | 451 // From which types of origins should we remove data? |
| 456 int origin_set_mask_; | 452 int origin_set_mask_; |
| 457 | 453 |
| 458 ObserverList<Observer> observer_list_; | 454 ObserverList<Observer> observer_list_; |
| 459 | 455 |
| 460 // Used if we need to clear history. | 456 // Used if we need to clear history. |
| 461 CancelableTaskTracker history_task_tracker_; | 457 CancelableTaskTracker history_task_tracker_; |
| 462 | 458 |
| 459 scoped_ptr<TemplateURLService::Subscription> template_url_sub_; |
| 460 |
| 463 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemover); | 461 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemover); |
| 464 }; | 462 }; |
| 465 | 463 |
| 466 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_H_ | 464 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_H_ |
| OLD | NEW |