| 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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 | 179 |
| 180 CanonicalCookie::~CanonicalCookie() { | 180 CanonicalCookie::~CanonicalCookie() { |
| 181 } | 181 } |
| 182 | 182 |
| 183 std::string CanonicalCookie::GetCookieSourceFromURL(const GURL& url) { | 183 std::string CanonicalCookie::GetCookieSourceFromURL(const GURL& url) { |
| 184 if (url.SchemeIsFile()) | 184 if (url.SchemeIsFile()) |
| 185 return url.spec(); | 185 return url.spec(); |
| 186 | 186 |
| 187 url::Replacements<char> replacements; | 187 url::Replacements<char> replacements; |
| 188 replacements.ClearPort(); | 188 replacements.ClearPort(); |
| 189 if (url.SchemeIsSecure()) | 189 if (url.SchemeIsCryptographic()) |
| 190 replacements.SetScheme("http", url::Component(0, 4)); | 190 replacements.SetScheme("http", url::Component(0, 4)); |
| 191 | 191 |
| 192 return url.GetOrigin().ReplaceComponents(replacements).spec(); | 192 return url.GetOrigin().ReplaceComponents(replacements).spec(); |
| 193 } | 193 } |
| 194 | 194 |
| 195 // static | 195 // static |
| 196 std::string CanonicalCookie::CanonPath(const GURL& url, | 196 std::string CanonicalCookie::CanonPath(const GURL& url, |
| 197 const ParsedCookie& pc) { | 197 const ParsedCookie& pc) { |
| 198 std::string path_string; | 198 std::string path_string; |
| 199 if (pc.HasPath()) | 199 if (pc.HasPath()) |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 domain_.length(), domain_) == 0); | 387 domain_.length(), domain_) == 0); |
| 388 } | 388 } |
| 389 | 389 |
| 390 bool CanonicalCookie::IncludeForRequestURL(const GURL& url, | 390 bool CanonicalCookie::IncludeForRequestURL(const GURL& url, |
| 391 const CookieOptions& options) const { | 391 const CookieOptions& options) const { |
| 392 // Filter out HttpOnly cookies, per options. | 392 // Filter out HttpOnly cookies, per options. |
| 393 if (options.exclude_httponly() && IsHttpOnly()) | 393 if (options.exclude_httponly() && IsHttpOnly()) |
| 394 return false; | 394 return false; |
| 395 // Secure cookies should not be included in requests for URLs with an | 395 // Secure cookies should not be included in requests for URLs with an |
| 396 // insecure scheme. | 396 // insecure scheme. |
| 397 if (IsSecure() && !url.SchemeIsSecure()) | 397 if (IsSecure() && !url.SchemeIsCryptographic()) |
| 398 return false; | 398 return false; |
| 399 // Don't include cookies for requests that don't apply to the cookie domain. | 399 // Don't include cookies for requests that don't apply to the cookie domain. |
| 400 if (!IsDomainMatch(url.host())) | 400 if (!IsDomainMatch(url.host())) |
| 401 return false; | 401 return false; |
| 402 // Don't include cookies for requests with a url path that does not path | 402 // Don't include cookies for requests with a url path that does not path |
| 403 // match the cookie-path. | 403 // match the cookie-path. |
| 404 if (!IsOnPath(url.path())) | 404 if (!IsOnPath(url.path())) |
| 405 return false; | 405 return false; |
| 406 | 406 |
| 407 // Include first-party-only cookies iff |options| tells us to include all of | 407 // Include first-party-only cookies iff |options| tells us to include all of |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 if (IsSecure() != other.IsSecure()) | 453 if (IsSecure() != other.IsSecure()) |
| 454 return IsSecure(); | 454 return IsSecure(); |
| 455 | 455 |
| 456 if (IsHttpOnly() != other.IsHttpOnly()) | 456 if (IsHttpOnly() != other.IsHttpOnly()) |
| 457 return IsHttpOnly(); | 457 return IsHttpOnly(); |
| 458 | 458 |
| 459 return Priority() < other.Priority(); | 459 return Priority() < other.Priority(); |
| 460 } | 460 } |
| 461 | 461 |
| 462 } // namespace net | 462 } // namespace net |
| OLD | NEW |