Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(311)

Side by Side Diff: net/cookies/canonical_cookie.cc

Issue 11308272: Add IncludeForRequestURL method to CanonicalCookie (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: " Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/cookies/canonical_cookie.h ('k') | net/cookies/canonical_cookie_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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::IncludeForRequestURL(const GURL& url,
375 const CookieOptions& options) const {
376 // Filter out HttpOnly cookies, per options.
377 if (options.exclude_httponly() && IsHttpOnly())
378 return false;
379 // Secure cookies should not be included in requests for URLs with an
380 // insecure scheme.
381 if (IsSecure() && !url.SchemeIsSecure())
382 return false;
383 // Don't include cookies for requests that don't apply to the cookie domain.
384 if (!IsDomainMatch(url.host()))
385 return false;
386 // Don't include cookies for requests with a url path that does not path
387 // match the cookie-path.
388 if (!IsOnPath(url.path()))
389 return false;
390
391 return true;
392 }
393
374 std::string CanonicalCookie::DebugString() const { 394 std::string CanonicalCookie::DebugString() const {
375 return base::StringPrintf( 395 return base::StringPrintf(
376 "name: %s value: %s domain: %s path: %s creation: %" 396 "name: %s value: %s domain: %s path: %s creation: %"
377 PRId64, 397 PRId64,
378 name_.c_str(), value_.c_str(), 398 name_.c_str(), value_.c_str(),
379 domain_.c_str(), path_.c_str(), 399 domain_.c_str(), path_.c_str(),
380 static_cast<int64>(creation_date_.ToTimeT())); 400 static_cast<int64>(creation_date_.ToTimeT()));
381 } 401 }
382 402
383 } // namespace net 403 } // namespace net
OLDNEW
« no previous file with comments | « net/cookies/canonical_cookie.h ('k') | net/cookies/canonical_cookie_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698