Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(297)

Side by Side Diff: chrome/browser/browsing_data/browsing_data_cookie_helper.cc

Issue 11339032: Account for server vs host clock skew in cookie expiration times. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Disable test on Android as there's no test server Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 AddCookie(frame_url, *add_cookie); 132 AddCookie(frame_url, *add_cookie);
133 } 133 }
134 } 134 }
135 135
136 void CannedBrowsingDataCookieHelper::AddChangedCookie( 136 void CannedBrowsingDataCookieHelper::AddChangedCookie(
137 const GURL& frame_url, 137 const GURL& frame_url,
138 const GURL& url, 138 const GURL& url,
139 const std::string& cookie_line, 139 const std::string& cookie_line,
140 const net::CookieOptions& options) { 140 const net::CookieOptions& options) {
141 base::Time creation_time = base::Time::Now(); 141 base::Time creation_time = base::Time::Now();
142 base::Time server_time;
143 if (options.has_server_time())
144 server_time = options.server_time();
145 else
146 server_time = creation_time;
142 147
143 net::ParsedCookie pc(cookie_line); 148 net::ParsedCookie pc(cookie_line);
144 if (!pc.IsValid()) 149 if (!pc.IsValid())
145 return; 150 return;
146 151
147 if (options.exclude_httponly() && pc.IsHttpOnly()) 152 if (options.exclude_httponly() && pc.IsHttpOnly())
148 return; 153 return;
149 154
150 std::string domain_string; 155 std::string domain_string;
151 if (pc.HasDomain()) 156 if (pc.HasDomain())
152 domain_string = pc.Domain(); 157 domain_string = pc.Domain();
153 std::string cookie_domain; 158 std::string cookie_domain;
154 if (!net::cookie_util::GetCookieDomainWithString(url, domain_string, 159 if (!net::cookie_util::GetCookieDomainWithString(url, domain_string,
155 &cookie_domain)) 160 &cookie_domain))
156 return; 161 return;
157 162
158 std::string cookie_path = net::CanonicalCookie::CanonPath(url, pc); 163 std::string cookie_path = net::CanonicalCookie::CanonPath(url, pc);
159 std::string mac_key = pc.HasMACKey() ? pc.MACKey() : std::string(); 164 std::string mac_key = pc.HasMACKey() ? pc.MACKey() : std::string();
160 std::string mac_algorithm = pc.HasMACAlgorithm() ? 165 std::string mac_algorithm = pc.HasMACAlgorithm() ?
161 pc.MACAlgorithm() : std::string(); 166 pc.MACAlgorithm() : std::string();
162 167
163 base::Time cookie_expires = 168 base::Time cookie_expires =
164 net::CanonicalCookie::CanonExpiration(pc, creation_time); 169 net::CanonicalCookie::CanonExpiration(pc, creation_time, server_time);
165 170
166 scoped_ptr<net::CanonicalCookie> cookie( 171 scoped_ptr<net::CanonicalCookie> cookie(
167 new net::CanonicalCookie(url, pc.Name(), pc.Value(), cookie_domain, 172 new net::CanonicalCookie(url, pc.Name(), pc.Value(), cookie_domain,
168 cookie_path, mac_key, mac_algorithm, 173 cookie_path, mac_key, mac_algorithm,
169 creation_time, cookie_expires, 174 creation_time, cookie_expires,
170 creation_time, pc.IsSecure(), pc.IsHttpOnly())); 175 creation_time, pc.IsSecure(), pc.IsHttpOnly()));
171 if (cookie.get()) 176 if (cookie.get())
172 AddCookie(frame_url, *cookie); 177 AddCookie(frame_url, *cookie);
173 } 178 }
174 179
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 // collecting cookies per origin in redirect chains. 265 // collecting cookies per origin in redirect chains.
261 // TODO(markusheintz): A) Change the GetCookiesCount method to prevent 266 // TODO(markusheintz): A) Change the GetCookiesCount method to prevent
262 // counting cookies multiple times if they are stored in multiple cookie 267 // counting cookies multiple times if they are stored in multiple cookie
263 // lists. B) Replace the GetCookieFor method call below with: 268 // lists. B) Replace the GetCookieFor method call below with:
264 // "GetCookiesFor(frame_url.GetOrigin());" 269 // "GetCookiesFor(frame_url.GetOrigin());"
265 net::CookieList* cookie_list = 270 net::CookieList* cookie_list =
266 GetCookiesFor(GURL(kGlobalCookieListURL)); 271 GetCookiesFor(GURL(kGlobalCookieListURL));
267 DeleteMatchingCookie(cookie, cookie_list); 272 DeleteMatchingCookie(cookie, cookie_list);
268 cookie_list->push_back(cookie); 273 cookie_list->push_back(cookie);
269 } 274 }
OLDNEW
« no previous file with comments | « build/android/gtest_filter/net_unittests_disabled ('k') | chrome_frame/test/net/fake_external_tab.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698