| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 |
| 11 * 1.1 (the "License"); you may not use this file except in compliance with | 11 * 1.1 (the "License"); you may not use this file except in compliance with |
| (...skipping 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1128 for (PairList::const_iterator it = pairs_.begin(); | 1128 for (PairList::const_iterator it = pairs_.begin(); |
| 1129 it != pairs_.end(); ++it) { | 1129 it != pairs_.end(); ++it) { |
| 1130 out.append(it->first); | 1130 out.append(it->first); |
| 1131 out.append("="); | 1131 out.append("="); |
| 1132 out.append(it->second); | 1132 out.append(it->second); |
| 1133 out.append("; "); | 1133 out.append("; "); |
| 1134 } | 1134 } |
| 1135 return out; | 1135 return out; |
| 1136 } | 1136 } |
| 1137 | 1137 |
| 1138 CookieMonster::CanonicalCookie::CanonicalCookie(const GURL& url, |
| 1139 const ParsedCookie& pc) |
| 1140 : name_(pc.Name()), |
| 1141 value_(pc.Value()), |
| 1142 path_(CanonPath(url, pc)), |
| 1143 creation_date_(Time::Now()), |
| 1144 last_access_date_(Time()), |
| 1145 has_expires_(pc.HasExpires()), |
| 1146 secure_(pc.IsSecure()), |
| 1147 httponly_(pc.IsHttpOnly()) { |
| 1148 if (has_expires_) |
| 1149 expiry_date_ = CanonExpiration(pc, creation_date_, CookieOptions()); |
| 1150 } |
| 1151 |
| 1138 bool CookieMonster::CanonicalCookie::IsOnPath( | 1152 bool CookieMonster::CanonicalCookie::IsOnPath( |
| 1139 const std::string& url_path) const { | 1153 const std::string& url_path) const { |
| 1140 | 1154 |
| 1141 // A zero length would be unsafe for our trailing '/' checks, and | 1155 // A zero length would be unsafe for our trailing '/' checks, and |
| 1142 // would also make no sense for our prefix match. The code that | 1156 // would also make no sense for our prefix match. The code that |
| 1143 // creates a CanonicalCookie should make sure the path is never zero length, | 1157 // creates a CanonicalCookie should make sure the path is never zero length, |
| 1144 // but we double check anyway. | 1158 // but we double check anyway. |
| 1145 if (path_.empty()) | 1159 if (path_.empty()) |
| 1146 return false; | 1160 return false; |
| 1147 | 1161 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1171 return true; | 1185 return true; |
| 1172 } | 1186 } |
| 1173 | 1187 |
| 1174 std::string CookieMonster::CanonicalCookie::DebugString() const { | 1188 std::string CookieMonster::CanonicalCookie::DebugString() const { |
| 1175 return StringPrintf("name: %s value: %s path: %s creation: %" PRId64, | 1189 return StringPrintf("name: %s value: %s path: %s creation: %" PRId64, |
| 1176 name_.c_str(), value_.c_str(), path_.c_str(), | 1190 name_.c_str(), value_.c_str(), path_.c_str(), |
| 1177 static_cast<int64>(creation_date_.ToTimeT())); | 1191 static_cast<int64>(creation_date_.ToTimeT())); |
| 1178 } | 1192 } |
| 1179 | 1193 |
| 1180 } // namespace | 1194 } // namespace |
| OLD | NEW |