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 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 return IsHttpOnly(); | 473 return IsHttpOnly(); |
474 | 474 |
475 return Priority() < other.Priority(); | 475 return Priority() < other.Priority(); |
476 } | 476 } |
477 | 477 |
478 // static | 478 // static |
479 CanonicalCookie::CookiePrefix CanonicalCookie::GetCookiePrefix( | 479 CanonicalCookie::CookiePrefix CanonicalCookie::GetCookiePrefix( |
480 const std::string& name) { | 480 const std::string& name) { |
481 const char kSecurePrefix[] = "__Secure-"; | 481 const char kSecurePrefix[] = "__Secure-"; |
482 const char kHostPrefix[] = "__Host-"; | 482 const char kHostPrefix[] = "__Host-"; |
483 if (base::StartsWith(name, kSecurePrefix, base::CompareCase::SENSITIVE)) | 483 if (name.find(kSecurePrefix) == 0) |
484 return CanonicalCookie::COOKIE_PREFIX_SECURE; | 484 return CanonicalCookie::COOKIE_PREFIX_SECURE; |
485 if (base::StartsWith(name, kHostPrefix, base::CompareCase::SENSITIVE)) | 485 if (name.find(kHostPrefix) == 0) |
486 return CanonicalCookie::COOKIE_PREFIX_HOST; | 486 return CanonicalCookie::COOKIE_PREFIX_HOST; |
487 return CanonicalCookie::COOKIE_PREFIX_NONE; | 487 return CanonicalCookie::COOKIE_PREFIX_NONE; |
488 } | 488 } |
489 | 489 |
490 // static | 490 // static |
491 void CanonicalCookie::RecordCookiePrefixMetrics( | 491 void CanonicalCookie::RecordCookiePrefixMetrics( |
492 CanonicalCookie::CookiePrefix prefix, | 492 CanonicalCookie::CookiePrefix prefix, |
493 bool is_cookie_valid) { | 493 bool is_cookie_valid) { |
494 const char kCookiePrefixHistogram[] = "Cookie.CookiePrefix"; | 494 const char kCookiePrefixHistogram[] = "Cookie.CookiePrefix"; |
495 const char kCookiePrefixBlockedHistogram[] = "Cookie.CookiePrefixBlocked"; | 495 const char kCookiePrefixBlockedHistogram[] = "Cookie.CookiePrefixBlocked"; |
(...skipping 16 matching lines...) Expand all Loading... |
512 if (prefix == CanonicalCookie::COOKIE_PREFIX_SECURE) | 512 if (prefix == CanonicalCookie::COOKIE_PREFIX_SECURE) |
513 return parsed_cookie.IsSecure() && url.SchemeIsCryptographic(); | 513 return parsed_cookie.IsSecure() && url.SchemeIsCryptographic(); |
514 if (prefix == CanonicalCookie::COOKIE_PREFIX_HOST) { | 514 if (prefix == CanonicalCookie::COOKIE_PREFIX_HOST) { |
515 return parsed_cookie.IsSecure() && url.SchemeIsCryptographic() && | 515 return parsed_cookie.IsSecure() && url.SchemeIsCryptographic() && |
516 !parsed_cookie.HasDomain() && parsed_cookie.Path() == "/"; | 516 !parsed_cookie.HasDomain() && parsed_cookie.Path() == "/"; |
517 } | 517 } |
518 return true; | 518 return true; |
519 } | 519 } |
520 | 520 |
521 } // namespace net | 521 } // namespace net |
OLD | NEW |