| 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 | 101 |
| 102 CannedBrowsingDataCookieHelper::CannedBrowsingDataCookieHelper( | 102 CannedBrowsingDataCookieHelper::CannedBrowsingDataCookieHelper( |
| 103 net::URLRequestContextGetter* request_context_getter) | 103 net::URLRequestContextGetter* request_context_getter) |
| 104 : BrowsingDataCookieHelper(request_context_getter) { | 104 : BrowsingDataCookieHelper(request_context_getter) { |
| 105 } | 105 } |
| 106 | 106 |
| 107 CannedBrowsingDataCookieHelper::~CannedBrowsingDataCookieHelper() { | 107 CannedBrowsingDataCookieHelper::~CannedBrowsingDataCookieHelper() { |
| 108 Reset(); | 108 Reset(); |
| 109 } | 109 } |
| 110 | 110 |
| 111 CannedBrowsingDataCookieHelper* CannedBrowsingDataCookieHelper::Clone() { | |
| 112 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
| 113 CannedBrowsingDataCookieHelper* clone = | |
| 114 new CannedBrowsingDataCookieHelper(request_context_getter()); | |
| 115 | |
| 116 for (OriginCookieSetMap::iterator it = origin_cookie_set_map_.begin(); | |
| 117 it != origin_cookie_set_map_.end(); | |
| 118 ++it) { | |
| 119 canonical_cookie::CookieHashSet* cookies = clone->GetCookiesFor(it->first); | |
| 120 cookies->insert(it->second->begin(), it->second->end()); | |
| 121 } | |
| 122 return clone; | |
| 123 } | |
| 124 | |
| 125 void CannedBrowsingDataCookieHelper::AddReadCookies( | 111 void CannedBrowsingDataCookieHelper::AddReadCookies( |
| 126 const GURL& frame_url, | 112 const GURL& frame_url, |
| 127 const GURL& url, | 113 const GURL& url, |
| 128 const net::CookieList& cookie_list) { | 114 const net::CookieList& cookie_list) { |
| 129 typedef net::CookieList::const_iterator cookie_iterator; | 115 typedef net::CookieList::const_iterator cookie_iterator; |
| 130 for (cookie_iterator add_cookie = cookie_list.begin(); | 116 for (cookie_iterator add_cookie = cookie_list.begin(); |
| 131 add_cookie != cookie_list.end(); ++add_cookie) { | 117 add_cookie != cookie_list.end(); ++add_cookie) { |
| 132 AddCookie(frame_url, *add_cookie); | 118 AddCookie(frame_url, *add_cookie); |
| 133 } | 119 } |
| 134 } | 120 } |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 // TODO(markusheintz): A) Change the GetCookiesCount method to prevent | 220 // TODO(markusheintz): A) Change the GetCookiesCount method to prevent |
| 235 // counting cookies multiple times if they are stored in multiple cookie | 221 // counting cookies multiple times if they are stored in multiple cookie |
| 236 // sets. B) Replace the GetCookieFor method call below with: | 222 // sets. B) Replace the GetCookieFor method call below with: |
| 237 // "GetCookiesFor(frame_url.GetOrigin());" | 223 // "GetCookiesFor(frame_url.GetOrigin());" |
| 238 CR_DEFINE_STATIC_LOCAL(const GURL, origin_cookie_url, (kGlobalCookieSetURL)); | 224 CR_DEFINE_STATIC_LOCAL(const GURL, origin_cookie_url, (kGlobalCookieSetURL)); |
| 239 canonical_cookie::CookieHashSet* cookie_set = | 225 canonical_cookie::CookieHashSet* cookie_set = |
| 240 GetCookiesFor(origin_cookie_url); | 226 GetCookiesFor(origin_cookie_url); |
| 241 DeleteMatchingCookie(cookie, cookie_set); | 227 DeleteMatchingCookie(cookie, cookie_set); |
| 242 cookie_set->insert(cookie); | 228 cookie_set->insert(cookie); |
| 243 } | 229 } |
| OLD | NEW |