| 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/string_util.h" | 8 #include "base/string_util.h" |
| 9 | 9 |
| 10 namespace { | 10 namespace { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 // |container| an ancestor of |path|? | 35 // |container| an ancestor of |path|? |
| 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 DCHECK(origin.SchemeIs("http") || origin.SchemeIs("https")); | 45 // Note that the scheme may be FTP when we're using a HTTP proxy. |
| 46 DCHECK(origin.SchemeIs("http") || origin.SchemeIs("https") || |
| 47 origin.SchemeIs("ftp")); |
| 46 DCHECK(origin.GetOrigin() == origin); | 48 DCHECK(origin.GetOrigin() == origin); |
| 47 } | 49 } |
| 48 | 50 |
| 49 // Functor used by remove_if. | 51 // Functor used by remove_if. |
| 50 struct IsEnclosedBy { | 52 struct IsEnclosedBy { |
| 51 explicit IsEnclosedBy(const std::string& path) : path(path) { } | 53 explicit IsEnclosedBy(const std::string& path) : path(path) { } |
| 52 bool operator() (const std::string& x) const { | 54 bool operator() (const std::string& x) const { |
| 53 return IsEnclosingPath(path, x); | 55 return IsEnclosingPath(path, x); |
| 54 } | 56 } |
| 55 const std::string& path; | 57 const std::string& path; |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 // Copy all other paths. | 235 // Copy all other paths. |
| 234 for (Entry::PathList::const_reverse_iterator it2 = ++it->paths_.rbegin(); | 236 for (Entry::PathList::const_reverse_iterator it2 = ++it->paths_.rbegin(); |
| 235 it2 != it->paths_.rend(); ++it2) | 237 it2 != it->paths_.rend(); ++it2) |
| 236 entry->AddPath(*it2); | 238 entry->AddPath(*it2); |
| 237 // Copy nonce count (for digest authentication). | 239 // Copy nonce count (for digest authentication). |
| 238 entry->nonce_count_ = it->nonce_count_; | 240 entry->nonce_count_ = it->nonce_count_; |
| 239 } | 241 } |
| 240 } | 242 } |
| 241 | 243 |
| 242 } // namespace net | 244 } // namespace net |
| OLD | NEW |