From 6e2efc0462d72267c5a524411e4771e67da206e1 Mon Sep 17 00:00:00 2001 From: "pfeldman@chromium.org" Date: Fri, 30 Oct 2009 14:48:15 +0000 Subject: DevTools: Allow deleting cookies. Review URL: http://codereview.chromium.org/350001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30578 0039d316-1c4b-4281-b951-d872f2087c98 --- net/base/cookie_monster.cc | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'net/base/cookie_monster.cc') diff --git a/net/base/cookie_monster.cc b/net/base/cookie_monster.cc index 2c2f21d..01b68a1 100644 --- a/net/base/cookie_monster.cc +++ b/net/base/cookie_monster.cc @@ -792,12 +792,27 @@ void CookieMonster::DeleteCookie(const GURL& url, if (!HasCookieableScheme(url)) return; - for (CookieMapItPair its = cookies_.equal_range(url.host()); - its.first != its.second; ++its.first) { - if (its.first->second->Name() == cookie_name) { - InternalDeleteCookie(its.first, true); - return; - } + CookieOptions options; + options.set_include_httponly(); + // Get the cookies for this host and its domain(s). + std::vector cookies; + FindCookiesForHostAndDomain(url, options, &cookies); + std::set matching_cookies; + + for (std::vector::const_iterator it = cookies.begin(); + it != cookies.end(); ++it) { + if ((*it)->Name() != cookie_name) + continue; + if (url.path().find((*it)->Path())) + continue; + matching_cookies.insert(*it); + } + + for (CookieMap::iterator it = cookies_.begin(); it != cookies_.end();) { + CookieMap::iterator curit = it; + ++it; + if (matching_cookies.find(curit->second) != matching_cookies.end()) + InternalDeleteCookie(curit, true); } } -- cgit v1.1