OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/http/http_auth_cache.h" | 5 #include "net/http/http_auth_cache.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 | 9 |
10 namespace { | 10 namespace { |
(...skipping 25 matching lines...) Expand all Loading... |
36 bool IsEnclosingPath(const std::string& container, const std::string& path) { | 36 bool IsEnclosingPath(const std::string& container, const std::string& path) { |
37 DCHECK(container.empty() || *(container.end() - 1) == '/'); | 37 DCHECK(container.empty() || *(container.end() - 1) == '/'); |
38 return ((container.empty() && path.empty()) || | 38 return ((container.empty() && path.empty()) || |
39 (!container.empty() && StartsWithASCII(path, container, true))); | 39 (!container.empty() && StartsWithASCII(path, container, true))); |
40 } | 40 } |
41 | 41 |
42 // Debug helper to check that |origin| arguments are properly formed. | 42 // Debug helper to check that |origin| arguments are properly formed. |
43 void CheckOriginIsValid(const GURL& origin) { | 43 void CheckOriginIsValid(const GURL& origin) { |
44 DCHECK(origin.is_valid()); | 44 DCHECK(origin.is_valid()); |
45 // Note that the scheme may be FTP when we're using a HTTP proxy. | 45 // Note that the scheme may be FTP when we're using a HTTP proxy. |
46 DCHECK(origin.SchemeIs("http") || origin.SchemeIs("https") || | 46 DCHECK(origin.SchemeIsHTTPOrHTTPS() || origin.SchemeIs("ftp")); |
47 origin.SchemeIs("ftp")); | |
48 DCHECK(origin.GetOrigin() == origin); | 47 DCHECK(origin.GetOrigin() == origin); |
49 } | 48 } |
50 | 49 |
51 // Functor used by remove_if. | 50 // Functor used by remove_if. |
52 struct IsEnclosedBy { | 51 struct IsEnclosedBy { |
53 explicit IsEnclosedBy(const std::string& path) : path(path) { } | 52 explicit IsEnclosedBy(const std::string& path) : path(path) { } |
54 bool operator() (const std::string& x) const { | 53 bool operator() (const std::string& x) const { |
55 return IsEnclosingPath(path, x); | 54 return IsEnclosingPath(path, x); |
56 } | 55 } |
57 const std::string& path; | 56 const std::string& path; |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 // Copy all other paths. | 234 // Copy all other paths. |
236 for (Entry::PathList::const_reverse_iterator it2 = ++it->paths_.rbegin(); | 235 for (Entry::PathList::const_reverse_iterator it2 = ++it->paths_.rbegin(); |
237 it2 != it->paths_.rend(); ++it2) | 236 it2 != it->paths_.rend(); ++it2) |
238 entry->AddPath(*it2); | 237 entry->AddPath(*it2); |
239 // Copy nonce count (for digest authentication). | 238 // Copy nonce count (for digest authentication). |
240 entry->nonce_count_ = it->nonce_count_; | 239 entry->nonce_count_ = it->nonce_count_; |
241 } | 240 } |
242 } | 241 } |
243 | 242 |
244 } // namespace net | 243 } // namespace net |
OLD | NEW |