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

Unified Diff: net/cookies/cookie_monster.cc

Issue 1741123002: Add removal filter support for Cookies, Storage, and Content Settings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ios fix, and fixed test Created 4 years, 9 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: net/cookies/cookie_monster.cc
diff --git a/net/cookies/cookie_monster.cc b/net/cookies/cookie_monster.cc
index c2b1871a5ca38bc84fe5591a43f978974152151e..003b31bc4416eb5ecf6a4367e26fb2370a2fb5d4 100644
--- a/net/cookies/cookie_monster.cc
+++ b/net/cookies/cookie_monster.cc
@@ -651,6 +651,40 @@ int CookieMonster::DeleteAllCreatedBetweenForHostTask::RunDeleteTask() {
delete_begin_, delete_end_, url_);
}
+// Task class for DeleteAllCreatedBetweenForHost call.
+class CookieMonster::DeleteAllCreatedBetweenWithPredicateTask
+ : public DeleteTask<int> {
+ public:
+ DeleteAllCreatedBetweenWithPredicateTask(
+ CookieMonster* cookie_monster,
+ Time delete_begin,
+ Time delete_end,
+ base::Callback<bool(const CanonicalCookie&)> predicate,
+ const DeleteCallback& callback)
+ : DeleteTask<int>(cookie_monster, callback),
+ delete_begin_(delete_begin),
+ delete_end_(delete_end),
+ predicate_(predicate) {}
+
+ // DeleteTask:
+ int RunDeleteTask() override;
+
+ protected:
+ ~DeleteAllCreatedBetweenWithPredicateTask() override {}
+
+ private:
+ Time delete_begin_;
+ Time delete_end_;
+ base::Callback<bool(const CanonicalCookie&)> predicate_;
+
+ DISALLOW_COPY_AND_ASSIGN(DeleteAllCreatedBetweenWithPredicateTask);
+};
+
+int CookieMonster::DeleteAllCreatedBetweenWithPredicateTask::RunDeleteTask() {
+ return this->cookie_monster()->DeleteAllCreatedBetweenWithPredicate(
+ delete_begin_, delete_end_, predicate_);
+}
+
// Task class for DeleteCanonicalCookie call.
class CookieMonster::DeleteCanonicalCookieTask : public DeleteTask<int> {
public:
@@ -961,6 +995,21 @@ void CookieMonster::DeleteAllCreatedBetweenForHostAsync(
DoCookieTaskForURL(task, url);
}
+void CookieMonster::DeleteAllCreatedBetweenWithPredicateAsync(
+ const Time& delete_begin,
+ const Time& delete_end,
+ const base::Callback<bool(const CanonicalCookie&)>& predicate,
+ const DeleteCallback& callback) {
+ if (predicate.is_null()) {
+ DeleteAllCreatedBetweenAsync(delete_begin, delete_end, callback);
+ return;
+ }
+ scoped_refptr<DeleteAllCreatedBetweenWithPredicateTask> task =
+ new DeleteAllCreatedBetweenWithPredicateTask(
+ this, delete_begin, delete_end, predicate, callback);
+ DoCookieTask(task);
+}
+
void CookieMonster::DeleteSessionCookiesAsync(
const CookieStore::DeleteCallback& callback) {
scoped_refptr<DeleteSessionCookiesTask> task =
@@ -1181,6 +1230,27 @@ int CookieMonster::DeleteAllCreatedBetweenForHost(const Time delete_begin,
return num_deleted;
}
+int CookieMonster::DeleteAllCreatedBetweenWithPredicate(
+ const base::Time& delete_begin,
+ const base::Time& delete_end,
+ const base::Callback<bool(const CanonicalCookie&)>& predicate) {
+ int num_deleted = 0;
+ for (CookieMap::iterator it = cookies_.begin(); it != cookies_.end();) {
+ CookieMap::iterator curit = it;
+ CanonicalCookie* cc = curit->second;
+ ++it;
+
+ if (cc->CreationDate() >= delete_begin &&
+ (delete_end.is_null() || cc->CreationDate() < delete_end) &&
+ predicate.Run(*cc)) {
+ InternalDeleteCookie(curit, true, /*sync_to_store*/
+ DELETE_COOKIE_EXPLICIT);
+ ++num_deleted;
+ }
+ }
+
+ return num_deleted;
+}
bool CookieMonster::SetCookieWithOptions(const GURL& url,
const std::string& cookie_line,

Powered by Google App Engine
This is Rietveld 408576698