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