This source file includes following definitions.
- AddFilter
- AddRuleToBypassLocal
- IsValid
- SetWhitelist
#include "base/strings/string_util.h"
#include "net/http/http_auth_filter.h"
#include "url/gurl.h"
namespace net {
typedef std::set<base::string16> RegistryWhitelist;
HttpAuthFilterWhitelist::HttpAuthFilterWhitelist(
const std::string& server_whitelist) {
SetWhitelist(server_whitelist);
}
HttpAuthFilterWhitelist::~HttpAuthFilterWhitelist() {
}
bool HttpAuthFilterWhitelist::AddFilter(const std::string& filter,
HttpAuth::Target target) {
if ((target != HttpAuth::AUTH_SERVER) && (target != HttpAuth::AUTH_PROXY))
return false;
if (target == HttpAuth::AUTH_PROXY)
return true;
rules_.AddRuleFromString(filter);
return true;
}
void HttpAuthFilterWhitelist::AddRuleToBypassLocal() {
rules_.AddRuleToBypassLocal();
}
bool HttpAuthFilterWhitelist::IsValid(const GURL& url,
HttpAuth::Target target) const {
if ((target != HttpAuth::AUTH_SERVER) && (target != HttpAuth::AUTH_PROXY))
return false;
if (target == HttpAuth::AUTH_PROXY)
return true;
return rules_.Matches(url);
}
void HttpAuthFilterWhitelist::SetWhitelist(
const std::string& server_whitelist) {
rules_.ParseFromString(server_whitelist);
}
}