| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 #include "components/nacl/browser/nacl_browser.h" | 57 #include "components/nacl/browser/nacl_browser.h" |
| 58 #include "components/nacl/browser/pnacl_host.h" | 58 #include "components/nacl/browser/pnacl_host.h" |
| 59 #include "components/ntp_snippets/bookmarks/bookmark_last_visit_utils.h" | 59 #include "components/ntp_snippets/bookmarks/bookmark_last_visit_utils.h" |
| 60 #include "components/ntp_snippets/content_suggestions_service.h" | 60 #include "components/ntp_snippets/content_suggestions_service.h" |
| 61 #include "components/omnibox/browser/omnibox_pref_names.h" | 61 #include "components/omnibox/browser/omnibox_pref_names.h" |
| 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/plugin_data_remover.h" |
| 67 #include "content/public/browser/ssl_host_state_delegate.h" | 68 #include "content/public/browser/ssl_host_state_delegate.h" |
| 68 #include "content/public/browser/storage_partition.h" | 69 #include "content/public/browser/storage_partition.h" |
| 69 #include "content/public/browser/user_metrics.h" | 70 #include "content/public/browser/user_metrics.h" |
| 70 #include "net/cookies/cookie_store.h" | 71 #include "net/cookies/cookie_store.h" |
| 71 #include "net/http/http_transaction_factory.h" | 72 #include "net/http/http_transaction_factory.h" |
| 72 #include "net/url_request/url_request_context.h" | 73 #include "net/url_request/url_request_context.h" |
| 73 #include "net/url_request/url_request_context_getter.h" | 74 #include "net/url_request/url_request_context_getter.h" |
| 74 | 75 |
| 75 #if defined(OS_ANDROID) | 76 #if defined(OS_ANDROID) |
| 76 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" | 77 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 98 #include "chromeos/dbus/cryptohome_client.h" | 99 #include "chromeos/dbus/cryptohome_client.h" |
| 99 #include "chromeos/dbus/dbus_thread_manager.h" | 100 #include "chromeos/dbus/dbus_thread_manager.h" |
| 100 #include "components/user_manager/user.h" | 101 #include "components/user_manager/user.h" |
| 101 #endif | 102 #endif |
| 102 | 103 |
| 103 #if BUILDFLAG(ENABLE_WEBRTC) | 104 #if BUILDFLAG(ENABLE_WEBRTC) |
| 104 #include "chrome/browser/media/webrtc/webrtc_log_list.h" | 105 #include "chrome/browser/media/webrtc/webrtc_log_list.h" |
| 105 #include "chrome/browser/media/webrtc/webrtc_log_util.h" | 106 #include "chrome/browser/media/webrtc/webrtc_log_util.h" |
| 106 #endif | 107 #endif |
| 107 | 108 |
| 109 #if BUILDFLAG(ENABLE_PLUGINS) |
| 110 #include "chrome/browser/browsing_data/browsing_data_flash_lso_helper.h" |
| 111 #endif |
| 112 |
| 108 using base::UserMetricsAction; | 113 using base::UserMetricsAction; |
| 109 using content::BrowserContext; | 114 using content::BrowserContext; |
| 110 using content::BrowserThread; | 115 using content::BrowserThread; |
| 111 | 116 |
| 112 namespace { | 117 namespace { |
| 113 | 118 |
| 114 void UIThreadTrampolineHelper(const base::Closure& callback) { | 119 void UIThreadTrampolineHelper(const base::Closure& callback) { |
| 115 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback); | 120 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback); |
| 116 } | 121 } |
| 117 | 122 |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 clear_http_auth_cache_(sub_task_forward_callback_), | 285 clear_http_auth_cache_(sub_task_forward_callback_), |
| 281 clear_platform_keys_(sub_task_forward_callback_), | 286 clear_platform_keys_(sub_task_forward_callback_), |
| 282 #if defined(OS_ANDROID) | 287 #if defined(OS_ANDROID) |
| 283 clear_precache_history_(sub_task_forward_callback_), | 288 clear_precache_history_(sub_task_forward_callback_), |
| 284 clear_offline_page_data_(sub_task_forward_callback_), | 289 clear_offline_page_data_(sub_task_forward_callback_), |
| 285 #endif | 290 #endif |
| 286 #if BUILDFLAG(ENABLE_WEBRTC) | 291 #if BUILDFLAG(ENABLE_WEBRTC) |
| 287 clear_webrtc_logs_(sub_task_forward_callback_), | 292 clear_webrtc_logs_(sub_task_forward_callback_), |
| 288 #endif | 293 #endif |
| 289 clear_auto_sign_in_(sub_task_forward_callback_), | 294 clear_auto_sign_in_(sub_task_forward_callback_), |
| 295 #if BUILDFLAG(ENABLE_PLUGINS) |
| 296 flash_lso_helper_(BrowsingDataFlashLSOHelper::Create(browser_context)), |
| 297 #endif |
| 290 #if defined(OS_ANDROID) | 298 #if defined(OS_ANDROID) |
| 291 webapp_registry_(new WebappRegistry()), | 299 webapp_registry_(new WebappRegistry()), |
| 292 #endif | 300 #endif |
| 293 weak_ptr_factory_(this) {} | 301 weak_ptr_factory_(this) {} |
| 294 | 302 |
| 295 ChromeBrowsingDataRemoverDelegate::~ChromeBrowsingDataRemoverDelegate() { | 303 ChromeBrowsingDataRemoverDelegate::~ChromeBrowsingDataRemoverDelegate() { |
| 296 history_task_tracker_.TryCancelAll(); | 304 history_task_tracker_.TryCancelAll(); |
| 297 template_url_sub_.reset(); | 305 template_url_sub_.reset(); |
| 298 } | 306 } |
| 299 | 307 |
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 784 offline_pages::OfflinePageModelFactory::GetForBrowserContext(profile_) | 792 offline_pages::OfflinePageModelFactory::GetForBrowserContext(profile_) |
| 785 ->DeleteCachedPagesByURLPredicate( | 793 ->DeleteCachedPagesByURLPredicate( |
| 786 filter, | 794 filter, |
| 787 IgnoreArgument<offline_pages::OfflinePageModel::DeletePageResult>( | 795 IgnoreArgument<offline_pages::OfflinePageModel::DeletePageResult>( |
| 788 clear_offline_page_data_.GetCompletionCallback())); | 796 clear_offline_page_data_.GetCompletionCallback())); |
| 789 } | 797 } |
| 790 #endif | 798 #endif |
| 791 } | 799 } |
| 792 | 800 |
| 793 ////////////////////////////////////////////////////////////////////////////// | 801 ////////////////////////////////////////////////////////////////////////////// |
| 802 // REMOVE_PLUGINS |
| 803 // Plugins are known to //content and their bulk deletion is implemented in |
| 804 // PluginDataRemover. However, the filtered deletion uses |
| 805 // BrowsingDataFlashLSOHelper which (currently) has strong dependencies |
| 806 // on //chrome. |
| 807 // TODO(msramek): Investigate these dependencies and move the plugin deletion |
| 808 // to BrowsingDataRemoverImpl in //content. Note that code in //content |
| 809 // can simply take advantage of PluginDataRemover directly to delete plugin |
| 810 // data in bulk. |
| 811 #if BUILDFLAG(ENABLE_PLUGINS) |
| 812 // Plugin is data not separated for protected and unprotected web origins. We |
| 813 // check the origin_type_mask_ to prevent unintended deletion. |
| 814 if (remove_mask & BrowsingDataRemover::REMOVE_PLUGIN_DATA && |
| 815 origin_type_mask & BrowsingDataHelper::UNPROTECTED_WEB) { |
| 816 content::RecordAction(UserMetricsAction("ClearBrowsingData_LSOData")); |
| 817 clear_plugin_data_count_ = 1; |
| 818 |
| 819 if (filter_builder.IsEmptyBlacklist()) { |
| 820 DCHECK(!plugin_data_remover_); |
| 821 plugin_data_remover_.reset( |
| 822 content::PluginDataRemover::Create(profile_)); |
| 823 base::WaitableEvent* event = |
| 824 plugin_data_remover_->StartRemoving(delete_begin_); |
| 825 |
| 826 base::WaitableEventWatcher::EventCallback watcher_callback = base::Bind( |
| 827 &ChromeBrowsingDataRemoverDelegate::OnWaitableEventSignaled, |
| 828 weak_ptr_factory_.GetWeakPtr()); |
| 829 watcher_.StartWatching(event, watcher_callback); |
| 830 } else { |
| 831 // TODO(msramek): Store filters from the currently executed task on the |
| 832 // object to avoid having to copy them to callback methods. |
| 833 flash_lso_helper_->StartFetching(base::Bind( |
| 834 &ChromeBrowsingDataRemoverDelegate::OnSitesWithFlashDataFetched, |
| 835 weak_ptr_factory_.GetWeakPtr(), |
| 836 filter_builder.BuildPluginFilter())); |
| 837 } |
| 838 } |
| 839 #endif |
| 840 |
| 841 ////////////////////////////////////////////////////////////////////////////// |
| 794 // REMOVE_MEDIA_LICENSES | 842 // REMOVE_MEDIA_LICENSES |
| 795 if (remove_mask & BrowsingDataRemover::REMOVE_MEDIA_LICENSES) { | 843 if (remove_mask & BrowsingDataRemover::REMOVE_MEDIA_LICENSES) { |
| 796 // TODO(jrummell): This UMA should be renamed to indicate it is for Media | 844 // TODO(jrummell): This UMA should be renamed to indicate it is for Media |
| 797 // Licenses. | 845 // Licenses. |
| 798 content::RecordAction( | 846 content::RecordAction( |
| 799 UserMetricsAction("ClearBrowsingData_ContentLicenses")); | 847 UserMetricsAction("ClearBrowsingData_ContentLicenses")); |
| 800 | 848 |
| 801 #if BUILDFLAG(ENABLE_PLUGINS) | 849 #if BUILDFLAG(ENABLE_PLUGINS) |
| 802 clear_flash_content_licenses_.Start(); | 850 clear_flash_content_licenses_.Start(); |
| 803 if (!pepper_flash_settings_manager_.get()) { | 851 if (!pepper_flash_settings_manager_.get()) { |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 896 !clear_passwords_stats_.is_pending() && | 944 !clear_passwords_stats_.is_pending() && |
| 897 !clear_http_auth_cache_.is_pending() && | 945 !clear_http_auth_cache_.is_pending() && |
| 898 !clear_platform_keys_.is_pending() && | 946 !clear_platform_keys_.is_pending() && |
| 899 #if defined(OS_ANDROID) | 947 #if defined(OS_ANDROID) |
| 900 !clear_precache_history_.is_pending() && | 948 !clear_precache_history_.is_pending() && |
| 901 !clear_offline_page_data_.is_pending() && | 949 !clear_offline_page_data_.is_pending() && |
| 902 #endif | 950 #endif |
| 903 #if BUILDFLAG(ENABLE_WEBRTC) | 951 #if BUILDFLAG(ENABLE_WEBRTC) |
| 904 !clear_webrtc_logs_.is_pending() && | 952 !clear_webrtc_logs_.is_pending() && |
| 905 #endif | 953 #endif |
| 906 !clear_auto_sign_in_.is_pending(); | 954 !clear_auto_sign_in_.is_pending() && |
| 955 !clear_plugin_data_count_; |
| 907 } | 956 } |
| 908 | 957 |
| 909 #if defined(OS_ANDROID) | 958 #if defined(OS_ANDROID) |
| 910 void ChromeBrowsingDataRemoverDelegate::OverrideWebappRegistryForTesting( | 959 void ChromeBrowsingDataRemoverDelegate::OverrideWebappRegistryForTesting( |
| 911 std::unique_ptr<WebappRegistry> webapp_registry) { | 960 std::unique_ptr<WebappRegistry> webapp_registry) { |
| 912 webapp_registry_ = std::move(webapp_registry); | 961 webapp_registry_ = std::move(webapp_registry); |
| 913 } | 962 } |
| 914 #endif | 963 #endif |
| 915 | 964 |
| 965 #if BUILDFLAG(ENABLE_PLUGINS) |
| 966 void ChromeBrowsingDataRemoverDelegate::OverrideFlashLSOHelperForTesting( |
| 967 scoped_refptr<BrowsingDataFlashLSOHelper> flash_lso_helper) { |
| 968 flash_lso_helper_ = flash_lso_helper; |
| 969 } |
| 970 #endif |
| 971 |
| 916 void ChromeBrowsingDataRemoverDelegate::OnKeywordsLoaded( | 972 void ChromeBrowsingDataRemoverDelegate::OnKeywordsLoaded( |
| 917 base::Callback<bool(const GURL&)> url_filter) { | 973 base::Callback<bool(const GURL&)> url_filter) { |
| 918 // Deletes the entries from the model. | 974 // Deletes the entries from the model. |
| 919 TemplateURLService* model = | 975 TemplateURLService* model = |
| 920 TemplateURLServiceFactory::GetForProfile(profile_); | 976 TemplateURLServiceFactory::GetForProfile(profile_); |
| 921 model->RemoveAutoGeneratedForUrlsBetween(url_filter, delete_begin_, | 977 model->RemoveAutoGeneratedForUrlsBetween(url_filter, delete_begin_, |
| 922 delete_end_); | 978 delete_end_); |
| 923 template_url_sub_.reset(); | 979 template_url_sub_.reset(); |
| 924 clear_keyword_data_.GetCompletionCallback().Run(); | 980 clear_keyword_data_.GetCompletionCallback().Run(); |
| 925 } | 981 } |
| 926 | 982 |
| 927 void ChromeBrowsingDataRemoverDelegate::OnClearedCookies() { | 983 void ChromeBrowsingDataRemoverDelegate::OnClearedCookies() { |
| 928 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 984 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 929 | 985 |
| 930 DCHECK_GT(clear_cookies_count_, 0); | 986 DCHECK_GT(clear_cookies_count_, 0); |
| 931 --clear_cookies_count_; | 987 --clear_cookies_count_; |
| 932 NotifyIfDone(); | 988 NotifyIfDone(); |
| 933 } | 989 } |
| 934 | 990 |
| 935 #if BUILDFLAG(ENABLE_PLUGINS) | |
| 936 void ChromeBrowsingDataRemoverDelegate:: | |
| 937 OnDeauthorizeFlashContentLicensesCompleted( | |
| 938 uint32_t request_id, | |
| 939 bool /* success */) { | |
| 940 DCHECK_EQ(request_id, deauthorize_flash_content_licenses_request_id_); | |
| 941 clear_flash_content_licenses_.GetCompletionCallback().Run(); | |
| 942 } | |
| 943 #endif | |
| 944 | |
| 945 #if defined(OS_CHROMEOS) | 991 #if defined(OS_CHROMEOS) |
| 946 void ChromeBrowsingDataRemoverDelegate::OnClearPlatformKeys( | 992 void ChromeBrowsingDataRemoverDelegate::OnClearPlatformKeys( |
| 947 chromeos::DBusMethodCallStatus call_status, | 993 chromeos::DBusMethodCallStatus call_status, |
| 948 bool result) { | 994 bool result) { |
| 949 LOG_IF(ERROR, call_status != chromeos::DBUS_METHOD_CALL_SUCCESS || !result) | 995 LOG_IF(ERROR, call_status != chromeos::DBUS_METHOD_CALL_SUCCESS || !result) |
| 950 << "Failed to clear platform keys."; | 996 << "Failed to clear platform keys."; |
| 951 clear_platform_keys_.GetCompletionCallback().Run(); | 997 clear_platform_keys_.GetCompletionCallback().Run(); |
| 952 } | 998 } |
| 953 #endif | 999 #endif |
| 1000 |
| 1001 #if BUILDFLAG(ENABLE_PLUGINS) |
| 1002 void ChromeBrowsingDataRemoverDelegate::OnWaitableEventSignaled( |
| 1003 base::WaitableEvent* waitable_event) { |
| 1004 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1005 |
| 1006 DCHECK_EQ(1, clear_plugin_data_count_); |
| 1007 clear_plugin_data_count_ = 0; |
| 1008 |
| 1009 plugin_data_remover_.reset(); |
| 1010 watcher_.StopWatching(); |
| 1011 NotifyIfDone(); |
| 1012 } |
| 1013 |
| 1014 void ChromeBrowsingDataRemoverDelegate::OnSitesWithFlashDataFetched( |
| 1015 base::Callback<bool(const std::string&)> plugin_filter, |
| 1016 const std::vector<std::string>& sites) { |
| 1017 DCHECK_EQ(1, clear_plugin_data_count_); |
| 1018 clear_plugin_data_count_ = 0; |
| 1019 |
| 1020 std::vector<std::string> sites_to_delete; |
| 1021 for (const std::string& site : sites) { |
| 1022 if (plugin_filter.Run(site)) |
| 1023 sites_to_delete.push_back(site); |
| 1024 } |
| 1025 |
| 1026 clear_plugin_data_count_ = sites_to_delete.size(); |
| 1027 |
| 1028 for (const std::string& site : sites_to_delete) { |
| 1029 flash_lso_helper_->DeleteFlashLSOsForSite( |
| 1030 site, |
| 1031 base::Bind(&ChromeBrowsingDataRemoverDelegate::OnFlashDataDeleted, |
| 1032 weak_ptr_factory_.GetWeakPtr())); |
| 1033 } |
| 1034 |
| 1035 NotifyIfDone(); |
| 1036 } |
| 1037 |
| 1038 void ChromeBrowsingDataRemoverDelegate::OnFlashDataDeleted() { |
| 1039 clear_plugin_data_count_--; |
| 1040 NotifyIfDone(); |
| 1041 } |
| 1042 |
| 1043 void ChromeBrowsingDataRemoverDelegate:: |
| 1044 OnDeauthorizeFlashContentLicensesCompleted( |
| 1045 uint32_t request_id, |
| 1046 bool /* success */) { |
| 1047 DCHECK_EQ(request_id, deauthorize_flash_content_licenses_request_id_); |
| 1048 clear_flash_content_licenses_.GetCompletionCallback().Run(); |
| 1049 } |
| 1050 #endif |
| OLD | NEW |