OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 29 matching lines...) Expand all Loading... |
40 * the provisions above, a recipient may use your version of this file under | 40 * the provisions above, a recipient may use your version of this file under |
41 * the terms of any one of the MPL, the GPL or the LGPL. | 41 * the terms of any one of the MPL, the GPL or the LGPL. |
42 * | 42 * |
43 * ***** END LICENSE BLOCK ***** */ | 43 * ***** END LICENSE BLOCK ***** */ |
44 | 44 |
45 #include "net/base/cookie_monster.h" | 45 #include "net/base/cookie_monster.h" |
46 | 46 |
47 #include <algorithm> | 47 #include <algorithm> |
48 | 48 |
49 #include "base/basictypes.h" | 49 #include "base/basictypes.h" |
| 50 #include "base/format_macros.h" |
50 #include "base/logging.h" | 51 #include "base/logging.h" |
51 #include "base/scoped_ptr.h" | 52 #include "base/scoped_ptr.h" |
52 #include "base/string_tokenizer.h" | 53 #include "base/string_tokenizer.h" |
53 #include "base/string_util.h" | 54 #include "base/string_util.h" |
54 #include "googleurl/src/gurl.h" | 55 #include "googleurl/src/gurl.h" |
55 #include "net/base/net_util.h" | 56 #include "net/base/net_util.h" |
56 #include "net/base/registry_controlled_domain.h" | 57 #include "net/base/registry_controlled_domain.h" |
57 | 58 |
58 // #define COOKIE_LOGGING_ENABLED | 59 // #define COOKIE_LOGGING_ENABLED |
59 #ifdef COOKIE_LOGGING_ENABLED | 60 #ifdef COOKIE_LOGGING_ENABLED |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 | 345 |
345 // Return up to the rightmost '/'. | 346 // Return up to the rightmost '/'. |
346 return url_path.substr(0, idx); | 347 return url_path.substr(0, idx); |
347 } | 348 } |
348 | 349 |
349 static Time CanonExpiration(const CookieMonster::ParsedCookie& pc, | 350 static Time CanonExpiration(const CookieMonster::ParsedCookie& pc, |
350 const Time& current) { | 351 const Time& current) { |
351 // First, try the Max-Age attribute. | 352 // First, try the Max-Age attribute. |
352 uint64 max_age = 0; | 353 uint64 max_age = 0; |
353 if (pc.HasMaxAge() && | 354 if (pc.HasMaxAge() && |
354 #if defined(COMPILER_MSVC) | 355 #ifdef COMPILER_MSVC |
355 sscanf_s(pc.MaxAge().c_str(), " %I64u", &max_age) == 1) { | 356 sscanf_s( |
356 | |
357 #else | 357 #else |
358 sscanf(pc.MaxAge().c_str(), " %llu", &max_age) == 1) { | 358 sscanf( |
359 #endif | 359 #endif |
| 360 pc.MaxAge().c_str(), " %" PRIu64, &max_age) == 1) { |
360 return current + TimeDelta::FromSeconds(max_age); | 361 return current + TimeDelta::FromSeconds(max_age); |
361 } | 362 } |
362 | 363 |
363 // Try the Expires attribute. | 364 // Try the Expires attribute. |
364 if (pc.HasExpires()) | 365 if (pc.HasExpires()) |
365 return CookieMonster::ParseCookieTime(pc.Expires()); | 366 return CookieMonster::ParseCookieTime(pc.Expires()); |
366 | 367 |
367 // Invalid or no expiration, persistent cookie. | 368 // Invalid or no expiration, persistent cookie. |
368 return Time(); | 369 return Time(); |
369 } | 370 } |
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1123 return true; | 1124 return true; |
1124 } | 1125 } |
1125 | 1126 |
1126 std::string CookieMonster::CanonicalCookie::DebugString() const { | 1127 std::string CookieMonster::CanonicalCookie::DebugString() const { |
1127 return StringPrintf("name: %s value: %s path: %s creation: %llu", | 1128 return StringPrintf("name: %s value: %s path: %s creation: %llu", |
1128 name_.c_str(), value_.c_str(), path_.c_str(), | 1129 name_.c_str(), value_.c_str(), path_.c_str(), |
1129 creation_date_.ToTimeT()); | 1130 creation_date_.ToTimeT()); |
1130 } | 1131 } |
1131 | 1132 |
1132 } // namespace | 1133 } // namespace |
OLD | NEW |