OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 2134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2145 #if defined(ENABLE_PERSISTENT_SESSION_COOKIES) | 2145 #if defined(ENABLE_PERSISTENT_SESSION_COOKIES) |
2146 // Mobile apps can sometimes be shut down without any warning, so the session | 2146 // Mobile apps can sometimes be shut down without any warning, so the session |
2147 // cookie has to be persistent and given a default expiration time. | 2147 // cookie has to be persistent and given a default expiration time. |
2148 expiry_date_ = base::Time::Now() + | 2148 expiry_date_ = base::Time::Now() + |
2149 base::TimeDelta::FromDays(kPersistentSessionCookieExpiryInDays); | 2149 base::TimeDelta::FromDays(kPersistentSessionCookieExpiryInDays); |
2150 has_expires_ = true; | 2150 has_expires_ = true; |
2151 #endif | 2151 #endif |
2152 } | 2152 } |
2153 | 2153 |
2154 CookieMonster::CanonicalCookie* CookieMonster::CanonicalCookie::Create( | 2154 CookieMonster::CanonicalCookie* CookieMonster::CanonicalCookie::Create( |
| 2155 const GURL& url, |
| 2156 const ParsedCookie& pc) { |
| 2157 if (!pc.IsValid()) { |
| 2158 return NULL; |
| 2159 } |
| 2160 |
| 2161 std::string domain_string; |
| 2162 if (!GetCookieDomain(url, pc, &domain_string)) { |
| 2163 return NULL; |
| 2164 } |
| 2165 std::string path_string = CanonPath(url, pc);; |
| 2166 std::string mac_key = pc.HasMACKey() ? pc.MACKey() : std::string(); |
| 2167 std::string mac_algorithm = pc.HasMACAlgorithm() ? |
| 2168 pc.MACAlgorithm() : std::string(); |
| 2169 Time creation_time = Time::Now(); |
| 2170 Time expiration_time; |
| 2171 if (pc.HasExpires()) |
| 2172 expiration_time = net::CookieMonster::ParseCookieTime(pc.Expires()); |
| 2173 |
| 2174 return (Create(url, pc.Name(), pc.Value(), domain_string, path_string, |
| 2175 mac_key, mac_algorithm, creation_time, expiration_time, |
| 2176 pc.IsSecure(), pc.IsHttpOnly())); |
| 2177 } |
| 2178 |
| 2179 CookieMonster::CanonicalCookie* CookieMonster::CanonicalCookie::Create( |
2155 const GURL& url, | 2180 const GURL& url, |
2156 const std::string& name, | 2181 const std::string& name, |
2157 const std::string& value, | 2182 const std::string& value, |
2158 const std::string& domain, | 2183 const std::string& domain, |
2159 const std::string& path, | 2184 const std::string& path, |
2160 const std::string& mac_key, | 2185 const std::string& mac_key, |
2161 const std::string& mac_algorithm, | 2186 const std::string& mac_algorithm, |
2162 const base::Time& creation, | 2187 const base::Time& creation, |
2163 const base::Time& expiration, | 2188 const base::Time& expiration, |
2164 bool secure, | 2189 bool secure, |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2276 std::string CookieMonster::CanonicalCookie::DebugString() const { | 2301 std::string CookieMonster::CanonicalCookie::DebugString() const { |
2277 return base::StringPrintf( | 2302 return base::StringPrintf( |
2278 "name: %s value: %s domain: %s path: %s creation: %" | 2303 "name: %s value: %s domain: %s path: %s creation: %" |
2279 PRId64, | 2304 PRId64, |
2280 name_.c_str(), value_.c_str(), | 2305 name_.c_str(), value_.c_str(), |
2281 domain_.c_str(), path_.c_str(), | 2306 domain_.c_str(), path_.c_str(), |
2282 static_cast<int64>(creation_date_.ToTimeT())); | 2307 static_cast<int64>(creation_date_.ToTimeT())); |
2283 } | 2308 } |
2284 | 2309 |
2285 } // namespace | 2310 } // namespace |
OLD | NEW |