| 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 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 if (domain_.compare(1, std::string::npos, host) == 0) | 364 if (domain_.compare(1, std::string::npos, host) == 0) |
| 365 return true; | 365 return true; |
| 366 | 366 |
| 367 // A pure suffix of the host (ok since we know the domain already | 367 // A pure suffix of the host (ok since we know the domain already |
| 368 // starts with a ".") | 368 // starts with a ".") |
| 369 return (host.length() > domain_.length() && | 369 return (host.length() > domain_.length() && |
| 370 host.compare(host.length() - domain_.length(), | 370 host.compare(host.length() - domain_.length(), |
| 371 domain_.length(), domain_) == 0); | 371 domain_.length(), domain_) == 0); |
| 372 } | 372 } |
| 373 | 373 |
| 374 bool CanonicalCookie::IncludeForRequest(const GURL& url) const { |
| 375 // Secure cookies should not be included in requests for URLs with an |
| 376 // unsecure scheme. |
| 377 if (IsSecure() && !url.SchemeIsSecure()) |
| 378 return false; |
| 379 // Don't include cookies for requests that don't apply to the cookie domain. |
| 380 if (!IsDomainMatch(url.host())) |
| 381 return false; |
| 382 // Don't include cookies for requests that |
| 383 if (!IsOnPath(url.path())) |
| 384 return false; |
| 385 |
| 386 return true; |
| 387 } |
| 388 |
| 374 std::string CanonicalCookie::DebugString() const { | 389 std::string CanonicalCookie::DebugString() const { |
| 375 return base::StringPrintf( | 390 return base::StringPrintf( |
| 376 "name: %s value: %s domain: %s path: %s creation: %" | 391 "name: %s value: %s domain: %s path: %s creation: %" |
| 377 PRId64, | 392 PRId64, |
| 378 name_.c_str(), value_.c_str(), | 393 name_.c_str(), value_.c_str(), |
| 379 domain_.c_str(), path_.c_str(), | 394 domain_.c_str(), path_.c_str(), |
| 380 static_cast<int64>(creation_date_.ToTimeT())); | 395 static_cast<int64>(creation_date_.ToTimeT())); |
| 381 } | 396 } |
| 382 | 397 |
| 383 } // namespace net | 398 } // namespace net |
| OLD | NEW |