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

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

Issue 2829683004: Reporting: Plumb from //chrome/browser/browsing_data. (Closed)
Patch Set: Fix. Created 3 years, 7 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 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
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
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 const base::Callback<bool(const GURL&)>& origin_filter) {
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
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 353
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after
999 mode = domain_reliability::CLEAR_BEACONS; 1014 mode = domain_reliability::CLEAR_BEACONS;
1000 1015
1001 clear_domain_reliability_monitor_.Start(); 1016 clear_domain_reliability_monitor_.Start();
1002 service->ClearBrowsingData( 1017 service->ClearBrowsingData(
1003 mode, 1018 mode,
1004 filter, 1019 filter,
1005 clear_domain_reliability_monitor_.GetCompletionCallback()); 1020 clear_domain_reliability_monitor_.GetCompletionCallback());
1006 } 1021 }
1007 } 1022 }
1008 1023
1024 if ((remove_mask & content::BrowsingDataRemover::DATA_TYPE_COOKIES) ||
1025 (remove_mask & DATA_TYPE_HISTORY)) {
1026 scoped_refptr<net::URLRequestContextGetter> context =
1027 profile_->GetRequestContext();
1028
1029 int data_type_mask = 0;
1030 if (remove_mask & DATA_TYPE_HISTORY)
1031 data_type_mask |= net::ReportingBrowsingDataRemover::DATA_TYPE_REPORTS;
1032 if (remove_mask & content::BrowsingDataRemover::DATA_TYPE_COOKIES)
1033 data_type_mask |= net::ReportingBrowsingDataRemover::DATA_TYPE_CLIENTS;
1034
1035 clear_reporting_cache_.Start();
1036 BrowserThread::PostTaskAndReply(
1037 BrowserThread::IO, FROM_HERE,
1038 base::Bind(&ClearReportingCacheOnIOThread,
1039 base::RetainedRef(std::move(context)), data_type_mask,
1040 filter),
1041 UIThreadTrampoline(clear_reporting_cache_.GetCompletionCallback()));
1042 }
1043
1009 ////////////////////////////////////////////////////////////////////////////// 1044 //////////////////////////////////////////////////////////////////////////////
1010 // DATA_TYPE_WEB_APP_DATA 1045 // DATA_TYPE_WEB_APP_DATA
1011 #if defined(OS_ANDROID) 1046 #if defined(OS_ANDROID)
1012 // Clear all data associated with registered webapps. 1047 // Clear all data associated with registered webapps.
1013 if (remove_mask & DATA_TYPE_WEB_APP_DATA) 1048 if (remove_mask & DATA_TYPE_WEB_APP_DATA)
1014 webapp_registry_->UnregisterWebappsForUrls(filter); 1049 webapp_registry_->UnregisterWebappsForUrls(filter);
1015 #endif 1050 #endif
1016 1051
1017 ////////////////////////////////////////////////////////////////////////////// 1052 //////////////////////////////////////////////////////////////////////////////
1018 // Remove external protocol data. 1053 // Remove external protocol data.
(...skipping 29 matching lines...) Expand all
1048 !clear_http_auth_cache_.is_pending() && 1083 !clear_http_auth_cache_.is_pending() &&
1049 !clear_platform_keys_.is_pending() && 1084 !clear_platform_keys_.is_pending() &&
1050 #if defined(OS_ANDROID) 1085 #if defined(OS_ANDROID)
1051 !clear_precache_history_.is_pending() && 1086 !clear_precache_history_.is_pending() &&
1052 !clear_offline_page_data_.is_pending() && 1087 !clear_offline_page_data_.is_pending() &&
1053 #endif 1088 #endif
1054 #if BUILDFLAG(ENABLE_WEBRTC) 1089 #if BUILDFLAG(ENABLE_WEBRTC)
1055 !clear_webrtc_logs_.is_pending() && 1090 !clear_webrtc_logs_.is_pending() &&
1056 #endif 1091 #endif
1057 !clear_auto_sign_in_.is_pending() && 1092 !clear_auto_sign_in_.is_pending() &&
1058 !clear_plugin_data_count_; 1093 !clear_reporting_cache_.is_pending() && !clear_plugin_data_count_;
1059 } 1094 }
1060 1095
1061 #if defined(OS_ANDROID) 1096 #if defined(OS_ANDROID)
1062 void ChromeBrowsingDataRemoverDelegate::OverrideWebappRegistryForTesting( 1097 void ChromeBrowsingDataRemoverDelegate::OverrideWebappRegistryForTesting(
1063 std::unique_ptr<WebappRegistry> webapp_registry) { 1098 std::unique_ptr<WebappRegistry> webapp_registry) {
1064 webapp_registry_ = std::move(webapp_registry); 1099 webapp_registry_ = std::move(webapp_registry);
1065 } 1100 }
1066 #endif 1101 #endif
1067 1102
1068 #if BUILDFLAG(ENABLE_PLUGINS) 1103 #if BUILDFLAG(ENABLE_PLUGINS)
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1144 } 1179 }
1145 1180
1146 void ChromeBrowsingDataRemoverDelegate:: 1181 void ChromeBrowsingDataRemoverDelegate::
1147 OnDeauthorizeFlashContentLicensesCompleted( 1182 OnDeauthorizeFlashContentLicensesCompleted(
1148 uint32_t request_id, 1183 uint32_t request_id,
1149 bool /* success */) { 1184 bool /* success */) {
1150 DCHECK_EQ(request_id, deauthorize_flash_content_licenses_request_id_); 1185 DCHECK_EQ(request_id, deauthorize_flash_content_licenses_request_id_);
1151 clear_flash_content_licenses_.GetCompletionCallback().Run(); 1186 clear_flash_content_licenses_.GetCompletionCallback().Run();
1152 } 1187 }
1153 #endif 1188 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698