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

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: FirstPartyOnly. 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
« no previous file with comments | « net/cookies/parsed_cookie.h ('k') | net/cookies/parsed_cookie_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/cookies/parsed_cookie.cc
diff --git a/net/cookies/parsed_cookie.cc b/net/cookies/parsed_cookie.cc
index 8cbca5c529363fdf30db8fe67d16caedc5778132..30afe10870dc0ca180a7c74172aea866f4abdc14 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 kFirstPartyOnlyTokenName[] = "first-party-only";
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),
+ firstpartyonly_index_(0),
priority_index_(0) {
if (cookie_line.size() > kMaxCookieSize) {
VLOG(1) << "Not parsing cookie, too large: " << cookie_line.size();
@@ -228,6 +230,11 @@ bool ParsedCookie::SetIsHttpOnly(bool is_http_only) {
return SetBool(&httponly_index_, kHttpOnlyTokenName, is_http_only);
}
+bool ParsedCookie::SetIsFirstPartyOnly(bool is_first_party_only) {
+ return SetBool(&firstpartyonly_index_, kFirstPartyOnlyTokenName,
+ is_first_party_only);
+}
+
bool ParsedCookie::SetPriority(const std::string& priority) {
return SetString(&priority_index_, kPriorityTokenName, priority);
}
@@ -238,7 +245,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 != kFirstPartyOnlyTokenName) {
out.append("=");
out.append(it->second);
}
@@ -429,6 +437,8 @@ void ParsedCookie::SetupAttributes() {
secure_index_ = i;
} else if (pairs_[i].first == kHttpOnlyTokenName) {
httponly_index_ = i;
+ } else if (pairs_[i].first == kFirstPartyOnlyTokenName) {
+ firstpartyonly_index_ = i;
} else if (pairs_[i].first == kPriorityTokenName) {
priority_index_ = i;
} else {
@@ -486,6 +496,7 @@ void ParsedCookie::ClearAttributePair(size_t index) {
&maxage_index_,
&secure_index_,
&httponly_index_,
+ &firstpartyonly_index_,
&priority_index_};
for (size_t i = 0; i < arraysize(indexes); ++i) {
if (*indexes[i] == index)
« no previous file with comments | « net/cookies/parsed_cookie.h ('k') | net/cookies/parsed_cookie_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698