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

Unified Diff: chrome/browser/browsing_data/browsing_data_remover.cc

Issue 1603903002: Add an OriginFilterBuilder class for [white|black]listing origins. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: DCHECK(not many origins) Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/browsing_data/browsing_data_remover.cc
diff --git a/chrome/browser/browsing_data/browsing_data_remover.cc b/chrome/browser/browsing_data/browsing_data_remover.cc
index ca6d7b3f052a5fc8bedaddaeec1246a1e9d81a35..b3eece35a0396fbdc0dcb28e50e1048c494c6583 100644
--- a/chrome/browser/browsing_data/browsing_data_remover.cc
+++ b/chrome/browser/browsing_data/browsing_data_remover.cc
@@ -18,6 +18,7 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browsing_data/browsing_data_helper.h"
#include "chrome/browser/browsing_data/browsing_data_remover_factory.h"
+#include "chrome/browser/browsing_data/origin_filter_builder.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/domain_reliability/service_factory.h"
@@ -343,7 +344,19 @@ void BrowsingDataRemover::RemoveImpl(const TimeRange& time_range,
delete_end_ = time_range.end;
remove_mask_ = remove_mask;
origin_type_mask_ = origin_type_mask;
+
+ // TODO(msramek): Replace |remove_origin| with |filter| in all backends.
const url::Origin remove_origin(remove_url);
+ OriginFilterBuilder builder(OriginFilterBuilder::BLACKLIST);
+ if (!remove_url.is_empty()) {
+ // Make sure that only URLs representing origins, with no extra components,
+ // are passed to this class.
+ DCHECK_EQ(remove_url, remove_url.GetOrigin());
+ builder.SetMode(OriginFilterBuilder::WHITELIST);
+ builder.AddOrigin(url::Origin(remove_origin));
+ }
+ base::Callback<bool(const GURL& url)> same_origin_filter =
+ builder.BuildSameOriginFilter();
PrefService* prefs = profile_->GetPrefs();
bool may_delete_history = prefs->GetBoolean(
@@ -379,6 +392,14 @@ void BrowsingDataRemover::RemoveImpl(const TimeRange& time_range,
HistoryServiceFactory::GetForProfile(
profile_, ServiceAccessType::EXPLICIT_ACCESS);
if (history_service) {
+ // Selective history deletion is currently done through HistoryUI ->
+ // HistoryBackend -> HistoryService, and that is for individual URLs,
+ // not origins. The code below is currently unused, as the only callsite
+ // supplying |remove_url| is the unittest.
+ // TODO(msramek): Investigate whether history deletion, especially in the
brettw 2016/02/22 23:23:58 History does an exact match.
msramek 2016/02/23 09:21:40 Thanks. I updated the TODO. I'll have to talk to s
brettw 2016/02/23 17:53:23 I'm not sure why anybody serverside would be neces
+ // case of web history, understands an origin parameter as the deletion
+ // of all URLs from that origin, or just the URL with empty path.
+ // TODO(msramek): Replace |remove_url| with a GURL->bool predicate.
std::set<GURL> restrict_urls;
if (!remove_url.is_empty())
restrict_urls.insert(remove_url);
@@ -559,12 +580,8 @@ void BrowsingDataRemover::RemoveImpl(const TimeRange& time_range,
content::RecordAction(UserMetricsAction("ClearBrowsingData_Downloads"));
content::DownloadManager* download_manager =
BrowserContext::GetDownloadManager(profile_);
- if (remove_url.is_empty()) {
- download_manager->RemoveDownloadsBetween(delete_begin_, delete_end_);
- } else {
- download_manager->RemoveDownloadsByOriginAndTime(
- remove_origin, delete_begin_, delete_end_);
- }
+ download_manager->RemoveDownloadsByURLAndTime(
+ same_origin_filter, delete_begin_, delete_end_);
DownloadPrefs* download_prefs = DownloadPrefs::FromDownloadManager(
download_manager);
download_prefs->SetSaveFilePath(download_prefs->DownloadPath());

Powered by Google App Engine
This is Rietveld 408576698