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 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 #include "components/web_cache/browser/web_cache_manager.h" | 65 #include "components/web_cache/browser/web_cache_manager.h" |
66 #include "content/public/browser/browser_thread.h" | 66 #include "content/public/browser/browser_thread.h" |
67 #include "content/public/browser/download_manager.h" | 67 #include "content/public/browser/download_manager.h" |
68 #include "content/public/browser/notification_service.h" | 68 #include "content/public/browser/notification_service.h" |
69 #include "content/public/browser/plugin_data_remover.h" | 69 #include "content/public/browser/plugin_data_remover.h" |
70 #include "content/public/browser/ssl_host_state_delegate.h" | 70 #include "content/public/browser/ssl_host_state_delegate.h" |
71 #include "content/public/browser/storage_partition.h" | 71 #include "content/public/browser/storage_partition.h" |
72 #include "content/public/browser/user_metrics.h" | 72 #include "content/public/browser/user_metrics.h" |
73 #include "net/base/net_errors.h" | 73 #include "net/base/net_errors.h" |
74 #include "net/cookies/cookie_store.h" | 74 #include "net/cookies/cookie_store.h" |
| 75 #include "net/http/http_network_session.h" |
| 76 #include "net/http/http_transaction_factory.h" |
75 #include "net/http/transport_security_state.h" | 77 #include "net/http/transport_security_state.h" |
76 #include "net/ssl/channel_id_service.h" | 78 #include "net/ssl/channel_id_service.h" |
77 #include "net/ssl/channel_id_store.h" | 79 #include "net/ssl/channel_id_store.h" |
78 #include "net/url_request/url_request_context.h" | 80 #include "net/url_request/url_request_context.h" |
79 #include "net/url_request/url_request_context_getter.h" | 81 #include "net/url_request/url_request_context_getter.h" |
80 #include "storage/browser/quota/special_storage_policy.h" | 82 #include "storage/browser/quota/special_storage_policy.h" |
81 #include "url/origin.h" | 83 #include "url/origin.h" |
82 | 84 |
83 #if BUILDFLAG(ANDROID_JAVA_UI) | 85 #if BUILDFLAG(ANDROID_JAVA_UI) |
84 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" | 86 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 const ContentSettingsPattern& secondary_pattern) { | 178 const ContentSettingsPattern& secondary_pattern) { |
177 return predicate.Run(primary_pattern); | 179 return predicate.Run(primary_pattern); |
178 } | 180 } |
179 | 181 |
180 void ClearHostnameResolutionCacheOnIOThread(IOThread* io_thread) { | 182 void ClearHostnameResolutionCacheOnIOThread(IOThread* io_thread) { |
181 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 183 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
182 | 184 |
183 io_thread->ClearHostCache(); | 185 io_thread->ClearHostCache(); |
184 } | 186 } |
185 | 187 |
| 188 void ClearHttpAuthCacheOnIOThread( |
| 189 scoped_refptr<net::URLRequestContextGetter> context_getter, |
| 190 base::Time delete_begin) { |
| 191 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 192 |
| 193 net::HttpNetworkSession* http_session = context_getter->GetURLRequestContext() |
| 194 ->http_transaction_factory() |
| 195 ->GetSession(); |
| 196 DCHECK(http_session); |
| 197 http_session->http_auth_cache()->Clear(base::Time::Now() - delete_begin); |
| 198 http_session->CloseAllConnections(); |
| 199 } |
| 200 |
186 void ClearNetworkPredictorOnIOThread(chrome_browser_net::Predictor* predictor) { | 201 void ClearNetworkPredictorOnIOThread(chrome_browser_net::Predictor* predictor) { |
187 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 202 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
188 DCHECK(predictor); | 203 DCHECK(predictor); |
189 | 204 |
190 predictor->DiscardInitialNavigationHistory(); | 205 predictor->DiscardInitialNavigationHistory(); |
191 predictor->DiscardAllResults(); | 206 predictor->DiscardAllResults(); |
192 } | 207 } |
193 | 208 |
194 #if !defined(DISABLE_NACL) | 209 #if !defined(DISABLE_NACL) |
195 void ClearNaClCacheOnIOThread(const base::Closure& callback) { | 210 void ClearNaClCacheOnIOThread(const base::Closure& callback) { |
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
888 | 903 |
889 // When clearing cache, wipe accumulated network related data | 904 // When clearing cache, wipe accumulated network related data |
890 // (TransportSecurityState and HttpServerPropertiesManager data). | 905 // (TransportSecurityState and HttpServerPropertiesManager data). |
891 waiting_for_clear_networking_history_ = true; | 906 waiting_for_clear_networking_history_ = true; |
892 profile_->ClearNetworkingHistorySince( | 907 profile_->ClearNetworkingHistorySince( |
893 delete_begin_, | 908 delete_begin_, |
894 base::Bind(&BrowsingDataRemover::OnClearedNetworkingHistory, | 909 base::Bind(&BrowsingDataRemover::OnClearedNetworkingHistory, |
895 weak_ptr_factory_.GetWeakPtr())); | 910 weak_ptr_factory_.GetWeakPtr())); |
896 } | 911 } |
897 | 912 |
| 913 if (remove_mask & REMOVE_COOKIES || remove_mask & REMOVE_PASSWORDS) { |
| 914 scoped_refptr<net::URLRequestContextGetter> request_context = |
| 915 profile_->GetRequestContext(); |
| 916 waiting_for_clear_http_auth_cache_ = true; |
| 917 BrowserThread::PostTaskAndReply( |
| 918 BrowserThread::IO, FROM_HERE, |
| 919 base::Bind(&ClearHttpAuthCacheOnIOThread, std::move(request_context), |
| 920 delete_begin_), |
| 921 base::Bind(&BrowsingDataRemover::OnClearedHttpAuthCache, |
| 922 weak_ptr_factory_.GetWeakPtr())); |
| 923 } |
| 924 |
898 // Content Decryption Modules used by Encrypted Media store licenses in a | 925 // Content Decryption Modules used by Encrypted Media store licenses in a |
899 // private filesystem. These are different than content licenses used by | 926 // private filesystem. These are different than content licenses used by |
900 // Flash (which are deleted father down in this method). | 927 // Flash (which are deleted father down in this method). |
901 if (remove_mask & REMOVE_MEDIA_LICENSES) { | 928 if (remove_mask & REMOVE_MEDIA_LICENSES) { |
902 storage_partition_remove_mask |= | 929 storage_partition_remove_mask |= |
903 content::StoragePartition::REMOVE_DATA_MASK_PLUGIN_PRIVATE_DATA; | 930 content::StoragePartition::REMOVE_DATA_MASK_PLUGIN_PRIVATE_DATA; |
904 } | 931 } |
905 | 932 |
906 if (storage_partition_remove_mask) { | 933 if (storage_partition_remove_mask) { |
907 waiting_for_clear_storage_partition_data_ = true; | 934 waiting_for_clear_storage_partition_data_ = true; |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1078 } | 1105 } |
1079 | 1106 |
1080 bool BrowsingDataRemover::AllDone() { | 1107 bool BrowsingDataRemover::AllDone() { |
1081 return !waiting_for_clear_autofill_origin_urls_ && | 1108 return !waiting_for_clear_autofill_origin_urls_ && |
1082 !waiting_for_clear_cache_ && | 1109 !waiting_for_clear_cache_ && |
1083 !waiting_for_clear_flash_content_licenses_ && | 1110 !waiting_for_clear_flash_content_licenses_ && |
1084 !waiting_for_clear_channel_ids_ && !waiting_for_clear_cookies_count_ && | 1111 !waiting_for_clear_channel_ids_ && !waiting_for_clear_cookies_count_ && |
1085 !waiting_for_clear_domain_reliability_monitor_ && | 1112 !waiting_for_clear_domain_reliability_monitor_ && |
1086 !waiting_for_clear_form_ && !waiting_for_clear_history_ && | 1113 !waiting_for_clear_form_ && !waiting_for_clear_history_ && |
1087 !waiting_for_clear_hostname_resolution_cache_ && | 1114 !waiting_for_clear_hostname_resolution_cache_ && |
| 1115 !waiting_for_clear_http_auth_cache_ && |
1088 !waiting_for_clear_keyword_data_ && !waiting_for_clear_nacl_cache_ && | 1116 !waiting_for_clear_keyword_data_ && !waiting_for_clear_nacl_cache_ && |
1089 !waiting_for_clear_network_predictor_ && | 1117 !waiting_for_clear_network_predictor_ && |
1090 !waiting_for_clear_networking_history_ && | 1118 !waiting_for_clear_networking_history_ && |
1091 !waiting_for_clear_passwords_ && !waiting_for_clear_passwords_stats_ && | 1119 !waiting_for_clear_passwords_ && !waiting_for_clear_passwords_stats_ && |
1092 !waiting_for_clear_platform_keys_ && !waiting_for_clear_plugin_data_ && | 1120 !waiting_for_clear_platform_keys_ && !waiting_for_clear_plugin_data_ && |
1093 !waiting_for_clear_pnacl_cache_ && | 1121 !waiting_for_clear_pnacl_cache_ && |
1094 #if BUILDFLAG(ANDROID_JAVA_UI) | 1122 #if BUILDFLAG(ANDROID_JAVA_UI) |
1095 !waiting_for_clear_precache_history_ && | 1123 !waiting_for_clear_precache_history_ && |
1096 !waiting_for_clear_webapp_data_ && | 1124 !waiting_for_clear_webapp_data_ && |
1097 !waiting_for_clear_webapp_history_ && | 1125 !waiting_for_clear_webapp_history_ && |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1150 waiting_for_clear_history_ = false; | 1178 waiting_for_clear_history_ = false; |
1151 NotifyIfDone(); | 1179 NotifyIfDone(); |
1152 } | 1180 } |
1153 | 1181 |
1154 void BrowsingDataRemover::OnClearedHostnameResolutionCache() { | 1182 void BrowsingDataRemover::OnClearedHostnameResolutionCache() { |
1155 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1183 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
1156 waiting_for_clear_hostname_resolution_cache_ = false; | 1184 waiting_for_clear_hostname_resolution_cache_ = false; |
1157 NotifyIfDone(); | 1185 NotifyIfDone(); |
1158 } | 1186 } |
1159 | 1187 |
| 1188 void BrowsingDataRemover::OnClearedHttpAuthCache() { |
| 1189 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1190 waiting_for_clear_http_auth_cache_ = false; |
| 1191 NotifyIfDone(); |
| 1192 } |
| 1193 |
1160 void BrowsingDataRemover::OnClearedNetworkPredictor() { | 1194 void BrowsingDataRemover::OnClearedNetworkPredictor() { |
1161 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1195 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
1162 waiting_for_clear_network_predictor_ = false; | 1196 waiting_for_clear_network_predictor_ = false; |
1163 NotifyIfDone(); | 1197 NotifyIfDone(); |
1164 } | 1198 } |
1165 | 1199 |
1166 void BrowsingDataRemover::OnClearedNetworkingHistory() { | 1200 void BrowsingDataRemover::OnClearedNetworkingHistory() { |
1167 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1201 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
1168 waiting_for_clear_networking_history_ = false; | 1202 waiting_for_clear_networking_history_ = false; |
1169 NotifyIfDone(); | 1203 NotifyIfDone(); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1313 waiting_for_clear_domain_reliability_monitor_ = false; | 1347 waiting_for_clear_domain_reliability_monitor_ = false; |
1314 NotifyIfDone(); | 1348 NotifyIfDone(); |
1315 } | 1349 } |
1316 | 1350 |
1317 // static | 1351 // static |
1318 BrowsingDataRemover::CallbackSubscription | 1352 BrowsingDataRemover::CallbackSubscription |
1319 BrowsingDataRemover::RegisterOnBrowsingDataRemovedCallback( | 1353 BrowsingDataRemover::RegisterOnBrowsingDataRemovedCallback( |
1320 const BrowsingDataRemover::Callback& callback) { | 1354 const BrowsingDataRemover::Callback& callback) { |
1321 return GetOnBrowsingDataRemovedCallbacks()->Add(callback); | 1355 return GetOnBrowsingDataRemovedCallbacks()->Add(callback); |
1322 } | 1356 } |
OLD | NEW |