| 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 std::string domain_string; | |
| 2158 if (pc.HasDomain()) | |
| 2159 domain_string = pc.Domain(); | |
| 2160 std::string path_string; | |
| 2161 if (pc.HasPath()) | |
| 2162 path_string = pc.Path(); | |
| 2163 std::string mac_key = pc.HasMACKey() ? pc.MACKey() : std::string(); | |
| 2164 std::string mac_algorithm = pc.HasMACAlgorithm() ? | |
| 2165 pc.MACAlgorithm() : std::string(); | |
| 2166 Time creation_time = Time::Now(); | |
| 2167 Time expiration_time; | |
| 2168 if (pc.HasExpires()) | |
| 2169 expiration_time = net::CookieMonster::ParseCookieTime(pc.Expires()); | |
| 2170 | |
| 2171 return (Create(url, pc.Name(), pc.Value(), domain_string, path_string, | |
| 2172 mac_key, mac_algorithm, creation_time, expiration_time, | |
| 2173 pc.IsSecure(), pc.IsHttpOnly())); | |
| 2174 } | |
| 2175 | |
| 2176 CookieMonster::CanonicalCookie* CookieMonster::CanonicalCookie::Create( | |
| 2177 const GURL& url, | 2155 const GURL& url, |
| 2178 const std::string& name, | 2156 const std::string& name, |
| 2179 const std::string& value, | 2157 const std::string& value, |
| 2180 const std::string& domain, | 2158 const std::string& domain, |
| 2181 const std::string& path, | 2159 const std::string& path, |
| 2182 const std::string& mac_key, | 2160 const std::string& mac_key, |
| 2183 const std::string& mac_algorithm, | 2161 const std::string& mac_algorithm, |
| 2184 const base::Time& creation, | 2162 const base::Time& creation, |
| 2185 const base::Time& expiration, | 2163 const base::Time& expiration, |
| 2186 bool secure, | 2164 bool secure, |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2298 std::string CookieMonster::CanonicalCookie::DebugString() const { | 2276 std::string CookieMonster::CanonicalCookie::DebugString() const { |
| 2299 return base::StringPrintf( | 2277 return base::StringPrintf( |
| 2300 "name: %s value: %s domain: %s path: %s creation: %" | 2278 "name: %s value: %s domain: %s path: %s creation: %" |
| 2301 PRId64, | 2279 PRId64, |
| 2302 name_.c_str(), value_.c_str(), | 2280 name_.c_str(), value_.c_str(), |
| 2303 domain_.c_str(), path_.c_str(), | 2281 domain_.c_str(), path_.c_str(), |
| 2304 static_cast<int64>(creation_date_.ToTimeT())); | 2282 static_cast<int64>(creation_date_.ToTimeT())); |
| 2305 } | 2283 } |
| 2306 | 2284 |
| 2307 } // namespace | 2285 } // namespace |
| OLD | NEW |