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 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 // in the url path. Since we know that the url path length is greater | 331 // in the url path. Since we know that the url path length is greater |
332 // than the cookie path length, it's safe to index one byte past. | 332 // than the cookie path length, it's safe to index one byte past. |
333 if (path_.length() != url_path.length() && | 333 if (path_.length() != url_path.length() && |
334 path_[path_.length() - 1] != '/' && | 334 path_[path_.length() - 1] != '/' && |
335 url_path[path_.length()] != '/') | 335 url_path[path_.length()] != '/') |
336 return false; | 336 return false; |
337 | 337 |
338 return true; | 338 return true; |
339 } | 339 } |
340 | 340 |
341 bool CanonicalCookie::IsDomainMatch(const std::string& scheme, | 341 bool CanonicalCookie::IsDomainMatch(const std::string& host) const { |
342 const std::string& host) const { | |
343 // Can domain match in two ways; as a domain cookie (where the cookie | 342 // Can domain match in two ways; as a domain cookie (where the cookie |
344 // domain begins with ".") or as a host cookie (where it doesn't). | 343 // domain begins with ".") or as a host cookie (where it doesn't). |
345 | 344 |
346 // Some consumers of the CookieMonster expect to set cookies on | 345 // Some consumers of the CookieMonster expect to set cookies on |
347 // URLs like http://.strange.url. To retrieve cookies in this instance, | 346 // URLs like http://.strange.url. To retrieve cookies in this instance, |
348 // we allow matching as a host cookie even when the domain_ starts with | 347 // we allow matching as a host cookie even when the domain_ starts with |
349 // a period. | 348 // a period. |
350 if (host == domain_) | 349 if (host == domain_) |
351 return true; | 350 return true; |
352 | 351 |
(...skipping 22 matching lines...) Expand all Loading... |
375 std::string CanonicalCookie::DebugString() const { | 374 std::string CanonicalCookie::DebugString() const { |
376 return base::StringPrintf( | 375 return base::StringPrintf( |
377 "name: %s value: %s domain: %s path: %s creation: %" | 376 "name: %s value: %s domain: %s path: %s creation: %" |
378 PRId64, | 377 PRId64, |
379 name_.c_str(), value_.c_str(), | 378 name_.c_str(), value_.c_str(), |
380 domain_.c_str(), path_.c_str(), | 379 domain_.c_str(), path_.c_str(), |
381 static_cast<int64>(creation_date_.ToTimeT())); | 380 static_cast<int64>(creation_date_.ToTimeT())); |
382 } | 381 } |
383 | 382 |
384 } // namespace net | 383 } // namespace net |
OLD | NEW |