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

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

Issue 1251243003: Support restricting browsing data removal for downloads by origin. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Created 5 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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 void BrowsingDataRemover::set_removing(bool is_removing) { 244 void BrowsingDataRemover::set_removing(bool is_removing) {
245 DCHECK(is_removing_ != is_removing); 245 DCHECK(is_removing_ != is_removing);
246 is_removing_ = is_removing; 246 is_removing_ = is_removing;
247 } 247 }
248 248
249 void BrowsingDataRemover::Remove(int remove_mask, int origin_type_mask) { 249 void BrowsingDataRemover::Remove(int remove_mask, int origin_type_mask) {
250 RemoveImpl(remove_mask, GURL(), origin_type_mask); 250 RemoveImpl(remove_mask, GURL(), origin_type_mask);
251 } 251 }
252 252
253 void BrowsingDataRemover::RemoveImpl(int remove_mask, 253 void BrowsingDataRemover::RemoveImpl(int remove_mask,
254 const GURL& origin, 254 const GURL& origin,
Mike West 2015/07/22 20:16:03 Please add a TODO to replace this with `url::Origi
255 int origin_type_mask) { 255 int origin_type_mask) {
256 DCHECK_CURRENTLY_ON(BrowserThread::UI); 256 DCHECK_CURRENTLY_ON(BrowserThread::UI);
257 set_removing(true); 257 set_removing(true);
258 remove_mask_ = remove_mask; 258 remove_mask_ = remove_mask;
259 remove_origin_ = origin; 259 remove_origin_ = origin;
260 origin_type_mask_ = origin_type_mask; 260 origin_type_mask_ = origin_type_mask;
261 261
262 PrefService* prefs = profile_->GetPrefs(); 262 PrefService* prefs = profile_->GetPrefs();
263 bool may_delete_history = prefs->GetBoolean( 263 bool may_delete_history = prefs->GetBoolean(
264 prefs::kAllowDeletingBrowserHistory); 264 prefs::kAllowDeletingBrowserHistory);
(...skipping 16 matching lines...) Expand all
281 UserMetricsAction("ClearBrowsingData_MaskContainsExtension")); 281 UserMetricsAction("ClearBrowsingData_MaskContainsExtension"));
282 } 282 }
283 // If this fires, we added a new BrowsingDataHelper::OriginTypeMask without 283 // If this fires, we added a new BrowsingDataHelper::OriginTypeMask without
284 // updating the user metrics above. 284 // updating the user metrics above.
285 static_assert( 285 static_assert(
286 BrowsingDataHelper::ALL == (BrowsingDataHelper::UNPROTECTED_WEB | 286 BrowsingDataHelper::ALL == (BrowsingDataHelper::UNPROTECTED_WEB |
287 BrowsingDataHelper::PROTECTED_WEB | 287 BrowsingDataHelper::PROTECTED_WEB |
288 BrowsingDataHelper::EXTENSION), 288 BrowsingDataHelper::EXTENSION),
289 "OriginTypeMask has been updated without updating user metrics"); 289 "OriginTypeMask has been updated without updating user metrics");
290 290
291 std::set<GURL> restrict_urls;
Mike West 2015/07/22 20:16:03 1. Why do we need a set here if we're adding a sin
Timo Reimann 2015/07/22 23:22:15 According to git history, the set was added back i
Mike West 2015/07/23 09:56:49 If there's a reasonable use case for multiple orig
Timo Reimann 2015/07/23 23:11:07 As of now, only for history::HistoryService::Expir
292 if (!remove_origin_.is_empty())
293 restrict_urls.insert(remove_origin_);
294
291 if ((remove_mask & REMOVE_HISTORY) && may_delete_history) { 295 if ((remove_mask & REMOVE_HISTORY) && may_delete_history) {
292 history::HistoryService* history_service = 296 history::HistoryService* history_service =
293 HistoryServiceFactory::GetForProfile( 297 HistoryServiceFactory::GetForProfile(
294 profile_, ServiceAccessType::EXPLICIT_ACCESS); 298 profile_, ServiceAccessType::EXPLICIT_ACCESS);
295 if (history_service) { 299 if (history_service) {
296 std::set<GURL> restrict_urls;
297 if (!remove_origin_.is_empty())
298 restrict_urls.insert(remove_origin_);
299 content::RecordAction(UserMetricsAction("ClearBrowsingData_History")); 300 content::RecordAction(UserMetricsAction("ClearBrowsingData_History"));
300 waiting_for_clear_history_ = true; 301 waiting_for_clear_history_ = true;
301 302
302 history_service->ExpireLocalAndRemoteHistoryBetween( 303 history_service->ExpireLocalAndRemoteHistoryBetween(
303 WebHistoryServiceFactory::GetForProfile(profile_), 304 WebHistoryServiceFactory::GetForProfile(profile_),
304 restrict_urls, delete_begin_, delete_end_, 305 restrict_urls, delete_begin_, delete_end_,
305 base::Bind(&BrowsingDataRemover::OnHistoryDeletionDone, 306 base::Bind(&BrowsingDataRemover::OnHistoryDeletionDone,
306 base::Unretained(this)), 307 base::Unretained(this)),
307 &history_task_tracker_); 308 &history_task_tracker_);
308 309
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 // The SSL Host State that tracks SSL interstitial "proceed" decisions may 437 // The SSL Host State that tracks SSL interstitial "proceed" decisions may
437 // include origins that the user has visited, so it must be cleared. 438 // include origins that the user has visited, so it must be cleared.
438 if (profile_->GetSSLHostStateDelegate()) 439 if (profile_->GetSSLHostStateDelegate())
439 profile_->GetSSLHostStateDelegate()->Clear(); 440 profile_->GetSSLHostStateDelegate()->Clear();
440 } 441 }
441 442
442 if ((remove_mask & REMOVE_DOWNLOADS) && may_delete_history) { 443 if ((remove_mask & REMOVE_DOWNLOADS) && may_delete_history) {
443 content::RecordAction(UserMetricsAction("ClearBrowsingData_Downloads")); 444 content::RecordAction(UserMetricsAction("ClearBrowsingData_Downloads"));
444 content::DownloadManager* download_manager = 445 content::DownloadManager* download_manager =
445 BrowserContext::GetDownloadManager(profile_); 446 BrowserContext::GetDownloadManager(profile_);
446 download_manager->RemoveDownloadsBetween(delete_begin_, delete_end_); 447 download_manager->RemoveDownloadsBetween(restrict_urls,
448 delete_begin_,
449 delete_end_);
447 DownloadPrefs* download_prefs = DownloadPrefs::FromDownloadManager( 450 DownloadPrefs* download_prefs = DownloadPrefs::FromDownloadManager(
448 download_manager); 451 download_manager);
449 download_prefs->SetSaveFilePath(download_prefs->DownloadPath()); 452 download_prefs->SetSaveFilePath(download_prefs->DownloadPath());
450 } 453 }
451 454
452 uint32 storage_partition_remove_mask = 0; 455 uint32 storage_partition_remove_mask = 0;
453 456
454 // We ignore the REMOVE_COOKIES request if UNPROTECTED_WEB is not set, 457 // We ignore the REMOVE_COOKIES request if UNPROTECTED_WEB is not set,
455 // so that callers who request REMOVE_SITE_DATA with PROTECTED_WEB 458 // so that callers who request REMOVE_SITE_DATA with PROTECTED_WEB
456 // don't accidentally remove the cookies that are associated with the 459 // don't accidentally remove the cookies that are associated with the
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
1105 waiting_for_clear_domain_reliability_monitor_ = false; 1108 waiting_for_clear_domain_reliability_monitor_ = false;
1106 NotifyAndDeleteIfDone(); 1109 NotifyAndDeleteIfDone();
1107 } 1110 }
1108 1111
1109 // static 1112 // static
1110 BrowsingDataRemover::CallbackSubscription 1113 BrowsingDataRemover::CallbackSubscription
1111 BrowsingDataRemover::RegisterOnBrowsingDataRemovedCallback( 1114 BrowsingDataRemover::RegisterOnBrowsingDataRemovedCallback(
1112 const BrowsingDataRemover::Callback& callback) { 1115 const BrowsingDataRemover::Callback& callback) {
1113 return GetOnBrowsingDataRemovedCallbacks()->Add(callback); 1116 return GetOnBrowsingDataRemovedCallbacks()->Add(callback);
1114 } 1117 }
OLDNEW
« no previous file with comments | « no previous file | content/browser/download/download_manager_impl.h » ('j') | content/browser/download/download_manager_impl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698