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

Side by Side Diff: net/cookies/canonical_cookie.cc

Issue 255333003: Renamed namespaces in src/net. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Tue 04/29/2014 19:22:06.75 Created 6 years, 7 months 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
« no previous file with comments | « net/cert/x509_certificate.cc ('k') | net/cookies/cookie_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 domain_ = cookie_domain; 155 domain_ = cookie_domain;
156 } 156 }
157 157
158 CanonicalCookie::~CanonicalCookie() { 158 CanonicalCookie::~CanonicalCookie() {
159 } 159 }
160 160
161 std::string CanonicalCookie::GetCookieSourceFromURL(const GURL& url) { 161 std::string CanonicalCookie::GetCookieSourceFromURL(const GURL& url) {
162 if (url.SchemeIsFile()) 162 if (url.SchemeIsFile())
163 return url.spec(); 163 return url.spec();
164 164
165 url_canon::Replacements<char> replacements; 165 url::Replacements<char> replacements;
166 replacements.ClearPort(); 166 replacements.ClearPort();
167 if (url.SchemeIsSecure()) 167 if (url.SchemeIsSecure())
168 replacements.SetScheme("http", url_parse::Component(0, 4)); 168 replacements.SetScheme("http", url::Component(0, 4));
169 169
170 return url.GetOrigin().ReplaceComponents(replacements).spec(); 170 return url.GetOrigin().ReplaceComponents(replacements).spec();
171 } 171 }
172 172
173 // static 173 // static
174 std::string CanonicalCookie::CanonPath(const GURL& url, 174 std::string CanonicalCookie::CanonPath(const GURL& url,
175 const ParsedCookie& pc) { 175 const ParsedCookie& pc) {
176 std::string path_string; 176 std::string path_string;
177 if (pc.HasPath()) 177 if (pc.HasPath())
178 path_string = pc.Path(); 178 path_string = pc.Path();
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 276
277 std::string parsed_path = ParsedCookie::ParseValueString(path); 277 std::string parsed_path = ParsedCookie::ParseValueString(path);
278 if (parsed_path != path) 278 if (parsed_path != path)
279 return NULL; 279 return NULL;
280 280
281 std::string cookie_path = CanonPathWithString(url, parsed_path); 281 std::string cookie_path = CanonPathWithString(url, parsed_path);
282 // Expect that the path was either not specified (empty), or is valid. 282 // Expect that the path was either not specified (empty), or is valid.
283 if (!parsed_path.empty() && cookie_path != parsed_path) 283 if (!parsed_path.empty() && cookie_path != parsed_path)
284 return NULL; 284 return NULL;
285 // Canonicalize path again to make sure it escapes characters as needed. 285 // Canonicalize path again to make sure it escapes characters as needed.
286 url_parse::Component path_component(0, cookie_path.length()); 286 url::Component path_component(0, cookie_path.length());
287 url_canon::RawCanonOutputT<char> canon_path; 287 url::RawCanonOutputT<char> canon_path;
288 url_parse::Component canon_path_component; 288 url::Component canon_path_component;
289 url_canon::CanonicalizePath(cookie_path.data(), path_component, 289 url::CanonicalizePath(cookie_path.data(), path_component, &canon_path,
290 &canon_path, &canon_path_component); 290 &canon_path_component);
291 cookie_path = std::string(canon_path.data() + canon_path_component.begin, 291 cookie_path = std::string(canon_path.data() + canon_path_component.begin,
292 canon_path_component.len); 292 canon_path_component.len);
293 293
294 return new CanonicalCookie(url, parsed_name, parsed_value, cookie_domain, 294 return new CanonicalCookie(url, parsed_name, parsed_value, cookie_domain,
295 cookie_path, creation, expiration, creation, 295 cookie_path, creation, expiration, creation,
296 secure, http_only, priority); 296 secure, http_only, priority);
297 } 297 }
298 298
299 bool CanonicalCookie::IsOnPath(const std::string& url_path) const { 299 bool CanonicalCookie::IsOnPath(const std::string& url_path) const {
300 300
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 std::string CanonicalCookie::DebugString() const { 388 std::string CanonicalCookie::DebugString() const {
389 return base::StringPrintf( 389 return base::StringPrintf(
390 "name: %s value: %s domain: %s path: %s creation: %" 390 "name: %s value: %s domain: %s path: %s creation: %"
391 PRId64, 391 PRId64,
392 name_.c_str(), value_.c_str(), 392 name_.c_str(), value_.c_str(),
393 domain_.c_str(), path_.c_str(), 393 domain_.c_str(), path_.c_str(),
394 static_cast<int64>(creation_date_.ToTimeT())); 394 static_cast<int64>(creation_date_.ToTimeT()));
395 } 395 }
396 396
397 } // namespace net 397 } // namespace net
OLDNEW
« no previous file with comments | « net/cert/x509_certificate.cc ('k') | net/cookies/cookie_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698