| 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 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 if (IsSecure() != other.IsSecure()) | 397 if (IsSecure() != other.IsSecure()) |
| 398 return IsSecure(); | 398 return IsSecure(); |
| 399 | 399 |
| 400 if (IsHttpOnly() != other.IsHttpOnly()) | 400 if (IsHttpOnly() != other.IsHttpOnly()) |
| 401 return IsHttpOnly(); | 401 return IsHttpOnly(); |
| 402 | 402 |
| 403 return Priority() < other.Priority(); | 403 return Priority() < other.Priority(); |
| 404 } | 404 } |
| 405 | 405 |
| 406 bool CanonicalCookie::IsCanonical() const { | 406 bool CanonicalCookie::IsCanonical() const { |
| 407 // Not checking domain against ParsedCookie as it may have come purely | 407 // Not checking domain or path against ParsedCookie as it may have |
| 408 // from the URL. | 408 // come purely from the URL. |
| 409 if (ParsedCookie::ParseTokenString(name_) != name_ || | 409 if (ParsedCookie::ParseTokenString(name_) != name_ || |
| 410 ParsedCookie::ParseValueString(value_) != value_ || | 410 ParsedCookie::ParseValueString(value_) != value_ || |
| 411 ParsedCookie::ParseValueString(path_) != path_ || | |
| 412 !ParsedCookie::IsValidCookieAttributeValue(name_) || | 411 !ParsedCookie::IsValidCookieAttributeValue(name_) || |
| 413 !ParsedCookie::IsValidCookieAttributeValue(value_) || | 412 !ParsedCookie::IsValidCookieAttributeValue(value_)) { |
| 414 !ParsedCookie::IsValidCookieAttributeValue(path_)) { | |
| 415 return false; | 413 return false; |
| 416 } | 414 } |
| 417 | 415 |
| 418 if (!last_access_date_.is_null() && creation_date_.is_null()) | 416 if (!last_access_date_.is_null() && creation_date_.is_null()) |
| 419 return false; | 417 return false; |
| 420 | 418 |
| 421 url::CanonHostInfo canon_host_info; | 419 url::CanonHostInfo canon_host_info; |
| 422 std::string canonical_domain(CanonicalizeHost(domain_, &canon_host_info)); | 420 std::string canonical_domain(CanonicalizeHost(domain_, &canon_host_info)); |
| 423 // TODO(rdsmith): This specifically allows for empty domains. The spec | 421 // TODO(rdsmith): This specifically allows for empty domains. The spec |
| 424 // suggests this is invalid (if a domain attribute is empty, the cookie's | 422 // suggests this is invalid (if a domain attribute is empty, the cookie's |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 return true; | 494 return true; |
| 497 } | 495 } |
| 498 | 496 |
| 499 std::string CanonicalCookie::DomainWithoutDot() const { | 497 std::string CanonicalCookie::DomainWithoutDot() const { |
| 500 if (domain_.empty() || domain_[0] != '.') | 498 if (domain_.empty() || domain_[0] != '.') |
| 501 return domain_; | 499 return domain_; |
| 502 return domain_.substr(1); | 500 return domain_.substr(1); |
| 503 } | 501 } |
| 504 | 502 |
| 505 } // namespace net | 503 } // namespace net |
| OLD | NEW |