| 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 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 5 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #include "chrome/browser/extensions/extension_service.h" | 23 #include "chrome/browser/extensions/extension_service.h" |
| 24 #include "chrome/browser/extensions/extension_special_storage_policy.h" | 24 #include "chrome/browser/extensions/extension_special_storage_policy.h" |
| 25 #include "chrome/browser/history/history_service.h" | 25 #include "chrome/browser/history/history_service.h" |
| 26 #include "chrome/browser/history/history_service_factory.h" | 26 #include "chrome/browser/history/history_service_factory.h" |
| 27 #include "chrome/browser/io_thread.h" | 27 #include "chrome/browser/io_thread.h" |
| 28 #include "chrome/browser/nacl_host/nacl_browser.h" | 28 #include "chrome/browser/nacl_host/nacl_browser.h" |
| 29 #include "chrome/browser/net/chrome_url_request_context.h" | 29 #include "chrome/browser/net/chrome_url_request_context.h" |
| 30 #include "chrome/browser/net/predictor.h" | 30 #include "chrome/browser/net/predictor.h" |
| 31 #include "chrome/browser/password_manager/password_store.h" | 31 #include "chrome/browser/password_manager/password_store.h" |
| 32 #include "chrome/browser/password_manager/password_store_factory.h" | 32 #include "chrome/browser/password_manager/password_store_factory.h" |
| 33 #include "chrome/browser/predictors/logged_in_predictor_table.h" |
| 34 #include "chrome/browser/predictors/predictor_database.h" |
| 35 #include "chrome/browser/predictors/predictor_database_factory.h" |
| 33 #include "chrome/browser/prerender/prerender_manager.h" | 36 #include "chrome/browser/prerender/prerender_manager.h" |
| 34 #include "chrome/browser/prerender/prerender_manager_factory.h" | 37 #include "chrome/browser/prerender/prerender_manager_factory.h" |
| 35 #include "chrome/browser/profiles/profile.h" | 38 #include "chrome/browser/profiles/profile.h" |
| 36 #include "chrome/browser/renderer_host/web_cache_manager.h" | 39 #include "chrome/browser/renderer_host/web_cache_manager.h" |
| 37 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 40 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 38 #include "chrome/browser/search_engines/template_url_service.h" | 41 #include "chrome/browser/search_engines/template_url_service.h" |
| 39 #include "chrome/browser/search_engines/template_url_service_factory.h" | 42 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 40 #include "chrome/browser/sessions/session_service.h" | 43 #include "chrome/browser/sessions/session_service.h" |
| 41 #include "chrome/browser/sessions/session_service_factory.h" | 44 #include "chrome/browser/sessions/session_service_factory.h" |
| 42 #include "chrome/browser/sessions/tab_restore_service.h" | 45 #include "chrome/browser/sessions/tab_restore_service.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 main_context_getter_(profile->GetRequestContext()), | 136 main_context_getter_(profile->GetRequestContext()), |
| 134 media_context_getter_(profile->GetMediaRequestContext()), | 137 media_context_getter_(profile->GetMediaRequestContext()), |
| 135 deauthorize_content_licenses_request_id_(0), | 138 deauthorize_content_licenses_request_id_(0), |
| 136 waiting_for_clear_cache_(false), | 139 waiting_for_clear_cache_(false), |
| 137 waiting_for_clear_content_licenses_(false), | 140 waiting_for_clear_content_licenses_(false), |
| 138 waiting_for_clear_cookies_count_(0), | 141 waiting_for_clear_cookies_count_(0), |
| 139 waiting_for_clear_form_(false), | 142 waiting_for_clear_form_(false), |
| 140 waiting_for_clear_history_(false), | 143 waiting_for_clear_history_(false), |
| 141 waiting_for_clear_hostname_resolution_cache_(false), | 144 waiting_for_clear_hostname_resolution_cache_(false), |
| 142 waiting_for_clear_local_storage_(false), | 145 waiting_for_clear_local_storage_(false), |
| 146 waiting_for_clear_logged_in_predictor_(false), |
| 143 waiting_for_clear_nacl_cache_(false), | 147 waiting_for_clear_nacl_cache_(false), |
| 144 waiting_for_clear_network_predictor_(false), | 148 waiting_for_clear_network_predictor_(false), |
| 145 waiting_for_clear_networking_history_(false), | 149 waiting_for_clear_networking_history_(false), |
| 146 waiting_for_clear_plugin_data_(false), | 150 waiting_for_clear_plugin_data_(false), |
| 147 waiting_for_clear_quota_managed_data_(false), | 151 waiting_for_clear_quota_managed_data_(false), |
| 148 waiting_for_clear_server_bound_certs_(false), | 152 waiting_for_clear_server_bound_certs_(false), |
| 149 waiting_for_clear_session_storage_(false), | 153 waiting_for_clear_session_storage_(false), |
| 150 waiting_for_clear_shader_cache_(false), | 154 waiting_for_clear_shader_cache_(false), |
| 151 remove_mask_(0), | 155 remove_mask_(0), |
| 152 remove_origin_(GURL()), | 156 remove_origin_(GURL()), |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 content::RecordAction(UserMetricsAction("ClearBrowsingData_Cookies")); | 336 content::RecordAction(UserMetricsAction("ClearBrowsingData_Cookies")); |
| 333 // Since we are running on the UI thread don't call GetURLRequestContext(). | 337 // Since we are running on the UI thread don't call GetURLRequestContext(). |
| 334 net::URLRequestContextGetter* rq_context = profile_->GetRequestContext(); | 338 net::URLRequestContextGetter* rq_context = profile_->GetRequestContext(); |
| 335 if (rq_context) { | 339 if (rq_context) { |
| 336 ++waiting_for_clear_cookies_count_; | 340 ++waiting_for_clear_cookies_count_; |
| 337 BrowserThread::PostTask( | 341 BrowserThread::PostTask( |
| 338 BrowserThread::IO, FROM_HERE, | 342 BrowserThread::IO, FROM_HERE, |
| 339 base::Bind(&BrowsingDataRemover::ClearCookiesOnIOThread, | 343 base::Bind(&BrowsingDataRemover::ClearCookiesOnIOThread, |
| 340 base::Unretained(this), base::Unretained(rq_context))); | 344 base::Unretained(this), base::Unretained(rq_context))); |
| 341 } | 345 } |
| 346 // Also delete the LoggedIn Predictor, which tries to keep track of which |
| 347 // sites a user is logged into. |
| 348 ClearLoggedInPredictor(); |
| 342 | 349 |
| 343 #if defined(FULL_SAFE_BROWSING) || defined(MOBILE_SAFE_BROWSING) | 350 #if defined(FULL_SAFE_BROWSING) || defined(MOBILE_SAFE_BROWSING) |
| 344 // Clear the safebrowsing cookies only if time period is for "all time". It | 351 // Clear the safebrowsing cookies only if time period is for "all time". It |
| 345 // doesn't make sense to apply the time period of deleting in the last X | 352 // doesn't make sense to apply the time period of deleting in the last X |
| 346 // hours/days to the safebrowsing cookies since they aren't the result of | 353 // hours/days to the safebrowsing cookies since they aren't the result of |
| 347 // any user action. | 354 // any user action. |
| 348 if (delete_begin_ == base::Time()) { | 355 if (delete_begin_ == base::Time()) { |
| 349 SafeBrowsingService* sb_service = | 356 SafeBrowsingService* sb_service = |
| 350 g_browser_process->safe_browsing_service(); | 357 g_browser_process->safe_browsing_service(); |
| 351 if (sb_service) { | 358 if (sb_service) { |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 return delete_begin_time - diff; | 574 return delete_begin_time - diff; |
| 568 } | 575 } |
| 569 | 576 |
| 570 bool BrowsingDataRemover::AllDone() { | 577 bool BrowsingDataRemover::AllDone() { |
| 571 return registrar_.IsEmpty() && | 578 return registrar_.IsEmpty() && |
| 572 !waiting_for_clear_cache_ && | 579 !waiting_for_clear_cache_ && |
| 573 !waiting_for_clear_nacl_cache_ && | 580 !waiting_for_clear_nacl_cache_ && |
| 574 !waiting_for_clear_cookies_count_&& | 581 !waiting_for_clear_cookies_count_&& |
| 575 !waiting_for_clear_history_ && | 582 !waiting_for_clear_history_ && |
| 576 !waiting_for_clear_local_storage_ && | 583 !waiting_for_clear_local_storage_ && |
| 584 !waiting_for_clear_logged_in_predictor_ && |
| 577 !waiting_for_clear_session_storage_ && | 585 !waiting_for_clear_session_storage_ && |
| 578 !waiting_for_clear_networking_history_ && | 586 !waiting_for_clear_networking_history_ && |
| 579 !waiting_for_clear_server_bound_certs_ && | 587 !waiting_for_clear_server_bound_certs_ && |
| 580 !waiting_for_clear_plugin_data_ && | 588 !waiting_for_clear_plugin_data_ && |
| 581 !waiting_for_clear_quota_managed_data_ && | 589 !waiting_for_clear_quota_managed_data_ && |
| 582 !waiting_for_clear_content_licenses_ && | 590 !waiting_for_clear_content_licenses_ && |
| 583 !waiting_for_clear_form_ && | 591 !waiting_for_clear_form_ && |
| 584 !waiting_for_clear_hostname_resolution_cache_ && | 592 !waiting_for_clear_hostname_resolution_cache_ && |
| 585 !waiting_for_clear_network_predictor_ && | 593 !waiting_for_clear_network_predictor_ && |
| 586 !waiting_for_clear_shader_cache_; | 594 !waiting_for_clear_shader_cache_; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 636 io_thread->ClearHostCache(); | 644 io_thread->ClearHostCache(); |
| 637 | 645 |
| 638 // Notify the UI thread that we are done. | 646 // Notify the UI thread that we are done. |
| 639 BrowserThread::PostTask( | 647 BrowserThread::PostTask( |
| 640 BrowserThread::UI, | 648 BrowserThread::UI, |
| 641 FROM_HERE, | 649 FROM_HERE, |
| 642 base::Bind(&BrowsingDataRemover::OnClearedHostnameResolutionCache, | 650 base::Bind(&BrowsingDataRemover::OnClearedHostnameResolutionCache, |
| 643 base::Unretained(this))); | 651 base::Unretained(this))); |
| 644 } | 652 } |
| 645 | 653 |
| 654 void BrowsingDataRemover::OnClearedLoggedInPredictor() { |
| 655 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 656 DCHECK(waiting_for_clear_logged_in_predictor_); |
| 657 waiting_for_clear_logged_in_predictor_ = false; |
| 658 NotifyAndDeleteIfDone(); |
| 659 } |
| 660 |
| 661 void BrowsingDataRemover::ClearLoggedInPredictor() { |
| 662 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 663 DCHECK(!waiting_for_clear_logged_in_predictor_); |
| 664 |
| 665 predictors::LoggedInPredictorTable* logged_in_table = |
| 666 predictors::PredictorDatabaseFactory::GetForProfile(profile_)-> |
| 667 logged_in_table(); |
| 668 |
| 669 if (!logged_in_table) |
| 670 return; |
| 671 |
| 672 waiting_for_clear_logged_in_predictor_ = true; |
| 673 |
| 674 BrowserThread::PostTaskAndReply( |
| 675 BrowserThread::DB, |
| 676 FROM_HERE, |
| 677 base::Bind(&predictors::LoggedInPredictorTable::DeleteAllCreatedBetween, |
| 678 logged_in_table, |
| 679 delete_begin_, |
| 680 delete_end_), |
| 681 base::Bind(&BrowsingDataRemover::OnClearedLoggedInPredictor, |
| 682 base::Unretained(this))); |
| 683 } |
| 684 |
| 646 void BrowsingDataRemover::OnClearedNetworkPredictor() { | 685 void BrowsingDataRemover::OnClearedNetworkPredictor() { |
| 647 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 686 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 648 waiting_for_clear_network_predictor_ = false; | 687 waiting_for_clear_network_predictor_ = false; |
| 649 NotifyAndDeleteIfDone(); | 688 NotifyAndDeleteIfDone(); |
| 650 } | 689 } |
| 651 | 690 |
| 652 void BrowsingDataRemover::ClearNetworkPredictorOnIOThread() { | 691 void BrowsingDataRemover::ClearNetworkPredictorOnIOThread() { |
| 653 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 692 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 654 | 693 |
| 655 chrome_browser_net::Predictor* predictor = profile_->GetNetworkPredictor(); | 694 chrome_browser_net::Predictor* predictor = profile_->GetNetworkPredictor(); |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1025 BrowserThread::UI, FROM_HERE, | 1064 BrowserThread::UI, FROM_HERE, |
| 1026 base::Bind(&BrowsingDataRemover::OnClearedFormData, | 1065 base::Bind(&BrowsingDataRemover::OnClearedFormData, |
| 1027 base::Unretained(this))); | 1066 base::Unretained(this))); |
| 1028 } | 1067 } |
| 1029 | 1068 |
| 1030 void BrowsingDataRemover::OnClearedFormData() { | 1069 void BrowsingDataRemover::OnClearedFormData() { |
| 1031 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1070 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1032 waiting_for_clear_form_ = false; | 1071 waiting_for_clear_form_ = false; |
| 1033 NotifyAndDeleteIfDone(); | 1072 NotifyAndDeleteIfDone(); |
| 1034 } | 1073 } |
| OLD | NEW |