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 #include "net/cookies/cookie_store.h" | 5 #include "net/cookies/cookie_store.h" |
6 | 6 |
| 7 #include "base/bind.h" |
| 8 #include "base/callback.h" |
7 #include "net/cookies/cookie_options.h" | 9 #include "net/cookies/cookie_options.h" |
8 | 10 |
9 namespace net { | 11 namespace net { |
| 12 namespace { |
| 13 bool DoesCookieMatchHost(const std::string& host, |
| 14 const CanonicalCookie& cookie) { |
| 15 return cookie.IsHostCookie() && cookie.IsDomainMatch(host); |
| 16 } |
| 17 } // namespace |
10 | 18 |
11 CookieStore::~CookieStore() {} | 19 CookieStore::~CookieStore() {} |
12 | 20 |
13 std::string CookieStore::BuildCookieLine( | 21 std::string CookieStore::BuildCookieLine( |
14 const std::vector<CanonicalCookie>& cookies) { | 22 const std::vector<CanonicalCookie>& cookies) { |
15 std::string cookie_line; | 23 std::string cookie_line; |
16 for (const auto& cookie : cookies) { | 24 for (const auto& cookie : cookies) { |
17 if (!cookie_line.empty()) | 25 if (!cookie_line.empty()) |
18 cookie_line += "; "; | 26 cookie_line += "; "; |
19 // In Mozilla, if you set a cookie like "AAA", it will have an empty token | 27 // In Mozilla, if you set a cookie like "AAA", it will have an empty token |
(...skipping 15 matching lines...) Expand all Loading... |
35 // In Mozilla, if you set a cookie like "AAA", it will have an empty token | 43 // In Mozilla, if you set a cookie like "AAA", it will have an empty token |
36 // and a value of "AAA". When it sends the cookie back, it will send "AAA", | 44 // and a value of "AAA". When it sends the cookie back, it will send "AAA", |
37 // so we need to avoid sending "=AAA" for a blank token value. | 45 // so we need to avoid sending "=AAA" for a blank token value. |
38 if (!cookie->Name().empty()) | 46 if (!cookie->Name().empty()) |
39 cookie_line += cookie->Name() + "="; | 47 cookie_line += cookie->Name() + "="; |
40 cookie_line += cookie->Value(); | 48 cookie_line += cookie->Value(); |
41 } | 49 } |
42 return cookie_line; | 50 return cookie_line; |
43 } | 51 } |
44 | 52 |
| 53 CookieStore::CookiePredicate CookieStore::CreatePredicateForHostCookies( |
| 54 const GURL& url) { |
| 55 return base::Bind(&DoesCookieMatchHost, url.host()); |
| 56 } |
| 57 |
45 void CookieStore::DeleteAllAsync(const DeleteCallback& callback) { | 58 void CookieStore::DeleteAllAsync(const DeleteCallback& callback) { |
46 DeleteAllCreatedBetweenAsync(base::Time(), base::Time::Max(), callback); | 59 DeleteAllCreatedBetweenAsync(base::Time(), base::Time::Max(), callback); |
47 } | 60 } |
48 | 61 |
49 void CookieStore::SetForceKeepSessionState() { | 62 void CookieStore::SetForceKeepSessionState() { |
50 // By default, do nothing. | 63 // By default, do nothing. |
51 } | 64 } |
52 | 65 |
53 void CookieStore::GetAllCookiesForURLAsync( | 66 void CookieStore::GetAllCookiesForURLAsync( |
54 const GURL& url, | 67 const GURL& url, |
(...skipping 11 matching lines...) Expand all Loading... |
66 channel_id_service_id_ = id; | 79 channel_id_service_id_ = id; |
67 } | 80 } |
68 | 81 |
69 int CookieStore::GetChannelIDServiceID() { | 82 int CookieStore::GetChannelIDServiceID() { |
70 return channel_id_service_id_; | 83 return channel_id_service_id_; |
71 } | 84 } |
72 | 85 |
73 CookieStore::CookieStore() : channel_id_service_id_(-1) {} | 86 CookieStore::CookieStore() : channel_id_service_id_(-1) {} |
74 | 87 |
75 } // namespace net | 88 } // namespace net |
OLD | NEW |