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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 entry->password_ = password; | 136 entry->password_ = password; |
137 entry->nonce_count_ = 1; | 137 entry->nonce_count_ = 1; |
138 entry->AddPath(path); | 138 entry->AddPath(path); |
139 | 139 |
140 return entry; | 140 return entry; |
141 } | 141 } |
142 | 142 |
143 HttpAuthCache::Entry::~Entry() { | 143 HttpAuthCache::Entry::~Entry() { |
144 } | 144 } |
145 | 145 |
| 146 void HttpAuthCache::Entry::UpdateStaleChallenge( |
| 147 const std::string& auth_challenge) { |
| 148 auth_challenge_ = auth_challenge; |
| 149 nonce_count_ = 1; |
| 150 } |
| 151 |
146 HttpAuthCache::Entry::Entry() | 152 HttpAuthCache::Entry::Entry() |
147 : nonce_count_(0) { | 153 : nonce_count_(0) { |
148 } | 154 } |
149 | 155 |
150 void HttpAuthCache::Entry::AddPath(const std::string& path) { | 156 void HttpAuthCache::Entry::AddPath(const std::string& path) { |
151 std::string parent_dir = GetParentDirectory(path); | 157 std::string parent_dir = GetParentDirectory(path); |
152 if (!HasEnclosingPath(parent_dir)) { | 158 if (!HasEnclosingPath(parent_dir)) { |
153 // Remove any entries that have been subsumed by the new entry. | 159 // Remove any entries that have been subsumed by the new entry. |
154 paths_.remove_if(IsEnclosedBy(parent_dir)); | 160 paths_.remove_if(IsEnclosedBy(parent_dir)); |
155 | 161 |
(...skipping 12 matching lines...) Expand all Loading... |
168 bool HttpAuthCache::Entry::HasEnclosingPath(const std::string& dir) { | 174 bool HttpAuthCache::Entry::HasEnclosingPath(const std::string& dir) { |
169 DCHECK(GetParentDirectory(dir) == dir); | 175 DCHECK(GetParentDirectory(dir) == dir); |
170 for (PathList::const_iterator it = paths_.begin(); it != paths_.end(); | 176 for (PathList::const_iterator it = paths_.begin(); it != paths_.end(); |
171 ++it) { | 177 ++it) { |
172 if (IsEnclosingPath(*it, dir)) | 178 if (IsEnclosingPath(*it, dir)) |
173 return true; | 179 return true; |
174 } | 180 } |
175 return false; | 181 return false; |
176 } | 182 } |
177 | 183 |
178 void HttpAuthCache::Entry::UpdateStaleChallenge( | |
179 const std::string& auth_challenge) { | |
180 auth_challenge_ = auth_challenge; | |
181 nonce_count_ = 1; | |
182 } | |
183 | |
184 bool HttpAuthCache::Remove(const GURL& origin, | 184 bool HttpAuthCache::Remove(const GURL& origin, |
185 const std::string& realm, | 185 const std::string& realm, |
186 HttpAuth::Scheme scheme, | 186 HttpAuth::Scheme scheme, |
187 const string16& username, | 187 const string16& username, |
188 const string16& password) { | 188 const string16& password) { |
189 for (EntryList::iterator it = entries_.begin(); it != entries_.end(); ++it) { | 189 for (EntryList::iterator it = entries_.begin(); it != entries_.end(); ++it) { |
190 if (it->origin() == origin && it->realm() == realm && | 190 if (it->origin() == origin && it->realm() == realm && |
191 it->scheme() == scheme) { | 191 it->scheme() == scheme) { |
192 if (username == it->username() && password == it->password()) { | 192 if (username == it->username() && password == it->password()) { |
193 entries_.erase(it); | 193 entries_.erase(it); |
(...skipping 10 matching lines...) Expand all Loading... |
204 HttpAuth::Scheme scheme, | 204 HttpAuth::Scheme scheme, |
205 const std::string& auth_challenge) { | 205 const std::string& auth_challenge) { |
206 HttpAuthCache::Entry* entry = Lookup(origin, realm, scheme); | 206 HttpAuthCache::Entry* entry = Lookup(origin, realm, scheme); |
207 if (!entry) | 207 if (!entry) |
208 return false; | 208 return false; |
209 entry->UpdateStaleChallenge(auth_challenge); | 209 entry->UpdateStaleChallenge(auth_challenge); |
210 return true; | 210 return true; |
211 } | 211 } |
212 | 212 |
213 } // namespace net | 213 } // namespace net |
OLD | NEW |