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

Unified Diff: net/cookies/cookie_monster.h

Issue 2882063002: Add a SetCanonicalCookie method for CookieMonster. (Closed)
Patch Set: Fix try jobs and do some cleanup. Created 3 years, 7 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.h
diff --git a/net/cookies/cookie_monster.h b/net/cookies/cookie_monster.h
index ff7c47f8b0a419348981c886ed2da9414d46ad0e..cfcc22a308141e6b71f3248116e1e5d59a25eec7 100644
--- a/net/cookies/cookie_monster.h
+++ b/net/cookies/cookie_monster.h
@@ -166,6 +166,10 @@ class NET_EXPORT CookieMonster : public CookieStore {
CookieSameSite same_site,
CookiePriority priority,
const SetCookiesCallback& callback) override;
+ void SetCanonicalCookieAsync(const CanonicalCookie& cookie,
+ bool secure_source,
+ bool modify_http_only,
+ const SetCookiesCallback& callback) override;
void GetCookiesWithOptionsAsync(const GURL& url,
const CookieOptions& options,
const GetCookiesCallback& callback) override;
@@ -232,6 +236,7 @@ class NET_EXPORT CookieMonster : public CookieStore {
class SetAllCookiesTask;
class SetCookieWithDetailsTask;
class SetCookieWithOptionsTask;
+ class SetCanonicalCookieTask;
class DeleteSessionCookiesTask;
// Testing support.
@@ -425,6 +430,15 @@ class NET_EXPORT CookieMonster : public CookieStore {
const base::Time& delete_end,
const base::Callback<bool(const CanonicalCookie&)>& predicate);
+ // Sets a canonical cookie, deletes equivalents and performs garbage
+ // collection. |source_secure| indicates if the cookie is being set
+ // from a secure source (e.g. a cryptographic scheme).
+ // |modify_http_only| indicates if this setting operation is allowed
+ // to affect http_only cookies.
+ bool SetCanonicalCookie(std::unique_ptr<CanonicalCookie> cookie,
+ bool secure_source,
+ bool can_modify_httponly);
+
bool SetCookieWithOptions(const GURL& url,
const std::string& cookie_line,
const CookieOptions& options);
@@ -501,7 +515,8 @@ class NET_EXPORT CookieMonster : public CookieStore {
std::vector<CanonicalCookie*>* cookies);
// Delete any cookies that are equivalent to |ecc| (same path, domain, etc).
- // |source_url| is the URL that is attempting to set the cookie.
+ // |source_secure| indicates if the source may override existing secure
+ // cookies.
// If |skip_httponly| is true, httponly cookies will not be deleted. The
// return value will be true if |skip_httponly| skipped an httponly cookie or
// the cookie to delete was Secure and the scheme of |ecc| is insecure. |key|
@@ -510,15 +525,17 @@ class NET_EXPORT CookieMonster : public CookieStore {
// NOTE: There should never be more than a single matching equivalent cookie.
bool DeleteAnyEquivalentCookie(const std::string& key,
const CanonicalCookie& ecc,
- const GURL& source_url,
+ bool source_secure,
bool skip_httponly,
bool already_expired);
// Inserts |cc| into cookies_. Returns an iterator that points to the inserted
// cookie in cookies_. Guarantee: all iterators to cookies_ remain valid.
+ // |secure_source| indicates if the setting of the canonical cookie is
+ // coming from a secure source (e.g. a cryptographically schemed URL).
CookieMap::iterator InternalInsertCookie(const std::string& key,
std::unique_ptr<CanonicalCookie> cc,
- const GURL& source_url,
+ bool source_secure,
bool sync_to_store);
// Helper function that sets cookies with more control.
@@ -529,15 +546,9 @@ class NET_EXPORT CookieMonster : public CookieStore {
const base::Time& creation_time,
const CookieOptions& options);
- // Helper function that sets a canonical cookie, deleting equivalents and
- // performing garbage collection.
- // |source_url| is the URL that's attempting to set the cookie.
- bool SetCanonicalCookie(std::unique_ptr<CanonicalCookie> cc,
- const GURL& source_url,
- const CookieOptions& options);
-
- // Helper function calling SetCanonicalCookie() for all cookies in |list|.
- bool SetCanonicalCookies(const CookieList& list);
+ // Helper function calling SetCanonicalCookieInternal() for all
+ // cookies in |list|.
+ bool SetCanonicalCookiesInternal(const CookieList& list);
void InternalUpdateCookieAccessTime(CanonicalCookie* cc,
const base::Time& current_time);

Powered by Google App Engine
This is Rietveld 408576698