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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 #include "components/password_manager/core/browser/password_store.h" | 62 #include "components/password_manager/core/browser/password_store.h" |
63 #include "components/prefs/pref_service.h" | 63 #include "components/prefs/pref_service.h" |
64 #include "components/previews/core/previews_ui_service.h" | 64 #include "components/previews/core/previews_ui_service.h" |
65 #include "components/search_engines/template_url_service.h" | 65 #include "components/search_engines/template_url_service.h" |
66 #include "components/sessions/core/tab_restore_service.h" | 66 #include "components/sessions/core/tab_restore_service.h" |
67 #include "content/public/browser/user_metrics.h" | 67 #include "content/public/browser/user_metrics.h" |
68 #include "net/cookies/cookie_store.h" | 68 #include "net/cookies/cookie_store.h" |
69 #include "net/url_request/url_request_context.h" | 69 #include "net/url_request/url_request_context.h" |
70 #include "net/url_request/url_request_context_getter.h" | 70 #include "net/url_request/url_request_context_getter.h" |
71 | 71 |
72 #if BUILDFLAG(ANDROID_JAVA_UI) | 72 #if defined(OS_ANDROID) |
73 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" | 73 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" |
74 #include "chrome/browser/android/webapps/webapp_registry.h" | 74 #include "chrome/browser/android/webapps/webapp_registry.h" |
75 #include "chrome/browser/precache/precache_manager_factory.h" | 75 #include "chrome/browser/precache/precache_manager_factory.h" |
76 #include "components/offline_pages/core/offline_page_feature.h" | 76 #include "components/offline_pages/core/offline_page_feature.h" |
77 #include "components/offline_pages/core/offline_page_model.h" | 77 #include "components/offline_pages/core/offline_page_model.h" |
78 #include "components/precache/content/precache_manager.h" | 78 #include "components/precache/content/precache_manager.h" |
79 #endif | 79 #endif |
80 | 80 |
81 #if BUILDFLAG(ENABLE_EXTENSIONS) | 81 #if BUILDFLAG(ENABLE_EXTENSIONS) |
82 #include "chrome/browser/extensions/activity_log/activity_log.h" | 82 #include "chrome/browser/extensions/activity_log/activity_log.h" |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 #if !defined(DISABLE_NACL) | 254 #if !defined(DISABLE_NACL) |
255 clear_nacl_cache_(sub_task_forward_callback_), | 255 clear_nacl_cache_(sub_task_forward_callback_), |
256 clear_pnacl_cache_(sub_task_forward_callback_), | 256 clear_pnacl_cache_(sub_task_forward_callback_), |
257 #endif | 257 #endif |
258 clear_hostname_resolution_cache_(sub_task_forward_callback_), | 258 clear_hostname_resolution_cache_(sub_task_forward_callback_), |
259 clear_network_predictor_(sub_task_forward_callback_), | 259 clear_network_predictor_(sub_task_forward_callback_), |
260 clear_networking_history_(sub_task_forward_callback_), | 260 clear_networking_history_(sub_task_forward_callback_), |
261 clear_passwords_(sub_task_forward_callback_), | 261 clear_passwords_(sub_task_forward_callback_), |
262 clear_passwords_stats_(sub_task_forward_callback_), | 262 clear_passwords_stats_(sub_task_forward_callback_), |
263 clear_platform_keys_(sub_task_forward_callback_), | 263 clear_platform_keys_(sub_task_forward_callback_), |
264 #if BUILDFLAG(ANDROID_JAVA_UI) | 264 #if defined(OS_ANDROID) |
265 clear_precache_history_(sub_task_forward_callback_), | 265 clear_precache_history_(sub_task_forward_callback_), |
266 clear_offline_page_data_(sub_task_forward_callback_), | 266 clear_offline_page_data_(sub_task_forward_callback_), |
267 #endif | 267 #endif |
268 #if BUILDFLAG(ENABLE_WEBRTC) | 268 #if BUILDFLAG(ENABLE_WEBRTC) |
269 clear_webrtc_logs_(sub_task_forward_callback_), | 269 clear_webrtc_logs_(sub_task_forward_callback_), |
270 #endif | 270 #endif |
271 clear_auto_sign_in_(sub_task_forward_callback_), | 271 clear_auto_sign_in_(sub_task_forward_callback_), |
272 #if BUILDFLAG(ANDROID_JAVA_UI) | 272 #if defined(OS_ANDROID) |
273 webapp_registry_(new WebappRegistry()), | 273 webapp_registry_(new WebappRegistry()), |
274 #endif | 274 #endif |
275 weak_ptr_factory_(this) {} | 275 weak_ptr_factory_(this) {} |
276 | 276 |
277 ChromeBrowsingDataRemoverDelegate::~ChromeBrowsingDataRemoverDelegate() { | 277 ChromeBrowsingDataRemoverDelegate::~ChromeBrowsingDataRemoverDelegate() { |
278 history_task_tracker_.TryCancelAll(); | 278 history_task_tracker_.TryCancelAll(); |
279 template_url_sub_.reset(); | 279 template_url_sub_.reset(); |
280 } | 280 } |
281 | 281 |
282 void ChromeBrowsingDataRemoverDelegate::RemoveEmbedderData( | 282 void ChromeBrowsingDataRemoverDelegate::RemoveEmbedderData( |
283 const base::Time& delete_begin, | 283 const base::Time& delete_begin, |
284 const base::Time& delete_end, | 284 const base::Time& delete_end, |
285 int remove_mask, | 285 int remove_mask, |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 clear_webrtc_logs_.Start(); | 467 clear_webrtc_logs_.Start(); |
468 BrowserThread::PostTaskAndReply( | 468 BrowserThread::PostTaskAndReply( |
469 BrowserThread::FILE, FROM_HERE, | 469 BrowserThread::FILE, FROM_HERE, |
470 base::Bind( | 470 base::Bind( |
471 &WebRtcLogUtil::DeleteOldAndRecentWebRtcLogFiles, | 471 &WebRtcLogUtil::DeleteOldAndRecentWebRtcLogFiles, |
472 WebRtcLogList::GetWebRtcLogDirectoryForProfile(profile_->GetPath()), | 472 WebRtcLogList::GetWebRtcLogDirectoryForProfile(profile_->GetPath()), |
473 delete_begin_), | 473 delete_begin_), |
474 clear_webrtc_logs_.GetCompletionCallback()); | 474 clear_webrtc_logs_.GetCompletionCallback()); |
475 #endif | 475 #endif |
476 | 476 |
477 #if BUILDFLAG(ANDROID_JAVA_UI) | 477 #if defined(OS_ANDROID) |
478 precache::PrecacheManager* precache_manager = | 478 precache::PrecacheManager* precache_manager = |
479 precache::PrecacheManagerFactory::GetForBrowserContext(profile_); | 479 precache::PrecacheManagerFactory::GetForBrowserContext(profile_); |
480 // |precache_manager| could be nullptr if the profile is off the record. | 480 // |precache_manager| could be nullptr if the profile is off the record. |
481 if (!precache_manager) { | 481 if (!precache_manager) { |
482 clear_precache_history_.Start(); | 482 clear_precache_history_.Start(); |
483 precache_manager->ClearHistory(); | 483 precache_manager->ClearHistory(); |
484 // The above calls are done on the UI thread but do their work on the DB | 484 // The above calls are done on the UI thread but do their work on the DB |
485 // thread. So wait for it. | 485 // thread. So wait for it. |
486 BrowserThread::PostTaskAndReply( | 486 BrowserThread::PostTaskAndReply( |
487 BrowserThread::DB, FROM_HERE, base::Bind(&base::DoNothing), | 487 BrowserThread::DB, FROM_HERE, base::Bind(&base::DoNothing), |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
722 Profile::ProfileType::REGULAR_PROFILE || | 722 Profile::ProfileType::REGULAR_PROFILE || |
723 ui_nqe_service != nullptr); | 723 ui_nqe_service != nullptr); |
724 if (ui_nqe_service) { | 724 if (ui_nqe_service) { |
725 // Network Quality Estimator (NQE) stores the quality (RTT, bandwidth | 725 // Network Quality Estimator (NQE) stores the quality (RTT, bandwidth |
726 // etc.) of different networks in prefs. The stored quality is not | 726 // etc.) of different networks in prefs. The stored quality is not |
727 // broken down by URLs or timestamps, so clearing the cache should | 727 // broken down by URLs or timestamps, so clearing the cache should |
728 // completely clear the prefs. | 728 // completely clear the prefs. |
729 ui_nqe_service->ClearPrefs(); | 729 ui_nqe_service->ClearPrefs(); |
730 } | 730 } |
731 | 731 |
732 #if BUILDFLAG(ANDROID_JAVA_UI) | 732 #if defined(OS_ANDROID) |
733 // For now we're considering offline pages as cache, so if we're removing | 733 // For now we're considering offline pages as cache, so if we're removing |
734 // cache we should remove offline pages as well. | 734 // cache we should remove offline pages as well. |
735 if ((remove_mask & BrowsingDataRemover::REMOVE_CACHE)) { | 735 if ((remove_mask & BrowsingDataRemover::REMOVE_CACHE)) { |
736 clear_offline_page_data_.Start(); | 736 clear_offline_page_data_.Start(); |
737 offline_pages::OfflinePageModelFactory::GetForBrowserContext(profile_) | 737 offline_pages::OfflinePageModelFactory::GetForBrowserContext(profile_) |
738 ->DeleteCachedPagesByURLPredicate( | 738 ->DeleteCachedPagesByURLPredicate( |
739 filter, | 739 filter, |
740 IgnoreArgument<offline_pages::OfflinePageModel::DeletePageResult>( | 740 IgnoreArgument<offline_pages::OfflinePageModel::DeletePageResult>( |
741 clear_offline_page_data_.GetCompletionCallback())); | 741 clear_offline_page_data_.GetCompletionCallback())); |
742 } | 742 } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
808 clear_domain_reliability_monitor_.Start(); | 808 clear_domain_reliability_monitor_.Start(); |
809 service->ClearBrowsingData( | 809 service->ClearBrowsingData( |
810 mode, | 810 mode, |
811 filter, | 811 filter, |
812 clear_domain_reliability_monitor_.GetCompletionCallback()); | 812 clear_domain_reliability_monitor_.GetCompletionCallback()); |
813 } | 813 } |
814 } | 814 } |
815 | 815 |
816 ////////////////////////////////////////////////////////////////////////////// | 816 ////////////////////////////////////////////////////////////////////////////// |
817 // REMOVE_WEBAPP_DATA | 817 // REMOVE_WEBAPP_DATA |
818 #if BUILDFLAG(ANDROID_JAVA_UI) | 818 #if defined(OS_ANDROID) |
819 // Clear all data associated with registered webapps. | 819 // Clear all data associated with registered webapps. |
820 if (remove_mask & BrowsingDataRemover::REMOVE_WEBAPP_DATA) | 820 if (remove_mask & BrowsingDataRemover::REMOVE_WEBAPP_DATA) |
821 webapp_registry_->UnregisterWebappsForUrls(filter); | 821 webapp_registry_->UnregisterWebappsForUrls(filter); |
822 #endif | 822 #endif |
823 | 823 |
824 synchronous_clear_operations_.GetCompletionCallback().Run(); | 824 synchronous_clear_operations_.GetCompletionCallback().Run(); |
825 } | 825 } |
826 | 826 |
827 void ChromeBrowsingDataRemoverDelegate::NotifyIfDone() { | 827 void ChromeBrowsingDataRemoverDelegate::NotifyIfDone() { |
828 if (!AllDone()) | 828 if (!AllDone()) |
829 return; | 829 return; |
830 | 830 |
831 DCHECK(!callback_.is_null()); | 831 DCHECK(!callback_.is_null()); |
832 callback_.Run(); | 832 callback_.Run(); |
833 } | 833 } |
834 | 834 |
835 bool ChromeBrowsingDataRemoverDelegate::AllDone() { | 835 bool ChromeBrowsingDataRemoverDelegate::AllDone() { |
836 return !clear_cookies_count_ && | 836 return !clear_cookies_count_ && !synchronous_clear_operations_.is_pending() && |
837 !synchronous_clear_operations_.is_pending() && | |
838 !clear_autofill_origin_urls_.is_pending() && | 837 !clear_autofill_origin_urls_.is_pending() && |
839 !clear_flash_content_licenses_.is_pending() && | 838 !clear_flash_content_licenses_.is_pending() && |
840 !clear_domain_reliability_monitor_.is_pending() && | 839 !clear_domain_reliability_monitor_.is_pending() && |
841 !clear_form_.is_pending() && | 840 !clear_form_.is_pending() && !clear_history_.is_pending() && |
842 !clear_history_.is_pending() && | |
843 !clear_hostname_resolution_cache_.is_pending() && | 841 !clear_hostname_resolution_cache_.is_pending() && |
844 !clear_keyword_data_.is_pending() && | 842 !clear_keyword_data_.is_pending() && |
845 #if !defined(DISABLE_NACL) | 843 #if !defined(DISABLE_NACL) |
846 !clear_nacl_cache_.is_pending() && | 844 !clear_nacl_cache_.is_pending() && !clear_pnacl_cache_.is_pending() && |
847 !clear_pnacl_cache_.is_pending() && | |
848 #endif | 845 #endif |
849 !clear_network_predictor_.is_pending() && | 846 !clear_network_predictor_.is_pending() && |
850 !clear_networking_history_.is_pending() && | 847 !clear_networking_history_.is_pending() && |
851 !clear_passwords_.is_pending() && | 848 !clear_passwords_.is_pending() && |
852 !clear_passwords_stats_.is_pending() && | 849 !clear_passwords_stats_.is_pending() && |
853 !clear_platform_keys_.is_pending() && | 850 !clear_platform_keys_.is_pending() && |
854 #if BUILDFLAG(ANDROID_JAVA_UI) | 851 #if defined(OS_ANDROID) |
855 !clear_precache_history_.is_pending() && | 852 !clear_precache_history_.is_pending() && |
856 !clear_offline_page_data_.is_pending() && | 853 !clear_offline_page_data_.is_pending() && |
857 #endif | 854 #endif |
858 #if BUILDFLAG(ENABLE_WEBRTC) | 855 #if BUILDFLAG(ENABLE_WEBRTC) |
859 !clear_webrtc_logs_.is_pending() && | 856 !clear_webrtc_logs_.is_pending() && |
860 #endif | 857 #endif |
861 !clear_auto_sign_in_.is_pending(); | 858 !clear_auto_sign_in_.is_pending(); |
862 } | 859 } |
863 | 860 |
864 #if BUILDFLAG(ANDROID_JAVA_UI) | 861 #if defined(OS_ANDROID) |
865 void ChromeBrowsingDataRemoverDelegate::OverrideWebappRegistryForTesting( | 862 void ChromeBrowsingDataRemoverDelegate::OverrideWebappRegistryForTesting( |
866 std::unique_ptr<WebappRegistry> webapp_registry) { | 863 std::unique_ptr<WebappRegistry> webapp_registry) { |
867 webapp_registry_ = std::move(webapp_registry); | 864 webapp_registry_ = std::move(webapp_registry); |
868 } | 865 } |
869 #endif | 866 #endif |
870 | 867 |
871 void ChromeBrowsingDataRemoverDelegate::OnKeywordsLoaded( | 868 void ChromeBrowsingDataRemoverDelegate::OnKeywordsLoaded( |
872 base::Callback<bool(const GURL&)> url_filter) { | 869 base::Callback<bool(const GURL&)> url_filter) { |
873 // Deletes the entries from the model. | 870 // Deletes the entries from the model. |
874 TemplateURLService* model = | 871 TemplateURLService* model = |
(...skipping 24 matching lines...) Expand all Loading... |
899 | 896 |
900 #if defined(OS_CHROMEOS) | 897 #if defined(OS_CHROMEOS) |
901 void ChromeBrowsingDataRemoverDelegate::OnClearPlatformKeys( | 898 void ChromeBrowsingDataRemoverDelegate::OnClearPlatformKeys( |
902 chromeos::DBusMethodCallStatus call_status, | 899 chromeos::DBusMethodCallStatus call_status, |
903 bool result) { | 900 bool result) { |
904 LOG_IF(ERROR, call_status != chromeos::DBUS_METHOD_CALL_SUCCESS || !result) | 901 LOG_IF(ERROR, call_status != chromeos::DBUS_METHOD_CALL_SUCCESS || !result) |
905 << "Failed to clear platform keys."; | 902 << "Failed to clear platform keys."; |
906 clear_platform_keys_.GetCompletionCallback().Run(); | 903 clear_platform_keys_.GetCompletionCallback().Run(); |
907 } | 904 } |
908 #endif | 905 #endif |
OLD | NEW |