| 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 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 785 for (std::vector<CanonicalCookie*>::const_iterator it = cookies.begin(); | 785 for (std::vector<CanonicalCookie*>::const_iterator it = cookies.begin(); |
| 786 it != cookies.end(); ++it) | 786 it != cookies.end(); ++it) |
| 787 raw_cookies->push_back(*(*it)); | 787 raw_cookies->push_back(*(*it)); |
| 788 } | 788 } |
| 789 | 789 |
| 790 void CookieMonster::DeleteCookie(const GURL& url, | 790 void CookieMonster::DeleteCookie(const GURL& url, |
| 791 const std::string& cookie_name) { | 791 const std::string& cookie_name) { |
| 792 if (!HasCookieableScheme(url)) | 792 if (!HasCookieableScheme(url)) |
| 793 return; | 793 return; |
| 794 | 794 |
| 795 CookieOptions options; | 795 for (CookieMapItPair its = cookies_.equal_range(url.host()); |
| 796 options.set_include_httponly(); | 796 its.first != its.second; ++its.first) { |
| 797 // Get the cookies for this host and its domain(s). | 797 if (its.first->second->Name() == cookie_name) { |
| 798 std::vector<CanonicalCookie*> cookies; | 798 InternalDeleteCookie(its.first, true); |
| 799 FindCookiesForHostAndDomain(url, options, &cookies); | 799 return; |
| 800 std::set<CanonicalCookie*> matching_cookies; | 800 } |
| 801 | |
| 802 for (std::vector<CanonicalCookie*>::const_iterator it = cookies.begin(); | |
| 803 it != cookies.end(); ++it) { | |
| 804 if ((*it)->Name() != cookie_name) | |
| 805 continue; | |
| 806 if (url.path().find((*it)->Path())) | |
| 807 continue; | |
| 808 matching_cookies.insert(*it); | |
| 809 } | |
| 810 | |
| 811 for (CookieMap::iterator it = cookies_.begin(); it != cookies_.end();) { | |
| 812 CookieMap::iterator curit = it; | |
| 813 ++it; | |
| 814 if (matching_cookies.find(curit->second) != matching_cookies.end()) | |
| 815 InternalDeleteCookie(curit, true); | |
| 816 } | 801 } |
| 817 } | 802 } |
| 818 | 803 |
| 819 CookieMonster::CookieList CookieMonster::GetAllCookies() { | 804 CookieMonster::CookieList CookieMonster::GetAllCookies() { |
| 820 AutoLock autolock(lock_); | 805 AutoLock autolock(lock_); |
| 821 InitIfNecessary(); | 806 InitIfNecessary(); |
| 822 | 807 |
| 823 // This function is being called to scrape the cookie list for management UI | 808 // This function is being called to scrape the cookie list for management UI |
| 824 // or similar. We shouldn't show expired cookies in this list since it will | 809 // or similar. We shouldn't show expired cookies in this list since it will |
| 825 // just be confusing to users, and this function is called rarely enough (and | 810 // just be confusing to users, and this function is called rarely enough (and |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1171 return true; | 1156 return true; |
| 1172 } | 1157 } |
| 1173 | 1158 |
| 1174 std::string CookieMonster::CanonicalCookie::DebugString() const { | 1159 std::string CookieMonster::CanonicalCookie::DebugString() const { |
| 1175 return StringPrintf("name: %s value: %s path: %s creation: %llu", | 1160 return StringPrintf("name: %s value: %s path: %s creation: %llu", |
| 1176 name_.c_str(), value_.c_str(), path_.c_str(), | 1161 name_.c_str(), value_.c_str(), path_.c_str(), |
| 1177 creation_date_.ToTimeT()); | 1162 creation_date_.ToTimeT()); |
| 1178 } | 1163 } |
| 1179 | 1164 |
| 1180 } // namespace | 1165 } // namespace |
| OLD | NEW |