Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(667)

Side by Side Diff: chrome/browser/browsing_data/browsing_data_remover.cc

Issue 2097043002: Clear HTTP auth data on clearing browsing data (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix review issues Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 base::Time delete_end) {
192 DCHECK_CURRENTLY_ON(BrowserThread::IO);
193
194 net::HttpNetworkSession* http_session = context_getter->GetURLRequestContext()
195 ->http_transaction_factory()
196 ->GetSession();
197 DCHECK(http_session);
198 http_session->http_auth_cache()->Clear(delete_begin, delete_end);
mmenke 2016/07/12 16:27:11 It makes no sense to clear auth but not closing al
Tomasz Moniuszko 2016/07/15 11:41:34 Done.
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 697 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 908
894 // When clearing cache, wipe accumulated network related data 909 // When clearing cache, wipe accumulated network related data
895 // (TransportSecurityState and HttpServerPropertiesManager data). 910 // (TransportSecurityState and HttpServerPropertiesManager data).
896 waiting_for_clear_networking_history_ = true; 911 waiting_for_clear_networking_history_ = true;
897 profile_->ClearNetworkingHistorySince( 912 profile_->ClearNetworkingHistorySince(
898 delete_begin_, 913 delete_begin_,
899 base::Bind(&BrowsingDataRemover::OnClearedNetworkingHistory, 914 base::Bind(&BrowsingDataRemover::OnClearedNetworkingHistory,
900 weak_ptr_factory_.GetWeakPtr())); 915 weak_ptr_factory_.GetWeakPtr()));
901 } 916 }
902 917
918 if (remove_mask & REMOVE_CACHE || remove_mask & REMOVE_COOKIES ||
mmenke 2016/07/12 16:27:11 Hrm...Should we really clear this when clearing th
msramek 2016/07/12 16:52:14 Since this will log you out of the affected sites,
asanka 2016/07/12 17:50:32 The semantics are related, but slightly different.
Tomasz Moniuszko 2016/07/15 11:41:34 REMOVE_CACHE test removed in Patch Set 5.
919 remove_mask & REMOVE_PASSWORDS) {
920 scoped_refptr<net::URLRequestContextGetter> request_context =
921 profile_->GetRequestContext();
922 waiting_for_clear_http_auth_cache_ = true;
923 BrowserThread::PostTaskAndReply(
924 BrowserThread::IO, FROM_HERE,
925 base::Bind(&ClearHttpAuthCacheOnIOThread, std::move(request_context),
926 delete_begin_, delete_end_),
927 base::Bind(&BrowsingDataRemover::OnClearedHttpAuthCache,
928 weak_ptr_factory_.GetWeakPtr()));
929 }
930
903 if (remove_mask & REMOVE_WEBRTC_IDENTITY) { 931 if (remove_mask & REMOVE_WEBRTC_IDENTITY) {
904 storage_partition_remove_mask |= 932 storage_partition_remove_mask |=
905 content::StoragePartition::REMOVE_DATA_MASK_WEBRTC_IDENTITY; 933 content::StoragePartition::REMOVE_DATA_MASK_WEBRTC_IDENTITY;
906 } 934 }
907 935
908 if (storage_partition_remove_mask) { 936 if (storage_partition_remove_mask) {
909 waiting_for_clear_storage_partition_data_ = true; 937 waiting_for_clear_storage_partition_data_ = true;
910 938
911 content::StoragePartition* storage_partition; 939 content::StoragePartition* storage_partition;
912 if (storage_partition_for_testing_) 940 if (storage_partition_for_testing_)
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
1101 return delete_begin_time - diff; 1129 return delete_begin_time - diff;
1102 } 1130 }
1103 1131
1104 bool BrowsingDataRemover::AllDone() { 1132 bool BrowsingDataRemover::AllDone() {
1105 return !waiting_for_clear_autofill_origin_urls_ && 1133 return !waiting_for_clear_autofill_origin_urls_ &&
1106 !waiting_for_clear_cache_ && !waiting_for_clear_content_licenses_ && 1134 !waiting_for_clear_cache_ && !waiting_for_clear_content_licenses_ &&
1107 !waiting_for_clear_channel_ids_ && !waiting_for_clear_cookies_count_ && 1135 !waiting_for_clear_channel_ids_ && !waiting_for_clear_cookies_count_ &&
1108 !waiting_for_clear_domain_reliability_monitor_ && 1136 !waiting_for_clear_domain_reliability_monitor_ &&
1109 !waiting_for_clear_form_ && !waiting_for_clear_history_ && 1137 !waiting_for_clear_form_ && !waiting_for_clear_history_ &&
1110 !waiting_for_clear_hostname_resolution_cache_ && 1138 !waiting_for_clear_hostname_resolution_cache_ &&
1139 !waiting_for_clear_http_auth_cache_ &&
1111 !waiting_for_clear_keyword_data_ && !waiting_for_clear_nacl_cache_ && 1140 !waiting_for_clear_keyword_data_ && !waiting_for_clear_nacl_cache_ &&
1112 !waiting_for_clear_network_predictor_ && 1141 !waiting_for_clear_network_predictor_ &&
1113 !waiting_for_clear_networking_history_ && 1142 !waiting_for_clear_networking_history_ &&
1114 !waiting_for_clear_passwords_ && !waiting_for_clear_passwords_stats_ && 1143 !waiting_for_clear_passwords_ && !waiting_for_clear_passwords_stats_ &&
1115 !waiting_for_clear_platform_keys_ && !waiting_for_clear_plugin_data_ && 1144 !waiting_for_clear_platform_keys_ && !waiting_for_clear_plugin_data_ &&
1116 !waiting_for_clear_pnacl_cache_ && 1145 !waiting_for_clear_pnacl_cache_ &&
1117 #if BUILDFLAG(ANDROID_JAVA_UI) 1146 #if BUILDFLAG(ANDROID_JAVA_UI)
1118 !waiting_for_clear_precache_history_ && 1147 !waiting_for_clear_precache_history_ &&
1119 !waiting_for_clear_webapp_data_ && 1148 !waiting_for_clear_webapp_data_ &&
1120 !waiting_for_clear_webapp_history_ && 1149 !waiting_for_clear_webapp_history_ &&
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1173 waiting_for_clear_history_ = false; 1202 waiting_for_clear_history_ = false;
1174 NotifyIfDone(); 1203 NotifyIfDone();
1175 } 1204 }
1176 1205
1177 void BrowsingDataRemover::OnClearedHostnameResolutionCache() { 1206 void BrowsingDataRemover::OnClearedHostnameResolutionCache() {
1178 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1207 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1179 waiting_for_clear_hostname_resolution_cache_ = false; 1208 waiting_for_clear_hostname_resolution_cache_ = false;
1180 NotifyIfDone(); 1209 NotifyIfDone();
1181 } 1210 }
1182 1211
1212 void BrowsingDataRemover::OnClearedHttpAuthCache() {
1213 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1214 waiting_for_clear_http_auth_cache_ = false;
1215 NotifyIfDone();
1216 }
1217
1183 void BrowsingDataRemover::OnClearedNetworkPredictor() { 1218 void BrowsingDataRemover::OnClearedNetworkPredictor() {
1184 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1219 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1185 waiting_for_clear_network_predictor_ = false; 1220 waiting_for_clear_network_predictor_ = false;
1186 NotifyIfDone(); 1221 NotifyIfDone();
1187 } 1222 }
1188 1223
1189 void BrowsingDataRemover::OnClearedNetworkingHistory() { 1224 void BrowsingDataRemover::OnClearedNetworkingHistory() {
1190 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1225 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1191 waiting_for_clear_networking_history_ = false; 1226 waiting_for_clear_networking_history_ = false;
1192 NotifyIfDone(); 1227 NotifyIfDone();
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
1336 waiting_for_clear_domain_reliability_monitor_ = false; 1371 waiting_for_clear_domain_reliability_monitor_ = false;
1337 NotifyIfDone(); 1372 NotifyIfDone();
1338 } 1373 }
1339 1374
1340 // static 1375 // static
1341 BrowsingDataRemover::CallbackSubscription 1376 BrowsingDataRemover::CallbackSubscription
1342 BrowsingDataRemover::RegisterOnBrowsingDataRemovedCallback( 1377 BrowsingDataRemover::RegisterOnBrowsingDataRemovedCallback(
1343 const BrowsingDataRemover::Callback& callback) { 1378 const BrowsingDataRemover::Callback& callback) {
1344 return GetOnBrowsingDataRemovedCallbacks()->Add(callback); 1379 return GetOnBrowsingDataRemovedCallbacks()->Add(callback);
1345 } 1380 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698