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 1584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1595 | 1595 |
1596 void CookieMonster::FindCookiesForKey( | 1596 void CookieMonster::FindCookiesForKey( |
1597 const std::string& key, | 1597 const std::string& key, |
1598 const GURL& url, | 1598 const GURL& url, |
1599 const CookieOptions& options, | 1599 const CookieOptions& options, |
1600 const Time& current, | 1600 const Time& current, |
1601 bool update_access_time, | 1601 bool update_access_time, |
1602 std::vector<CanonicalCookie*>* cookies) { | 1602 std::vector<CanonicalCookie*>* cookies) { |
1603 lock_.AssertAcquired(); | 1603 lock_.AssertAcquired(); |
1604 | 1604 |
1605 const std::string host(url.host()); | |
1606 bool secure = url.SchemeIsSecure(); | |
1607 | |
1608 for (CookieMapItPair its = cookies_.equal_range(key); | 1605 for (CookieMapItPair its = cookies_.equal_range(key); |
1609 its.first != its.second; ) { | 1606 its.first != its.second; ) { |
1610 CookieMap::iterator curit = its.first; | 1607 CookieMap::iterator curit = its.first; |
1611 CanonicalCookie* cc = curit->second; | 1608 CanonicalCookie* cc = curit->second; |
1612 ++its.first; | 1609 ++its.first; |
1613 | 1610 |
1614 // If the cookie is expired, delete it. | 1611 // If the cookie is expired, delete it. |
1615 if (cc->IsExpired(current) && !keep_expired_cookies_) { | 1612 if (cc->IsExpired(current) && !keep_expired_cookies_) { |
1616 InternalDeleteCookie(curit, true, DELETE_COOKIE_EXPIRED); | 1613 InternalDeleteCookie(curit, true, DELETE_COOKIE_EXPIRED); |
1617 continue; | 1614 continue; |
1618 } | 1615 } |
1619 | 1616 |
1620 // Filter out HttpOnly cookies, per options. | 1617 // Filter out HttpOnly cookies, per options. |
1621 if (options.exclude_httponly() && cc->IsHttpOnly()) | 1618 if (options.exclude_httponly() && cc->IsHttpOnly()) |
1622 continue; | 1619 continue; |
markusheintz_
2012/11/29 15:16:14
I think I should even move the if above to the new
| |
1623 | 1620 |
1624 // Filter out secure cookies unless we're https. | 1621 // Filter out cookies that should not be included for a request to the |
1625 if (!secure && cc->IsSecure()) | 1622 // given |url|. |
1623 if (!cc->IncludeForRequest(url)) | |
1626 continue; | 1624 continue; |
1627 | 1625 |
1628 // Filter out cookies that don't apply to this domain. | 1626 // Add this cookie to the set of matching cookies. Update the access |
1629 if (!cc->IsDomainMatch(host)) | |
1630 continue; | |
1631 | |
1632 if (!cc->IsOnPath(url.path())) | |
1633 continue; | |
1634 | |
1635 // Add this cookie to the set of matching cookies. Update the access | |
1636 // time if we've been requested to do so. | 1627 // time if we've been requested to do so. |
1637 if (update_access_time) { | 1628 if (update_access_time) { |
1638 InternalUpdateCookieAccessTime(cc, current); | 1629 InternalUpdateCookieAccessTime(cc, current); |
1639 } | 1630 } |
1640 cookies->push_back(cc); | 1631 cookies->push_back(cc); |
1641 } | 1632 } |
1642 } | 1633 } |
1643 | 1634 |
1644 bool CookieMonster::DeleteAnyEquivalentCookie(const std::string& key, | 1635 bool CookieMonster::DeleteAnyEquivalentCookie(const std::string& key, |
1645 const CanonicalCookie& ecc, | 1636 const CanonicalCookie& ecc, |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2113 | 2104 |
2114 // The system resolution is not high enough, so we can have multiple | 2105 // The system resolution is not high enough, so we can have multiple |
2115 // set cookies that result in the same system time. When this happens, we | 2106 // set cookies that result in the same system time. When this happens, we |
2116 // increment by one Time unit. Let's hope computers don't get too fast. | 2107 // increment by one Time unit. Let's hope computers don't get too fast. |
2117 Time CookieMonster::CurrentTime() { | 2108 Time CookieMonster::CurrentTime() { |
2118 return std::max(Time::Now(), | 2109 return std::max(Time::Now(), |
2119 Time::FromInternalValue(last_time_seen_.ToInternalValue() + 1)); | 2110 Time::FromInternalValue(last_time_seen_.ToInternalValue() + 1)); |
2120 } | 2111 } |
2121 | 2112 |
2122 } // namespace net | 2113 } // namespace net |
OLD | NEW |