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 "chrome/browser/browsing_data/browsing_data_cookie_helper.h" | 5 #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h" |
6 | 6 |
7 #include "utility" | 7 #include "utility" |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 for (OriginCookieListMap::iterator it = origin_cookie_list_map_.begin(); | 180 for (OriginCookieListMap::iterator it = origin_cookie_list_map_.begin(); |
181 it != origin_cookie_list_map_.end(); | 181 it != origin_cookie_list_map_.end(); |
182 ++it) { | 182 ++it) { |
183 cookie_list.insert(cookie_list.begin(), | 183 cookie_list.insert(cookie_list.begin(), |
184 it->second->begin(), | 184 it->second->begin(), |
185 it->second->end()); | 185 it->second->end()); |
186 } | 186 } |
187 callback.Run(cookie_list); | 187 callback.Run(cookie_list); |
188 } | 188 } |
189 | 189 |
| 190 void CannedBrowsingDataCookieHelper::DeleteCookie( |
| 191 const net::CanonicalCookie& cookie) { |
| 192 for (OriginCookieListMap::iterator it = origin_cookie_list_map_.begin(); |
| 193 it != origin_cookie_list_map_.end(); |
| 194 ++it) { |
| 195 DeleteMatchingCookie(cookie, it->second); |
| 196 } |
| 197 BrowsingDataCookieHelper::DeleteCookie(cookie); |
| 198 } |
| 199 |
190 bool CannedBrowsingDataCookieHelper::DeleteMatchingCookie( | 200 bool CannedBrowsingDataCookieHelper::DeleteMatchingCookie( |
191 const net::CanonicalCookie& add_cookie, | 201 const net::CanonicalCookie& add_cookie, |
192 net::CookieList* cookie_list) { | 202 net::CookieList* cookie_list) { |
193 typedef net::CookieList::iterator cookie_iterator; | 203 typedef net::CookieList::iterator cookie_iterator; |
194 for (cookie_iterator cookie = cookie_list->begin(); | 204 for (cookie_iterator cookie = cookie_list->begin(); |
195 cookie != cookie_list->end(); ++cookie) { | 205 cookie != cookie_list->end(); ++cookie) { |
196 if (cookie->Name() == add_cookie.Name() && | 206 if (cookie->Name() == add_cookie.Name() && |
197 cookie->Domain() == add_cookie.Domain()&& | 207 cookie->Domain() == add_cookie.Domain()&& |
198 cookie->Path() == add_cookie.Path()) { | 208 cookie->Path() == add_cookie.Path()) { |
199 cookie_list->erase(cookie); | 209 cookie_list->erase(cookie); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 // collecting cookies per origin in redirect chains. | 242 // collecting cookies per origin in redirect chains. |
233 // TODO(markusheintz): A) Change the GetCookiesCount method to prevent | 243 // TODO(markusheintz): A) Change the GetCookiesCount method to prevent |
234 // counting cookies multiple times if they are stored in multiple cookie | 244 // counting cookies multiple times if they are stored in multiple cookie |
235 // lists. B) Replace the GetCookieFor method call below with: | 245 // lists. B) Replace the GetCookieFor method call below with: |
236 // "GetCookiesFor(frame_url.GetOrigin());" | 246 // "GetCookiesFor(frame_url.GetOrigin());" |
237 net::CookieList* cookie_list = | 247 net::CookieList* cookie_list = |
238 GetCookiesFor(GURL(kGlobalCookieListURL)); | 248 GetCookiesFor(GURL(kGlobalCookieListURL)); |
239 DeleteMatchingCookie(cookie, cookie_list); | 249 DeleteMatchingCookie(cookie, cookie_list); |
240 cookie_list->push_back(cookie); | 250 cookie_list->push_back(cookie); |
241 } | 251 } |
OLD | NEW |