| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 DCHECK(origin.SchemeIs("http") || origin.SchemeIs("https") || |
| 46 origin.SchemeIs("httpsv")); |
| 46 DCHECK(origin.GetOrigin() == origin); | 47 DCHECK(origin.GetOrigin() == origin); |
| 47 } | 48 } |
| 48 | 49 |
| 49 // Functor used by remove_if. | 50 // Functor used by remove_if. |
| 50 struct IsEnclosedBy { | 51 struct IsEnclosedBy { |
| 51 explicit IsEnclosedBy(const std::string& path) : path(path) { } | 52 explicit IsEnclosedBy(const std::string& path) : path(path) { } |
| 52 bool operator() (const std::string& x) { | 53 bool operator() (const std::string& x) { |
| 53 return IsEnclosingPath(path, x); | 54 return IsEnclosingPath(path, x); |
| 54 } | 55 } |
| 55 const std::string& path; | 56 const std::string& path; |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 HttpAuth::Scheme scheme, | 205 HttpAuth::Scheme scheme, |
| 205 const std::string& auth_challenge) { | 206 const std::string& auth_challenge) { |
| 206 HttpAuthCache::Entry* entry = Lookup(origin, realm, scheme); | 207 HttpAuthCache::Entry* entry = Lookup(origin, realm, scheme); |
| 207 if (!entry) | 208 if (!entry) |
| 208 return false; | 209 return false; |
| 209 entry->UpdateStaleChallenge(auth_challenge); | 210 entry->UpdateStaleChallenge(auth_challenge); |
| 210 return true; | 211 return true; |
| 211 } | 212 } |
| 212 | 213 |
| 213 } // namespace net | 214 } // namespace net |
| OLD | NEW |