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 "chrome/browser/autofill/personal_data_manager_factory.h" | 7 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
8 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 8 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/browsing_data/browsing_data_filter_builder.h" | 10 #include "chrome/browser/browsing_data/browsing_data_filter_builder.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 #include "components/password_manager/core/browser/password_store.h" | 57 #include "components/password_manager/core/browser/password_store.h" |
58 #include "components/prefs/pref_service.h" | 58 #include "components/prefs/pref_service.h" |
59 #include "components/previews/core/previews_ui_service.h" | 59 #include "components/previews/core/previews_ui_service.h" |
60 #include "components/search_engines/template_url_service.h" | 60 #include "components/search_engines/template_url_service.h" |
61 #include "components/sessions/core/tab_restore_service.h" | 61 #include "components/sessions/core/tab_restore_service.h" |
62 #include "content/public/browser/user_metrics.h" | 62 #include "content/public/browser/user_metrics.h" |
63 #include "net/cookies/cookie_store.h" | 63 #include "net/cookies/cookie_store.h" |
64 #include "net/url_request/url_request_context.h" | 64 #include "net/url_request/url_request_context.h" |
65 #include "net/url_request/url_request_context_getter.h" | 65 #include "net/url_request/url_request_context_getter.h" |
66 | 66 |
67 #if BUILDFLAG(ANDROID_JAVA_UI) | 67 #if defined(OS_ANDROID) |
68 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" | 68 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" |
69 #include "chrome/browser/android/webapps/webapp_registry.h" | 69 #include "chrome/browser/android/webapps/webapp_registry.h" |
70 #include "chrome/browser/precache/precache_manager_factory.h" | 70 #include "chrome/browser/precache/precache_manager_factory.h" |
71 #include "components/offline_pages/core/offline_page_feature.h" | 71 #include "components/offline_pages/core/offline_page_feature.h" |
72 #include "components/offline_pages/core/offline_page_model.h" | 72 #include "components/offline_pages/core/offline_page_model.h" |
73 #include "components/precache/content/precache_manager.h" | 73 #include "components/precache/content/precache_manager.h" |
74 #endif | 74 #endif |
75 | 75 |
76 #if BUILDFLAG(ENABLE_EXTENSIONS) | 76 #if BUILDFLAG(ENABLE_EXTENSIONS) |
77 #include "chrome/browser/extensions/activity_log/activity_log.h" | 77 #include "chrome/browser/extensions/activity_log/activity_log.h" |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 #if !defined(DISABLE_NACL) | 210 #if !defined(DISABLE_NACL) |
211 clear_nacl_cache_(sub_task_forward_callback_), | 211 clear_nacl_cache_(sub_task_forward_callback_), |
212 clear_pnacl_cache_(sub_task_forward_callback_), | 212 clear_pnacl_cache_(sub_task_forward_callback_), |
213 #endif | 213 #endif |
214 clear_hostname_resolution_cache_(sub_task_forward_callback_), | 214 clear_hostname_resolution_cache_(sub_task_forward_callback_), |
215 clear_network_predictor_(sub_task_forward_callback_), | 215 clear_network_predictor_(sub_task_forward_callback_), |
216 clear_networking_history_(sub_task_forward_callback_), | 216 clear_networking_history_(sub_task_forward_callback_), |
217 clear_passwords_(sub_task_forward_callback_), | 217 clear_passwords_(sub_task_forward_callback_), |
218 clear_passwords_stats_(sub_task_forward_callback_), | 218 clear_passwords_stats_(sub_task_forward_callback_), |
219 clear_platform_keys_(sub_task_forward_callback_), | 219 clear_platform_keys_(sub_task_forward_callback_), |
220 #if BUILDFLAG(ANDROID_JAVA_UI) | 220 #if defined(OS_ANDROID) |
221 clear_precache_history_(sub_task_forward_callback_), | 221 clear_precache_history_(sub_task_forward_callback_), |
222 clear_offline_page_data_(sub_task_forward_callback_), | 222 clear_offline_page_data_(sub_task_forward_callback_), |
223 #endif | 223 #endif |
224 #if BUILDFLAG(ENABLE_WEBRTC) | 224 #if BUILDFLAG(ENABLE_WEBRTC) |
225 clear_webrtc_logs_(sub_task_forward_callback_), | 225 clear_webrtc_logs_(sub_task_forward_callback_), |
226 #endif | 226 #endif |
227 clear_auto_sign_in_(sub_task_forward_callback_), | 227 clear_auto_sign_in_(sub_task_forward_callback_), |
228 #if BUILDFLAG(ANDROID_JAVA_UI) | 228 #if defined(OS_ANDROID) |
229 webapp_registry_(new WebappRegistry()), | 229 webapp_registry_(new WebappRegistry()), |
230 #endif | 230 #endif |
231 weak_ptr_factory_(this) {} | 231 weak_ptr_factory_(this) {} |
232 | 232 |
233 ChromeBrowsingDataRemoverDelegate::~ChromeBrowsingDataRemoverDelegate() { | 233 ChromeBrowsingDataRemoverDelegate::~ChromeBrowsingDataRemoverDelegate() { |
234 history_task_tracker_.TryCancelAll(); | 234 history_task_tracker_.TryCancelAll(); |
235 template_url_sub_.reset(); | 235 template_url_sub_.reset(); |
236 } | 236 } |
237 | 237 |
238 void ChromeBrowsingDataRemoverDelegate::RemoveEmbedderData( | 238 void ChromeBrowsingDataRemoverDelegate::RemoveEmbedderData( |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 clear_webrtc_logs_.Start(); | 425 clear_webrtc_logs_.Start(); |
426 BrowserThread::PostTaskAndReply( | 426 BrowserThread::PostTaskAndReply( |
427 BrowserThread::FILE, FROM_HERE, | 427 BrowserThread::FILE, FROM_HERE, |
428 base::Bind( | 428 base::Bind( |
429 &WebRtcLogUtil::DeleteOldAndRecentWebRtcLogFiles, | 429 &WebRtcLogUtil::DeleteOldAndRecentWebRtcLogFiles, |
430 WebRtcLogList::GetWebRtcLogDirectoryForProfile(profile_->GetPath()), | 430 WebRtcLogList::GetWebRtcLogDirectoryForProfile(profile_->GetPath()), |
431 delete_begin_), | 431 delete_begin_), |
432 clear_webrtc_logs_.GetCompletionCallback()); | 432 clear_webrtc_logs_.GetCompletionCallback()); |
433 #endif | 433 #endif |
434 | 434 |
435 #if BUILDFLAG(ANDROID_JAVA_UI) | 435 #if defined(OS_ANDROID) |
436 precache::PrecacheManager* precache_manager = | 436 precache::PrecacheManager* precache_manager = |
437 precache::PrecacheManagerFactory::GetForBrowserContext(profile_); | 437 precache::PrecacheManagerFactory::GetForBrowserContext(profile_); |
438 // |precache_manager| could be nullptr if the profile is off the record. | 438 // |precache_manager| could be nullptr if the profile is off the record. |
439 if (!precache_manager) { | 439 if (!precache_manager) { |
440 clear_precache_history_.Start(); | 440 clear_precache_history_.Start(); |
441 precache_manager->ClearHistory(); | 441 precache_manager->ClearHistory(); |
442 // The above calls are done on the UI thread but do their work on the DB | 442 // The above calls are done on the UI thread but do their work on the DB |
443 // thread. So wait for it. | 443 // thread. So wait for it. |
444 BrowserThread::PostTaskAndReply( | 444 BrowserThread::PostTaskAndReply( |
445 BrowserThread::DB, FROM_HERE, base::Bind(&base::DoNothing), | 445 BrowserThread::DB, FROM_HERE, base::Bind(&base::DoNothing), |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
680 Profile::ProfileType::REGULAR_PROFILE || | 680 Profile::ProfileType::REGULAR_PROFILE || |
681 ui_nqe_service != nullptr); | 681 ui_nqe_service != nullptr); |
682 if (ui_nqe_service) { | 682 if (ui_nqe_service) { |
683 // Network Quality Estimator (NQE) stores the quality (RTT, bandwidth | 683 // Network Quality Estimator (NQE) stores the quality (RTT, bandwidth |
684 // etc.) of different networks in prefs. The stored quality is not | 684 // etc.) of different networks in prefs. The stored quality is not |
685 // broken down by URLs or timestamps, so clearing the cache should | 685 // broken down by URLs or timestamps, so clearing the cache should |
686 // completely clear the prefs. | 686 // completely clear the prefs. |
687 ui_nqe_service->ClearPrefs(); | 687 ui_nqe_service->ClearPrefs(); |
688 } | 688 } |
689 | 689 |
690 #if BUILDFLAG(ANDROID_JAVA_UI) | 690 #if defined(OS_ANDROID) |
691 // For now we're considering offline pages as cache, so if we're removing | 691 // For now we're considering offline pages as cache, so if we're removing |
692 // cache we should remove offline pages as well. | 692 // cache we should remove offline pages as well. |
693 if ((remove_mask & BrowsingDataRemover::REMOVE_CACHE)) { | 693 if ((remove_mask & BrowsingDataRemover::REMOVE_CACHE)) { |
694 clear_offline_page_data_.Start(); | 694 clear_offline_page_data_.Start(); |
695 offline_pages::OfflinePageModelFactory::GetForBrowserContext(profile_) | 695 offline_pages::OfflinePageModelFactory::GetForBrowserContext(profile_) |
696 ->DeleteCachedPagesByURLPredicate( | 696 ->DeleteCachedPagesByURLPredicate( |
697 filter, | 697 filter, |
698 IgnoreArgument<offline_pages::OfflinePageModel::DeletePageResult>( | 698 IgnoreArgument<offline_pages::OfflinePageModel::DeletePageResult>( |
699 clear_offline_page_data_.GetCompletionCallback())); | 699 clear_offline_page_data_.GetCompletionCallback())); |
700 } | 700 } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
766 clear_domain_reliability_monitor_.Start(); | 766 clear_domain_reliability_monitor_.Start(); |
767 service->ClearBrowsingData( | 767 service->ClearBrowsingData( |
768 mode, | 768 mode, |
769 filter, | 769 filter, |
770 clear_domain_reliability_monitor_.GetCompletionCallback()); | 770 clear_domain_reliability_monitor_.GetCompletionCallback()); |
771 } | 771 } |
772 } | 772 } |
773 | 773 |
774 ////////////////////////////////////////////////////////////////////////////// | 774 ////////////////////////////////////////////////////////////////////////////// |
775 // REMOVE_WEBAPP_DATA | 775 // REMOVE_WEBAPP_DATA |
776 #if BUILDFLAG(ANDROID_JAVA_UI) | 776 #if defined(OS_ANDROID) |
777 // Clear all data associated with registered webapps. | 777 // Clear all data associated with registered webapps. |
778 if (remove_mask & BrowsingDataRemover::REMOVE_WEBAPP_DATA) | 778 if (remove_mask & BrowsingDataRemover::REMOVE_WEBAPP_DATA) |
779 webapp_registry_->UnregisterWebappsForUrls(filter); | 779 webapp_registry_->UnregisterWebappsForUrls(filter); |
780 #endif | 780 #endif |
781 | 781 |
782 synchronous_clear_operations_.GetCompletionCallback().Run(); | 782 synchronous_clear_operations_.GetCompletionCallback().Run(); |
783 } | 783 } |
784 | 784 |
785 void ChromeBrowsingDataRemoverDelegate::NotifyIfDone() { | 785 void ChromeBrowsingDataRemoverDelegate::NotifyIfDone() { |
786 if (!AllDone()) | 786 if (!AllDone()) |
(...skipping 15 matching lines...) Expand all Loading... |
802 !clear_keyword_data_.is_pending() && | 802 !clear_keyword_data_.is_pending() && |
803 #if !defined(DISABLE_NACL) | 803 #if !defined(DISABLE_NACL) |
804 !clear_nacl_cache_.is_pending() && | 804 !clear_nacl_cache_.is_pending() && |
805 !clear_pnacl_cache_.is_pending() && | 805 !clear_pnacl_cache_.is_pending() && |
806 #endif | 806 #endif |
807 !clear_network_predictor_.is_pending() && | 807 !clear_network_predictor_.is_pending() && |
808 !clear_networking_history_.is_pending() && | 808 !clear_networking_history_.is_pending() && |
809 !clear_passwords_.is_pending() && | 809 !clear_passwords_.is_pending() && |
810 !clear_passwords_stats_.is_pending() && | 810 !clear_passwords_stats_.is_pending() && |
811 !clear_platform_keys_.is_pending() && | 811 !clear_platform_keys_.is_pending() && |
812 #if BUILDFLAG(ANDROID_JAVA_UI) | 812 #if defined(OS_ANDROID) |
813 !clear_precache_history_.is_pending() && | 813 !clear_precache_history_.is_pending() && |
814 !clear_offline_page_data_.is_pending() && | 814 !clear_offline_page_data_.is_pending() && |
815 #endif | 815 #endif |
816 #if BUILDFLAG(ENABLE_WEBRTC) | 816 #if BUILDFLAG(ENABLE_WEBRTC) |
817 !clear_webrtc_logs_.is_pending() && | 817 !clear_webrtc_logs_.is_pending() && |
818 #endif | 818 #endif |
819 !clear_auto_sign_in_.is_pending(); | 819 !clear_auto_sign_in_.is_pending(); |
820 } | 820 } |
821 | 821 |
822 #if BUILDFLAG(ANDROID_JAVA_UI) | 822 #if defined(OS_ANDROID) |
823 void ChromeBrowsingDataRemoverDelegate::OverrideWebappRegistryForTesting( | 823 void ChromeBrowsingDataRemoverDelegate::OverrideWebappRegistryForTesting( |
824 std::unique_ptr<WebappRegistry> webapp_registry) { | 824 std::unique_ptr<WebappRegistry> webapp_registry) { |
825 webapp_registry_ = std::move(webapp_registry); | 825 webapp_registry_ = std::move(webapp_registry); |
826 } | 826 } |
827 #endif | 827 #endif |
828 | 828 |
829 void ChromeBrowsingDataRemoverDelegate::OnKeywordsLoaded( | 829 void ChromeBrowsingDataRemoverDelegate::OnKeywordsLoaded( |
830 base::Callback<bool(const GURL&)> url_filter) { | 830 base::Callback<bool(const GURL&)> url_filter) { |
831 // Deletes the entries from the model. | 831 // Deletes the entries from the model. |
832 TemplateURLService* model = | 832 TemplateURLService* model = |
(...skipping 24 matching lines...) Expand all Loading... |
857 | 857 |
858 #if defined(OS_CHROMEOS) | 858 #if defined(OS_CHROMEOS) |
859 void ChromeBrowsingDataRemoverDelegate::OnClearPlatformKeys( | 859 void ChromeBrowsingDataRemoverDelegate::OnClearPlatformKeys( |
860 chromeos::DBusMethodCallStatus call_status, | 860 chromeos::DBusMethodCallStatus call_status, |
861 bool result) { | 861 bool result) { |
862 LOG_IF(ERROR, call_status != chromeos::DBUS_METHOD_CALL_SUCCESS || !result) | 862 LOG_IF(ERROR, call_status != chromeos::DBUS_METHOD_CALL_SUCCESS || !result) |
863 << "Failed to clear platform keys."; | 863 << "Failed to clear platform keys."; |
864 clear_platform_keys_.GetCompletionCallback().Run(); | 864 clear_platform_keys_.GetCompletionCallback().Run(); |
865 } | 865 } |
866 #endif | 866 #endif |
OLD | NEW |