| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Portions of this code based on Mozilla: | 5 // Portions of this code based on Mozilla: |
| 6 // (netwerk/cookie/src/nsCookieService.cpp) | 6 // (netwerk/cookie/src/nsCookieService.cpp) |
| 7 /* ***** BEGIN LICENSE BLOCK ***** | 7 /* ***** BEGIN LICENSE BLOCK ***** |
| 8 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | 8 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
| 9 * | 9 * |
| 10 * The contents of this file are subject to the Mozilla Public License Version | 10 * The contents of this file are subject to the Mozilla Public License Version |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 | 172 |
| 173 ParseTokenValuePairs(cookie_line); | 173 ParseTokenValuePairs(cookie_line); |
| 174 if (!pairs_.empty()) | 174 if (!pairs_.empty()) |
| 175 SetupAttributes(); | 175 SetupAttributes(); |
| 176 } | 176 } |
| 177 | 177 |
| 178 ParsedCookie::~ParsedCookie() { | 178 ParsedCookie::~ParsedCookie() { |
| 179 } | 179 } |
| 180 | 180 |
| 181 bool ParsedCookie::IsValid() const { | 181 bool ParsedCookie::IsValid() const { |
| 182 return !pairs_.empty(); | 182 return !pairs_.empty() && IsSameSiteAttributeValid(); |
| 183 } | 183 } |
| 184 | 184 |
| 185 CookieSameSite ParsedCookie::SameSite() const { | 185 CookieSameSite ParsedCookie::SameSite() const { |
| 186 return (same_site_index_ == 0) | 186 return (same_site_index_ == 0) |
| 187 ? CookieSameSite::DEFAULT_MODE | 187 ? CookieSameSite::DEFAULT_MODE |
| 188 : StringToCookieSameSite(pairs_[same_site_index_].second); | 188 : StringToCookieSameSite(pairs_[same_site_index_].second); |
| 189 } | 189 } |
| 190 | 190 |
| 191 CookiePriority ParsedCookie::Priority() const { | 191 CookiePriority ParsedCookie::Priority() const { |
| 192 return (priority_index_ == 0) | 192 return (priority_index_ == 0) |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 &same_site_index_, &priority_index_}; | 499 &same_site_index_, &priority_index_}; |
| 500 for (size_t i = 0; i < arraysize(indexes); ++i) { | 500 for (size_t i = 0; i < arraysize(indexes); ++i) { |
| 501 if (*indexes[i] == index) | 501 if (*indexes[i] == index) |
| 502 *indexes[i] = 0; | 502 *indexes[i] = 0; |
| 503 else if (*indexes[i] > index) | 503 else if (*indexes[i] > index) |
| 504 --*indexes[i]; | 504 --*indexes[i]; |
| 505 } | 505 } |
| 506 pairs_.erase(pairs_.begin() + index); | 506 pairs_.erase(pairs_.begin() + index); |
| 507 } | 507 } |
| 508 | 508 |
| 509 bool ParsedCookie::IsSameSiteAttributeValid() const { |
| 510 return same_site_index_ == 0 || SameSite() != CookieSameSite::DEFAULT_MODE; |
| 511 } |
| 512 |
| 509 } // namespace | 513 } // namespace |
| OLD | NEW |