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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
67 #include "components/search_engines/template_url_service.h" | 67 #include "components/search_engines/template_url_service.h" |
68 #include "components/sessions/core/tab_restore_service.h" | 68 #include "components/sessions/core/tab_restore_service.h" |
69 #include "components/translate/core/browser/language_model.h" | 69 #include "components/translate/core/browser/language_model.h" |
70 #include "components/web_cache/browser/web_cache_manager.h" | 70 #include "components/web_cache/browser/web_cache_manager.h" |
71 #include "content/public/browser/browsing_data_filter_builder.h" | 71 #include "content/public/browser/browsing_data_filter_builder.h" |
72 #include "content/public/browser/plugin_data_remover.h" | 72 #include "content/public/browser/plugin_data_remover.h" |
73 #include "content/public/browser/ssl_host_state_delegate.h" | 73 #include "content/public/browser/ssl_host_state_delegate.h" |
74 #include "content/public/browser/storage_partition.h" | 74 #include "content/public/browser/storage_partition.h" |
75 #include "net/cookies/cookie_store.h" | 75 #include "net/cookies/cookie_store.h" |
76 #include "net/http/http_transaction_factory.h" | 76 #include "net/http/http_transaction_factory.h" |
77 #include "net/reporting/reporting_browsing_data_remover.h" | |
78 #include "net/reporting/reporting_service.h" | |
77 #include "net/url_request/url_request_context.h" | 79 #include "net/url_request/url_request_context.h" |
78 #include "net/url_request/url_request_context_getter.h" | 80 #include "net/url_request/url_request_context_getter.h" |
79 #include "url/url_util.h" | 81 #include "url/url_util.h" |
80 | 82 |
81 #if defined(OS_ANDROID) | 83 #if defined(OS_ANDROID) |
82 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" | 84 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" |
83 #include "chrome/browser/android/webapps/webapp_registry.h" | 85 #include "chrome/browser/android/webapps/webapp_registry.h" |
84 #include "chrome/browser/precache/precache_manager_factory.h" | 86 #include "chrome/browser/precache/precache_manager_factory.h" |
85 #include "components/offline_pages/core/offline_page_feature.h" | 87 #include "components/offline_pages/core/offline_page_feature.h" |
86 #include "components/offline_pages/core/offline_page_model.h" | 88 #include "components/offline_pages/core/offline_page_model.h" |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
229 | 231 |
230 net::HttpNetworkSession* http_session = context_getter->GetURLRequestContext() | 232 net::HttpNetworkSession* http_session = context_getter->GetURLRequestContext() |
231 ->http_transaction_factory() | 233 ->http_transaction_factory() |
232 ->GetSession(); | 234 ->GetSession(); |
233 DCHECK(http_session); | 235 DCHECK(http_session); |
234 http_session->http_auth_cache()->ClearEntriesAddedWithin(base::Time::Now() - | 236 http_session->http_auth_cache()->ClearEntriesAddedWithin(base::Time::Now() - |
235 delete_begin); | 237 delete_begin); |
236 http_session->CloseAllConnections(); | 238 http_session->CloseAllConnections(); |
237 } | 239 } |
238 | 240 |
241 void ClearReportingCacheOnIOThread( | |
242 net::URLRequestContextGetter* context, | |
243 int data_type_mask, | |
244 base::Callback<bool(const GURL&)> origin_filter) { | |
Bernhard Bauer
2017/04/21 16:49:26
Nit: Callbacks are usually passed by const-ref.
Julia Tuttle
2017/04/21 18:25:11
Oops!
| |
245 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
246 | |
247 net::ReportingService* service = | |
248 context->GetURLRequestContext()->reporting_service(); | |
249 if (service) | |
250 service->RemoveBrowsingData(data_type_mask, origin_filter); | |
251 } | |
252 | |
239 // Returned by ChromeBrowsingDataRemoverDelegate::GetOriginTypeMatcher(). | 253 // Returned by ChromeBrowsingDataRemoverDelegate::GetOriginTypeMatcher(). |
240 bool DoesOriginMatchEmbedderMask(int origin_type_mask, | 254 bool DoesOriginMatchEmbedderMask(int origin_type_mask, |
241 const GURL& origin, | 255 const GURL& origin, |
242 storage::SpecialStoragePolicy* policy) { | 256 storage::SpecialStoragePolicy* policy) { |
243 DCHECK_EQ( | 257 DCHECK_EQ( |
244 0, | 258 0, |
245 origin_type_mask & | 259 origin_type_mask & |
246 (ChromeBrowsingDataRemoverDelegate::ORIGIN_TYPE_EMBEDDER_BEGIN - 1)) | 260 (ChromeBrowsingDataRemoverDelegate::ORIGIN_TYPE_EMBEDDER_BEGIN - 1)) |
247 << "|origin_type_mask| can only contain origin types defined in " | 261 << "|origin_type_mask| can only contain origin types defined in " |
248 << "the embedder."; | 262 << "the embedder."; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
319 clear_http_auth_cache_(sub_task_forward_callback_), | 333 clear_http_auth_cache_(sub_task_forward_callback_), |
320 clear_platform_keys_(sub_task_forward_callback_), | 334 clear_platform_keys_(sub_task_forward_callback_), |
321 #if defined(OS_ANDROID) | 335 #if defined(OS_ANDROID) |
322 clear_precache_history_(sub_task_forward_callback_), | 336 clear_precache_history_(sub_task_forward_callback_), |
323 clear_offline_page_data_(sub_task_forward_callback_), | 337 clear_offline_page_data_(sub_task_forward_callback_), |
324 #endif | 338 #endif |
325 #if BUILDFLAG(ENABLE_WEBRTC) | 339 #if BUILDFLAG(ENABLE_WEBRTC) |
326 clear_webrtc_logs_(sub_task_forward_callback_), | 340 clear_webrtc_logs_(sub_task_forward_callback_), |
327 #endif | 341 #endif |
328 clear_auto_sign_in_(sub_task_forward_callback_), | 342 clear_auto_sign_in_(sub_task_forward_callback_), |
343 clear_reporting_cache_(sub_task_forward_callback_), | |
329 #if BUILDFLAG(ENABLE_PLUGINS) | 344 #if BUILDFLAG(ENABLE_PLUGINS) |
330 flash_lso_helper_(BrowsingDataFlashLSOHelper::Create(browser_context)), | 345 flash_lso_helper_(BrowsingDataFlashLSOHelper::Create(browser_context)), |
331 #endif | 346 #endif |
332 #if defined(OS_ANDROID) | 347 #if defined(OS_ANDROID) |
333 webapp_registry_(new WebappRegistry()), | 348 webapp_registry_(new WebappRegistry()), |
334 #endif | 349 #endif |
335 weak_ptr_factory_(this) {} | 350 weak_ptr_factory_(this) {} |
336 | 351 |
337 ChromeBrowsingDataRemoverDelegate::~ChromeBrowsingDataRemoverDelegate() { | 352 ChromeBrowsingDataRemoverDelegate::~ChromeBrowsingDataRemoverDelegate() { |
338 history_task_tracker_.TryCancelAll(); | 353 history_task_tracker_.TryCancelAll(); |
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
987 mode = domain_reliability::CLEAR_BEACONS; | 1002 mode = domain_reliability::CLEAR_BEACONS; |
988 | 1003 |
989 clear_domain_reliability_monitor_.Start(); | 1004 clear_domain_reliability_monitor_.Start(); |
990 service->ClearBrowsingData( | 1005 service->ClearBrowsingData( |
991 mode, | 1006 mode, |
992 filter, | 1007 filter, |
993 clear_domain_reliability_monitor_.GetCompletionCallback()); | 1008 clear_domain_reliability_monitor_.GetCompletionCallback()); |
994 } | 1009 } |
995 } | 1010 } |
996 | 1011 |
1012 if ((remove_mask & BrowsingDataRemover::DATA_TYPE_COOKIES) || | |
1013 (remove_mask & DATA_TYPE_HISTORY)) { | |
1014 scoped_refptr<net::URLRequestContextGetter> context = | |
1015 profile_->GetRequestContext(); | |
1016 | |
1017 int data_type_mask = 0; | |
1018 if (remove_mask & DATA_TYPE_HISTORY) | |
1019 data_type_mask |= net::ReportingBrowsingDataRemover::DATA_TYPE_REPORTS; | |
1020 if (remove_mask & BrowsingDataRemover::DATA_TYPE_COOKIES) | |
1021 data_type_mask |= net::ReportingBrowsingDataRemover::DATA_TYPE_CLIENTS; | |
1022 | |
1023 clear_reporting_cache_.Start(); | |
1024 BrowserThread::PostTaskAndReply( | |
1025 BrowserThread::IO, FROM_HERE, | |
1026 base::Bind(&ClearReportingCacheOnIOThread, | |
1027 base::RetainedRef(std::move(context)), data_type_mask, | |
1028 filter), | |
1029 UIThreadTrampoline(clear_reporting_cache_.GetCompletionCallback())); | |
1030 } | |
1031 | |
997 ////////////////////////////////////////////////////////////////////////////// | 1032 ////////////////////////////////////////////////////////////////////////////// |
998 // DATA_TYPE_WEB_APP_DATA | 1033 // DATA_TYPE_WEB_APP_DATA |
999 #if defined(OS_ANDROID) | 1034 #if defined(OS_ANDROID) |
1000 // Clear all data associated with registered webapps. | 1035 // Clear all data associated with registered webapps. |
1001 if (remove_mask & DATA_TYPE_WEB_APP_DATA) | 1036 if (remove_mask & DATA_TYPE_WEB_APP_DATA) |
1002 webapp_registry_->UnregisterWebappsForUrls(filter); | 1037 webapp_registry_->UnregisterWebappsForUrls(filter); |
1003 #endif | 1038 #endif |
1004 | 1039 |
1005 ////////////////////////////////////////////////////////////////////////////// | 1040 ////////////////////////////////////////////////////////////////////////////// |
1006 // Remove external protocol data. | 1041 // Remove external protocol data. |
(...skipping 29 matching lines...) Expand all Loading... | |
1036 !clear_http_auth_cache_.is_pending() && | 1071 !clear_http_auth_cache_.is_pending() && |
1037 !clear_platform_keys_.is_pending() && | 1072 !clear_platform_keys_.is_pending() && |
1038 #if defined(OS_ANDROID) | 1073 #if defined(OS_ANDROID) |
1039 !clear_precache_history_.is_pending() && | 1074 !clear_precache_history_.is_pending() && |
1040 !clear_offline_page_data_.is_pending() && | 1075 !clear_offline_page_data_.is_pending() && |
1041 #endif | 1076 #endif |
1042 #if BUILDFLAG(ENABLE_WEBRTC) | 1077 #if BUILDFLAG(ENABLE_WEBRTC) |
1043 !clear_webrtc_logs_.is_pending() && | 1078 !clear_webrtc_logs_.is_pending() && |
1044 #endif | 1079 #endif |
1045 !clear_auto_sign_in_.is_pending() && | 1080 !clear_auto_sign_in_.is_pending() && |
1046 !clear_plugin_data_count_; | 1081 !clear_reporting_cache_.is_pending() && !clear_plugin_data_count_; |
1047 } | 1082 } |
1048 | 1083 |
1049 #if defined(OS_ANDROID) | 1084 #if defined(OS_ANDROID) |
1050 void ChromeBrowsingDataRemoverDelegate::OverrideWebappRegistryForTesting( | 1085 void ChromeBrowsingDataRemoverDelegate::OverrideWebappRegistryForTesting( |
1051 std::unique_ptr<WebappRegistry> webapp_registry) { | 1086 std::unique_ptr<WebappRegistry> webapp_registry) { |
1052 webapp_registry_ = std::move(webapp_registry); | 1087 webapp_registry_ = std::move(webapp_registry); |
1053 } | 1088 } |
1054 #endif | 1089 #endif |
1055 | 1090 |
1056 #if BUILDFLAG(ENABLE_PLUGINS) | 1091 #if BUILDFLAG(ENABLE_PLUGINS) |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1132 } | 1167 } |
1133 | 1168 |
1134 void ChromeBrowsingDataRemoverDelegate:: | 1169 void ChromeBrowsingDataRemoverDelegate:: |
1135 OnDeauthorizeFlashContentLicensesCompleted( | 1170 OnDeauthorizeFlashContentLicensesCompleted( |
1136 uint32_t request_id, | 1171 uint32_t request_id, |
1137 bool /* success */) { | 1172 bool /* success */) { |
1138 DCHECK_EQ(request_id, deauthorize_flash_content_licenses_request_id_); | 1173 DCHECK_EQ(request_id, deauthorize_flash_content_licenses_request_id_); |
1139 clear_flash_content_licenses_.GetCompletionCallback().Run(); | 1174 clear_flash_content_licenses_.GetCompletionCallback().Run(); |
1140 } | 1175 } |
1141 #endif | 1176 #endif |
OLD | NEW |