summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authormaruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-24 20:19:16 +0000
committermaruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-24 20:19:16 +0000
commit869f2efe7f02e3eca489b1ced00f371543bb1e0a (patch)
treefc821949211a73dd0c763e7c081b6eca9afc2583 /net
parent0ec9203dac6b11c664adda8a39b77f3f00eb6072 (diff)
downloadchromium_src-869f2efe7f02e3eca489b1ced00f371543bb1e0a.zip
chromium_src-869f2efe7f02e3eca489b1ced00f371543bb1e0a.tar.gz
chromium_src-869f2efe7f02e3eca489b1ced00f371543bb1e0a.tar.bz2
Reapply 42467 by reverting 42499 and added suppression.
"Clear cookies, local storage and databases when an extension gets uninstalled." BUG=39177 BUG=38398 Review URL: http://codereview.chromium.org/1210004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42520 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/base/cookie_monster.cc79
-rw-r--r--net/base/cookie_monster.h7
2 files changed, 55 insertions, 31 deletions
diff --git a/net/base/cookie_monster.cc b/net/base/cookie_monster.cc
index 50ffcac..cd5d7f2 100644
--- a/net/base/cookie_monster.cc
+++ b/net/base/cookie_monster.cc
@@ -782,6 +782,20 @@ int CookieMonster::DeleteAllCreatedAfter(const Time& delete_begin,
return DeleteAllCreatedBetween(delete_begin, Time(), sync_to_store);
}
+int CookieMonster::DeleteAllForURL(const GURL& url,
+ bool sync_to_store) {
+ AutoLock autolock(lock_);
+ InitIfNecessary();
+ CookieList cookies = InternalGetAllCookiesForURL(url);
+ int num_deleted = 0;
+ for (CookieMap::iterator it = cookies_.begin(); it != cookies_.end();) {
+ CookieMap::iterator curit = it;
+ ++it;
+ InternalDeleteCookie(curit, true);
+ }
+ return num_deleted;
+}
+
bool CookieMonster::DeleteCookie(const std::string& domain,
const CanonicalCookie& cookie,
bool sync_to_store) {
@@ -911,37 +925,7 @@ CookieMonster::CookieList CookieMonster::GetAllCookies() {
CookieMonster::CookieList CookieMonster::GetAllCookiesForURL(const GURL& url) {
AutoLock autolock(lock_);
InitIfNecessary();
-
- // Do not return removed cookies.
- GarbageCollectExpired(Time::Now(),
- CookieMapItPair(cookies_.begin(), cookies_.end()),
- NULL);
-
- CookieList cookie_list;
- if (!HasCookieableScheme(url))
- return cookie_list;
-
- bool secure = url.SchemeIsSecure();
-
- // Query for the full host, For example: 'a.c.blah.com'.
- std::string key(url.host());
- FindRawCookies(key, secure, url.path(), &cookie_list);
-
- // See if we can search for domain cookies, i.e. if the host has a TLD + 1.
- const std::string domain(GetEffectiveDomain(url.scheme(), key));
- if (domain.empty())
- return cookie_list;
-
- // Use same logic as in FindCookiesForHostAndDomain.
- DCHECK_LE(domain.length(), key.length());
- DCHECK_EQ(0, key.compare(key.length() - domain.length(), domain.length(),
- domain));
- for (key = "." + key; key.length() > domain.length(); ) {
- FindRawCookies(key, secure, url.path(), &cookie_list);
- const size_t next_dot = key.find('.', 1); // Skip over leading dot.
- key.erase(0, next_dot);
- }
- return cookie_list;
+ return InternalGetAllCookiesForURL(url);
}
void CookieMonster::FindCookiesForHostAndDomain(
@@ -1030,6 +1014,39 @@ void CookieMonster::FindRawCookies(const std::string& key,
}
}
+CookieMonster::CookieList CookieMonster::InternalGetAllCookiesForURL(
+ const GURL& url) {
+ // Do not return removed cookies.
+ GarbageCollectExpired(Time::Now(),
+ CookieMapItPair(cookies_.begin(), cookies_.end()),
+ NULL);
+
+ CookieList cookie_list;
+ if (!HasCookieableScheme(url))
+ return cookie_list;
+
+ bool secure = url.SchemeIsSecure();
+
+ // Query for the full host, For example: 'a.c.blah.com'.
+ std::string key(url.host());
+ FindRawCookies(key, secure, url.path(), &cookie_list);
+
+ // See if we can search for domain cookies, i.e. if the host has a TLD + 1.
+ const std::string domain(GetEffectiveDomain(url.scheme(), key));
+ if (domain.empty())
+ return cookie_list;
+
+ // Use same logic as in FindCookiesForHostAndDomain.
+ DCHECK_LE(domain.length(), key.length());
+ DCHECK_EQ(0, key.compare(key.length() - domain.length(), domain.length(),
+ domain));
+ for (key = "." + key; key.length() > domain.length(); ) {
+ FindRawCookies(key, secure, url.path(), &cookie_list);
+ const size_t next_dot = key.find('.', 1); // Skip over leading dot.
+ key.erase(0, next_dot);
+ }
+ return cookie_list;
+}
CookieMonster::ParsedCookie::ParsedCookie(const std::string& cookie_line)
: is_valid_(false),
diff --git a/net/base/cookie_monster.h b/net/base/cookie_monster.h
index ccdae0b..a48c2d3 100644
--- a/net/base/cookie_monster.h
+++ b/net/base/cookie_monster.h
@@ -112,6 +112,9 @@ class CookieMonster : public CookieStore {
// one passed into the function via |delete_after|.
int DeleteAllCreatedAfter(const base::Time& delete_begin, bool sync_to_store);
+ // Delete all cookies that match the given URL.
+ int DeleteAllForURL(const GURL& url, bool sync_to_store);
+
// Delete one specific cookie.
bool DeleteCookie(const std::string& domain,
const CanonicalCookie& cookie,
@@ -176,6 +179,10 @@ class CookieMonster : public CookieStore {
const std::string& path,
CookieList* list);
+ // Internal helper returning all cookies for a given URL. The caller is
+ // assumed to hold lock_ and having called InitIfNecessary().
+ CookieList InternalGetAllCookiesForURL(const GURL& url);
+
// Delete any cookies that are equivalent to |ecc| (same path, key, etc).
// If |skip_httponly| is true, httponly cookies will not be deleted. The
// return value with be true if |skip_httponly| skipped an httponly cookie.