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

Unified Diff: net/cookies/parsed_cookie.cc

Issue 876973003: Implement the "first-party-only" cookie flag. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tiny bug. Created 5 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: net/cookies/parsed_cookie.cc
diff --git a/net/cookies/parsed_cookie.cc b/net/cookies/parsed_cookie.cc
index 8cbca5c529363fdf30db8fe67d16caedc5778132..ba6db5161f3c47381424d7f4a9ffe176f9d55c18 100644
--- a/net/cookies/parsed_cookie.cc
+++ b/net/cookies/parsed_cookie.cc
@@ -55,6 +55,7 @@ const char kExpiresTokenName[] = "expires";
const char kMaxAgeTokenName[] = "max-age";
const char kSecureTokenName[] = "secure";
const char kHttpOnlyTokenName[] = "httponly";
+const char kFirstPartyTokenName[] = "first-party";
const char kPriorityTokenName[] = "priority";
const char kTerminator[] = "\n\r\0";
@@ -162,6 +163,7 @@ ParsedCookie::ParsedCookie(const std::string& cookie_line)
maxage_index_(0),
secure_index_(0),
httponly_index_(0),
+ firstparty_index_(0),
priority_index_(0) {
if (cookie_line.size() > kMaxCookieSize) {
VLOG(1) << "Not parsing cookie, too large: " << cookie_line.size();
@@ -228,6 +230,10 @@ bool ParsedCookie::SetIsHttpOnly(bool is_http_only) {
return SetBool(&httponly_index_, kHttpOnlyTokenName, is_http_only);
}
+bool ParsedCookie::SetIsFirstParty(bool is_first_party) {
+ return SetBool(&firstparty_index_, kFirstPartyTokenName, is_first_party);
+}
+
bool ParsedCookie::SetPriority(const std::string& priority) {
return SetString(&priority_index_, kPriorityTokenName, priority);
}
@@ -238,7 +244,8 @@ std::string ParsedCookie::ToCookieLine() const {
if (!out.empty())
out.append("; ");
out.append(it->first);
- if (it->first != kSecureTokenName && it->first != kHttpOnlyTokenName) {
+ if (it->first != kSecureTokenName && it->first != kHttpOnlyTokenName &&
+ it->first != kFirstPartyTokenName) {
out.append("=");
out.append(it->second);
}
@@ -429,6 +436,8 @@ void ParsedCookie::SetupAttributes() {
secure_index_ = i;
} else if (pairs_[i].first == kHttpOnlyTokenName) {
httponly_index_ = i;
+ } else if (pairs_[i].first == kFirstPartyTokenName) {
+ firstparty_index_ = i;
} else if (pairs_[i].first == kPriorityTokenName) {
priority_index_ = i;
} else {
@@ -486,6 +495,7 @@ void ParsedCookie::ClearAttributePair(size_t index) {
&maxage_index_,
&secure_index_,
&httponly_index_,
+ &firstparty_index_,
&priority_index_};
for (size_t i = 0; i < arraysize(indexes); ++i) {
if (*indexes[i] == index)

Powered by Google App Engine
This is Rietveld 408576698