| 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 1026 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1037 secure, http_only, same_site, enforce_strict_secure, priority)); | 1037 secure, http_only, same_site, enforce_strict_secure, priority)); |
| 1038 | 1038 |
| 1039 if (!cc.get()) | 1039 if (!cc.get()) |
| 1040 return false; | 1040 return false; |
| 1041 | 1041 |
| 1042 if (!last_access_time.is_null()) | 1042 if (!last_access_time.is_null()) |
| 1043 cc->SetLastAccessDate(last_access_time); | 1043 cc->SetLastAccessDate(last_access_time); |
| 1044 | 1044 |
| 1045 CookieOptions options; | 1045 CookieOptions options; |
| 1046 options.set_include_httponly(); | 1046 options.set_include_httponly(); |
| 1047 options.set_include_same_site(); | 1047 options.set_same_site_cookie_mode( |
| 1048 CookieOptions::SameSiteCookieMode::INCLUDE_STRICT_AND_LAX); |
| 1048 if (enforce_strict_secure) | 1049 if (enforce_strict_secure) |
| 1049 options.set_enforce_strict_secure(); | 1050 options.set_enforce_strict_secure(); |
| 1050 return SetCanonicalCookie(std::move(cc), options); | 1051 return SetCanonicalCookie(std::move(cc), options); |
| 1051 } | 1052 } |
| 1052 | 1053 |
| 1053 CookieList CookieMonster::GetAllCookies() { | 1054 CookieList CookieMonster::GetAllCookies() { |
| 1054 DCHECK(thread_checker_.CalledOnValidThread()); | 1055 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1055 | 1056 |
| 1056 // This function is being called to scrape the cookie list for management UI | 1057 // This function is being called to scrape the cookie list for management UI |
| 1057 // or similar. We shouldn't show expired cookies in this list since it will | 1058 // or similar. We shouldn't show expired cookies in this list since it will |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1191 | 1192 |
| 1192 void CookieMonster::DeleteCookie(const GURL& url, | 1193 void CookieMonster::DeleteCookie(const GURL& url, |
| 1193 const std::string& cookie_name) { | 1194 const std::string& cookie_name) { |
| 1194 DCHECK(thread_checker_.CalledOnValidThread()); | 1195 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1195 | 1196 |
| 1196 if (!HasCookieableScheme(url)) | 1197 if (!HasCookieableScheme(url)) |
| 1197 return; | 1198 return; |
| 1198 | 1199 |
| 1199 CookieOptions options; | 1200 CookieOptions options; |
| 1200 options.set_include_httponly(); | 1201 options.set_include_httponly(); |
| 1201 options.set_include_same_site(); | 1202 options.set_same_site_cookie_mode( |
| 1203 CookieOptions::SameSiteCookieMode::INCLUDE_STRICT_AND_LAX); |
| 1202 // Get the cookies for this host and its domain(s). | 1204 // Get the cookies for this host and its domain(s). |
| 1203 std::vector<CanonicalCookie*> cookies; | 1205 std::vector<CanonicalCookie*> cookies; |
| 1204 FindCookiesForHostAndDomain(url, options, &cookies); | 1206 FindCookiesForHostAndDomain(url, options, &cookies); |
| 1205 std::set<CanonicalCookie*> matching_cookies; | 1207 std::set<CanonicalCookie*> matching_cookies; |
| 1206 | 1208 |
| 1207 for (const auto& cookie : cookies) { | 1209 for (const auto& cookie : cookies) { |
| 1208 if (cookie->Name() != cookie_name) | 1210 if (cookie->Name() != cookie_name) |
| 1209 continue; | 1211 continue; |
| 1210 if (!cookie->IsOnPath(url.path())) | 1212 if (!cookie->IsOnPath(url.path())) |
| 1211 continue; | 1213 continue; |
| (...skipping 1108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2320 DCHECK(thread_checker_.CalledOnValidThread()); | 2322 DCHECK(thread_checker_.CalledOnValidThread()); |
| 2321 callback.Run(); | 2323 callback.Run(); |
| 2322 } | 2324 } |
| 2323 | 2325 |
| 2324 void CookieMonster::RunCookieChangedCallbacks(const CanonicalCookie& cookie, | 2326 void CookieMonster::RunCookieChangedCallbacks(const CanonicalCookie& cookie, |
| 2325 bool removed) { | 2327 bool removed) { |
| 2326 DCHECK(thread_checker_.CalledOnValidThread()); | 2328 DCHECK(thread_checker_.CalledOnValidThread()); |
| 2327 | 2329 |
| 2328 CookieOptions opts; | 2330 CookieOptions opts; |
| 2329 opts.set_include_httponly(); | 2331 opts.set_include_httponly(); |
| 2330 opts.set_include_same_site(); | 2332 opts.set_same_site_cookie_mode( |
| 2333 CookieOptions::SameSiteCookieMode::INCLUDE_STRICT_AND_LAX); |
| 2331 // Note that the callbacks in hook_map_ are wrapped with RunAsync(), so they | 2334 // Note that the callbacks in hook_map_ are wrapped with RunAsync(), so they |
| 2332 // are guaranteed to not take long - they just post a RunAsync task back to | 2335 // are guaranteed to not take long - they just post a RunAsync task back to |
| 2333 // the appropriate thread's message loop and return. | 2336 // the appropriate thread's message loop and return. |
| 2334 // TODO(mmenke): Consider running these synchronously? | 2337 // TODO(mmenke): Consider running these synchronously? |
| 2335 for (CookieChangedHookMap::iterator it = hook_map_.begin(); | 2338 for (CookieChangedHookMap::iterator it = hook_map_.begin(); |
| 2336 it != hook_map_.end(); ++it) { | 2339 it != hook_map_.end(); ++it) { |
| 2337 std::pair<GURL, std::string> key = it->first; | 2340 std::pair<GURL, std::string> key = it->first; |
| 2338 if (cookie.IncludeForRequestURL(key.first, opts) && | 2341 if (cookie.IncludeForRequestURL(key.first, opts) && |
| 2339 cookie.Name() == key.second) { | 2342 cookie.Name() == key.second) { |
| 2340 it->second->Notify(cookie, removed); | 2343 it->second->Notify(cookie, removed); |
| 2341 } | 2344 } |
| 2342 } | 2345 } |
| 2343 } | 2346 } |
| 2344 | 2347 |
| 2345 } // namespace net | 2348 } // namespace net |
| OLD | NEW |