| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/chrome_browsing_data_remover_delegate.h" | 5 #include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 // Need to clear the host cache and accumulated speculative data, as it also | 478 // Need to clear the host cache and accumulated speculative data, as it also |
| 479 // reveals some history. We have no mechanism to track when these items were | 479 // reveals some history. We have no mechanism to track when these items were |
| 480 // created, so we'll not honor the time range. | 480 // created, so we'll not honor the time range. |
| 481 // TODO(msramek): We can use the plugin filter here because plugins, same | 481 // TODO(msramek): We can use the plugin filter here because plugins, same |
| 482 // as the hostname resolution cache, key their entries by hostname. Rename | 482 // as the hostname resolution cache, key their entries by hostname. Rename |
| 483 // BuildPluginFilter() to something more general to reflect this use. | 483 // BuildPluginFilter() to something more general to reflect this use. |
| 484 if (g_browser_process->io_thread()) { | 484 if (g_browser_process->io_thread()) { |
| 485 clear_hostname_resolution_cache_.Start(); | 485 clear_hostname_resolution_cache_.Start(); |
| 486 BrowserThread::PostTaskAndReply( | 486 BrowserThread::PostTaskAndReply( |
| 487 BrowserThread::IO, FROM_HERE, | 487 BrowserThread::IO, FROM_HERE, |
| 488 base::Bind(&ClearHostnameResolutionCacheOnIOThread, | 488 base::BindOnce(&ClearHostnameResolutionCacheOnIOThread, |
| 489 g_browser_process->io_thread(), | 489 g_browser_process->io_thread(), |
| 490 filter_builder.BuildPluginFilter()), | 490 filter_builder.BuildPluginFilter()), |
| 491 clear_hostname_resolution_cache_.GetCompletionCallback()); | 491 clear_hostname_resolution_cache_.GetCompletionCallback()); |
| 492 } | 492 } |
| 493 if (profile_->GetNetworkPredictor()) { | 493 if (profile_->GetNetworkPredictor()) { |
| 494 // TODO(dmurph): Support all backends with filter (crbug.com/113621). | 494 // TODO(dmurph): Support all backends with filter (crbug.com/113621). |
| 495 clear_network_predictor_.Start(); | 495 clear_network_predictor_.Start(); |
| 496 BrowserThread::PostTaskAndReply( | 496 BrowserThread::PostTaskAndReply( |
| 497 BrowserThread::IO, FROM_HERE, | 497 BrowserThread::IO, FROM_HERE, |
| 498 base::Bind(&ClearNetworkPredictorOnIOThread, | 498 base::BindOnce(&ClearNetworkPredictorOnIOThread, |
| 499 profile_->GetNetworkPredictor()), | 499 profile_->GetNetworkPredictor()), |
| 500 clear_network_predictor_.GetCompletionCallback()); | 500 clear_network_predictor_.GetCompletionCallback()); |
| 501 profile_->GetNetworkPredictor()->ClearPrefsOnUIThread(); | 501 profile_->GetNetworkPredictor()->ClearPrefsOnUIThread(); |
| 502 } | 502 } |
| 503 | 503 |
| 504 // As part of history deletion we also delete the auto-generated keywords. | 504 // As part of history deletion we also delete the auto-generated keywords. |
| 505 TemplateURLService* keywords_model = | 505 TemplateURLService* keywords_model = |
| 506 TemplateURLServiceFactory::GetForProfile(profile_); | 506 TemplateURLServiceFactory::GetForProfile(profile_); |
| 507 | 507 |
| 508 if (keywords_model && !keywords_model->loaded()) { | 508 if (keywords_model && !keywords_model->loaded()) { |
| 509 // TODO(msramek): Store filters from the currently executed task on the | 509 // TODO(msramek): Store filters from the currently executed task on the |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 scoped_refptr<autofill::AutofillWebDataService> web_data_service = | 559 scoped_refptr<autofill::AutofillWebDataService> web_data_service = |
| 560 WebDataServiceFactory::GetAutofillWebDataForProfile( | 560 WebDataServiceFactory::GetAutofillWebDataForProfile( |
| 561 profile_, ServiceAccessType::EXPLICIT_ACCESS); | 561 profile_, ServiceAccessType::EXPLICIT_ACCESS); |
| 562 if (web_data_service.get()) { | 562 if (web_data_service.get()) { |
| 563 clear_autofill_origin_urls_.Start(); | 563 clear_autofill_origin_urls_.Start(); |
| 564 web_data_service->RemoveOriginURLsModifiedBetween( | 564 web_data_service->RemoveOriginURLsModifiedBetween( |
| 565 delete_begin_, delete_end_); | 565 delete_begin_, delete_end_); |
| 566 // The above calls are done on the UI thread but do their work on the DB | 566 // The above calls are done on the UI thread but do their work on the DB |
| 567 // thread. So wait for it. | 567 // thread. So wait for it. |
| 568 BrowserThread::PostTaskAndReply( | 568 BrowserThread::PostTaskAndReply( |
| 569 BrowserThread::DB, FROM_HERE, base::Bind(&base::DoNothing), | 569 BrowserThread::DB, FROM_HERE, base::BindOnce(&base::DoNothing), |
| 570 clear_autofill_origin_urls_.GetCompletionCallback()); | 570 clear_autofill_origin_urls_.GetCompletionCallback()); |
| 571 | 571 |
| 572 autofill::PersonalDataManager* data_manager = | 572 autofill::PersonalDataManager* data_manager = |
| 573 autofill::PersonalDataManagerFactory::GetForProfile(profile_); | 573 autofill::PersonalDataManagerFactory::GetForProfile(profile_); |
| 574 if (data_manager) | 574 if (data_manager) |
| 575 data_manager->Refresh(); | 575 data_manager->Refresh(); |
| 576 } | 576 } |
| 577 | 577 |
| 578 #if BUILDFLAG(ENABLE_WEBRTC) | 578 #if BUILDFLAG(ENABLE_WEBRTC) |
| 579 clear_webrtc_logs_.Start(); | 579 clear_webrtc_logs_.Start(); |
| 580 BrowserThread::PostTaskAndReply( | 580 BrowserThread::PostTaskAndReply( |
| 581 BrowserThread::FILE, FROM_HERE, | 581 BrowserThread::FILE, FROM_HERE, |
| 582 base::Bind( | 582 base::BindOnce( |
| 583 &WebRtcLogUtil::DeleteOldAndRecentWebRtcLogFiles, | 583 &WebRtcLogUtil::DeleteOldAndRecentWebRtcLogFiles, |
| 584 WebRtcLogList::GetWebRtcLogDirectoryForProfile(profile_->GetPath()), | 584 WebRtcLogList::GetWebRtcLogDirectoryForProfile(profile_->GetPath()), |
| 585 delete_begin_), | 585 delete_begin_), |
| 586 clear_webrtc_logs_.GetCompletionCallback()); | 586 clear_webrtc_logs_.GetCompletionCallback()); |
| 587 #endif | 587 #endif |
| 588 | 588 |
| 589 #if defined(OS_ANDROID) | 589 #if defined(OS_ANDROID) |
| 590 precache::PrecacheManager* precache_manager = | 590 precache::PrecacheManager* precache_manager = |
| 591 precache::PrecacheManagerFactory::GetForBrowserContext(profile_); | 591 precache::PrecacheManagerFactory::GetForBrowserContext(profile_); |
| 592 // |precache_manager| could be nullptr if the profile is off the record. | 592 // |precache_manager| could be nullptr if the profile is off the record. |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 668 if (delete_begin_ == base::Time()) { | 668 if (delete_begin_ == base::Time()) { |
| 669 safe_browsing::SafeBrowsingService* sb_service = | 669 safe_browsing::SafeBrowsingService* sb_service = |
| 670 g_browser_process->safe_browsing_service(); | 670 g_browser_process->safe_browsing_service(); |
| 671 if (sb_service) { | 671 if (sb_service) { |
| 672 scoped_refptr<net::URLRequestContextGetter> sb_context = | 672 scoped_refptr<net::URLRequestContextGetter> sb_context = |
| 673 sb_service->url_request_context(); | 673 sb_service->url_request_context(); |
| 674 ++clear_cookies_count_; | 674 ++clear_cookies_count_; |
| 675 if (filter_builder.IsEmptyBlacklist()) { | 675 if (filter_builder.IsEmptyBlacklist()) { |
| 676 BrowserThread::PostTask( | 676 BrowserThread::PostTask( |
| 677 BrowserThread::IO, FROM_HERE, | 677 BrowserThread::IO, FROM_HERE, |
| 678 base::Bind( | 678 base::BindOnce( |
| 679 &ClearCookiesOnIOThread, delete_begin_, delete_end_, | 679 &ClearCookiesOnIOThread, delete_begin_, delete_end_, |
| 680 base::RetainedRef(std::move(sb_context)), | 680 base::RetainedRef(std::move(sb_context)), |
| 681 UIThreadTrampoline( | 681 UIThreadTrampoline(base::Bind( |
| 682 base::Bind( | 682 &ChromeBrowsingDataRemoverDelegate::OnClearedCookies, |
| 683 &ChromeBrowsingDataRemoverDelegate::OnClearedCookies, | 683 weak_ptr_factory_.GetWeakPtr())))); |
| 684 weak_ptr_factory_.GetWeakPtr())))); | |
| 685 } else { | 684 } else { |
| 686 BrowserThread::PostTask( | 685 BrowserThread::PostTask( |
| 687 BrowserThread::IO, FROM_HERE, | 686 BrowserThread::IO, FROM_HERE, |
| 688 base::Bind( | 687 base::BindOnce( |
| 689 &ClearCookiesWithPredicateOnIOThread, delete_begin_, | 688 &ClearCookiesWithPredicateOnIOThread, delete_begin_, |
| 690 delete_end_, filter_builder.BuildCookieFilter(), | 689 delete_end_, filter_builder.BuildCookieFilter(), |
| 691 base::RetainedRef(std::move(sb_context)), | 690 base::RetainedRef(std::move(sb_context)), |
| 692 UIThreadTrampoline( | 691 UIThreadTrampoline(base::Bind( |
| 693 base::Bind( | 692 &ChromeBrowsingDataRemoverDelegate::OnClearedCookies, |
| 694 &ChromeBrowsingDataRemoverDelegate::OnClearedCookies, | 693 weak_ptr_factory_.GetWeakPtr())))); |
| 695 weak_ptr_factory_.GetWeakPtr())))); | |
| 696 } | 694 } |
| 697 } | 695 } |
| 698 } | 696 } |
| 699 | 697 |
| 700 MediaDeviceIDSalt::Reset(profile_->GetPrefs()); | 698 MediaDeviceIDSalt::Reset(profile_->GetPrefs()); |
| 701 } | 699 } |
| 702 | 700 |
| 703 ////////////////////////////////////////////////////////////////////////////// | 701 ////////////////////////////////////////////////////////////////////////////// |
| 704 // DATA_TYPE_DURABLE_PERMISSION | 702 // DATA_TYPE_DURABLE_PERMISSION |
| 705 if (remove_mask & DATA_TYPE_DURABLE_PERMISSION) { | 703 if (remove_mask & DATA_TYPE_DURABLE_PERMISSION) { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 743 filter, delete_begin_, delete_end_, | 741 filter, delete_begin_, delete_end_, |
| 744 clear_passwords_.GetCompletionCallback()); | 742 clear_passwords_.GetCompletionCallback()); |
| 745 } | 743 } |
| 746 | 744 |
| 747 scoped_refptr<net::URLRequestContextGetter> request_context = | 745 scoped_refptr<net::URLRequestContextGetter> request_context = |
| 748 BrowserContext::GetDefaultStoragePartition(profile_) | 746 BrowserContext::GetDefaultStoragePartition(profile_) |
| 749 ->GetURLRequestContext(); | 747 ->GetURLRequestContext(); |
| 750 clear_http_auth_cache_.Start(); | 748 clear_http_auth_cache_.Start(); |
| 751 BrowserThread::PostTaskAndReply( | 749 BrowserThread::PostTaskAndReply( |
| 752 BrowserThread::IO, FROM_HERE, | 750 BrowserThread::IO, FROM_HERE, |
| 753 base::Bind(&ClearHttpAuthCacheOnIOThread, std::move(request_context), | 751 base::BindOnce(&ClearHttpAuthCacheOnIOThread, |
| 754 delete_begin_), | 752 std::move(request_context), delete_begin_), |
| 755 clear_http_auth_cache_.GetCompletionCallback()); | 753 clear_http_auth_cache_.GetCompletionCallback()); |
| 756 } | 754 } |
| 757 | 755 |
| 758 if (remove_mask & BrowsingDataRemover::DATA_TYPE_COOKIES) { | 756 if (remove_mask & BrowsingDataRemover::DATA_TYPE_COOKIES) { |
| 759 password_manager::PasswordStore* password_store = | 757 password_manager::PasswordStore* password_store = |
| 760 PasswordStoreFactory::GetForProfile(profile_, | 758 PasswordStoreFactory::GetForProfile(profile_, |
| 761 ServiceAccessType::EXPLICIT_ACCESS) | 759 ServiceAccessType::EXPLICIT_ACCESS) |
| 762 .get(); | 760 .get(); |
| 763 | 761 |
| 764 if (password_store) { | 762 if (password_store) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 791 profile_, ServiceAccessType::EXPLICIT_ACCESS); | 789 profile_, ServiceAccessType::EXPLICIT_ACCESS); |
| 792 | 790 |
| 793 if (web_data_service.get()) { | 791 if (web_data_service.get()) { |
| 794 clear_form_.Start(); | 792 clear_form_.Start(); |
| 795 web_data_service->RemoveFormElementsAddedBetween(delete_begin_, | 793 web_data_service->RemoveFormElementsAddedBetween(delete_begin_, |
| 796 delete_end_); | 794 delete_end_); |
| 797 web_data_service->RemoveAutofillDataModifiedBetween( | 795 web_data_service->RemoveAutofillDataModifiedBetween( |
| 798 delete_begin_, delete_end_); | 796 delete_begin_, delete_end_); |
| 799 // The above calls are done on the UI thread but do their work on the DB | 797 // The above calls are done on the UI thread but do their work on the DB |
| 800 // thread. So wait for it. | 798 // thread. So wait for it. |
| 801 BrowserThread::PostTaskAndReply( | 799 BrowserThread::PostTaskAndReply(BrowserThread::DB, FROM_HERE, |
| 802 BrowserThread::DB, FROM_HERE, base::Bind(&base::DoNothing), | 800 base::BindOnce(&base::DoNothing), |
| 803 clear_form_.GetCompletionCallback()); | 801 clear_form_.GetCompletionCallback()); |
| 804 | 802 |
| 805 autofill::PersonalDataManager* data_manager = | 803 autofill::PersonalDataManager* data_manager = |
| 806 autofill::PersonalDataManagerFactory::GetForProfile(profile_); | 804 autofill::PersonalDataManagerFactory::GetForProfile(profile_); |
| 807 if (data_manager) | 805 if (data_manager) |
| 808 data_manager->Refresh(); | 806 data_manager->Refresh(); |
| 809 } | 807 } |
| 810 } | 808 } |
| 811 | 809 |
| 812 ////////////////////////////////////////////////////////////////////////////// | 810 ////////////////////////////////////////////////////////////////////////////// |
| 813 // DATA_TYPE_CACHE | 811 // DATA_TYPE_CACHE |
| 814 if (remove_mask & BrowsingDataRemover::DATA_TYPE_CACHE) { | 812 if (remove_mask & BrowsingDataRemover::DATA_TYPE_CACHE) { |
| 815 // Tell the renderers to clear their cache. | 813 // Tell the renderers to clear their cache. |
| 816 // TODO(crbug.com/668114): Renderer cache is a platform concept, and should | 814 // TODO(crbug.com/668114): Renderer cache is a platform concept, and should |
| 817 // live in BrowsingDataRemoverImpl. However, WebCacheManager itself is | 815 // live in BrowsingDataRemoverImpl. However, WebCacheManager itself is |
| 818 // a component with dependency on content/browser. Untangle these | 816 // a component with dependency on content/browser. Untangle these |
| 819 // dependencies or reimplement the relevant part of WebCacheManager | 817 // dependencies or reimplement the relevant part of WebCacheManager |
| 820 // in content/browser. | 818 // in content/browser. |
| 821 web_cache::WebCacheManager::GetInstance()->ClearCache(); | 819 web_cache::WebCacheManager::GetInstance()->ClearCache(); |
| 822 | 820 |
| 823 #if !defined(DISABLE_NACL) | 821 #if !defined(DISABLE_NACL) |
| 824 clear_nacl_cache_.Start(); | 822 clear_nacl_cache_.Start(); |
| 825 | 823 |
| 826 BrowserThread::PostTask( | 824 BrowserThread::PostTask( |
| 827 BrowserThread::IO, FROM_HERE, | 825 BrowserThread::IO, FROM_HERE, |
| 828 base::Bind(&ClearNaClCacheOnIOThread, | 826 base::BindOnce( |
| 829 UIThreadTrampoline( | 827 &ClearNaClCacheOnIOThread, |
| 830 clear_nacl_cache_.GetCompletionCallback()))); | 828 UIThreadTrampoline(clear_nacl_cache_.GetCompletionCallback()))); |
| 831 | 829 |
| 832 clear_pnacl_cache_.Start(); | 830 clear_pnacl_cache_.Start(); |
| 833 BrowserThread::PostTask( | 831 BrowserThread::PostTask( |
| 834 BrowserThread::IO, FROM_HERE, | 832 BrowserThread::IO, FROM_HERE, |
| 835 base::Bind( | 833 base::BindOnce( |
| 836 &ClearPnaclCacheOnIOThread, delete_begin_, delete_end_, | 834 &ClearPnaclCacheOnIOThread, delete_begin_, delete_end_, |
| 837 UIThreadTrampoline(clear_pnacl_cache_.GetCompletionCallback()))); | 835 UIThreadTrampoline(clear_pnacl_cache_.GetCompletionCallback()))); |
| 838 #endif | 836 #endif |
| 839 | 837 |
| 840 // The PrerenderManager may have a page actively being prerendered, which | 838 // The PrerenderManager may have a page actively being prerendered, which |
| 841 // is essentially a preemptively cached page. | 839 // is essentially a preemptively cached page. |
| 842 prerender::PrerenderManager* prerender_manager = | 840 prerender::PrerenderManager* prerender_manager = |
| 843 prerender::PrerenderManagerFactory::GetForBrowserContext(profile_); | 841 prerender::PrerenderManagerFactory::GetForBrowserContext(profile_); |
| 844 if (prerender_manager) { | 842 if (prerender_manager) { |
| 845 prerender_manager->ClearData( | 843 prerender_manager->ClearData( |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1134 } | 1132 } |
| 1135 | 1133 |
| 1136 void ChromeBrowsingDataRemoverDelegate:: | 1134 void ChromeBrowsingDataRemoverDelegate:: |
| 1137 OnDeauthorizeFlashContentLicensesCompleted( | 1135 OnDeauthorizeFlashContentLicensesCompleted( |
| 1138 uint32_t request_id, | 1136 uint32_t request_id, |
| 1139 bool /* success */) { | 1137 bool /* success */) { |
| 1140 DCHECK_EQ(request_id, deauthorize_flash_content_licenses_request_id_); | 1138 DCHECK_EQ(request_id, deauthorize_flash_content_licenses_request_id_); |
| 1141 clear_flash_content_licenses_.GetCompletionCallback().Run(); | 1139 clear_flash_content_licenses_.GetCompletionCallback().Run(); |
| 1142 } | 1140 } |
| 1143 #endif | 1141 #endif |
| OLD | NEW |