Revert of Add CompleteRead to SequencedSocketData and convert all but 3 tests (patchs...
[chromium-blink-merge.git] / net / http / http_auth_filter.h
blob260da47c16d1832189e498e7f98ee0c7c57ff84a
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
3 // found in the LICENSE file.
5 #ifndef NET_HTTP_HTTP_AUTH_FILTER_H_
6 #define NET_HTTP_HTTP_AUTH_FILTER_H_
8 #include <list>
9 #include <string>
11 #include "net/base/net_export.h"
12 #include "net/http/http_auth.h"
13 #include "net/proxy/proxy_bypass_rules.h"
15 class GURL;
17 namespace net {
19 // |HttpAuthFilter|s determine whether an authentication scheme should be
20 // allowed for a particular peer.
21 class NET_EXPORT_PRIVATE HttpAuthFilter {
22 public:
23 virtual ~HttpAuthFilter() {}
25 // Checks if (|url|, |target|) is supported by the authentication scheme.
26 // Only the host of |url| is examined.
27 virtual bool IsValid(const GURL& url, HttpAuth::Target target) const = 0;
30 // Whitelist HTTP authentication filter.
31 // Explicit whitelists of domains are set via SetWhitelist().
33 // Uses the ProxyBypassRules class to do whitelisting for servers.
34 // All proxies are allowed.
35 class NET_EXPORT HttpAuthFilterWhitelist : public HttpAuthFilter {
36 public:
37 explicit HttpAuthFilterWhitelist(const std::string& server_whitelist);
38 ~HttpAuthFilterWhitelist() override;
40 // Adds an individual URL |filter| to the list, of the specified |target|.
41 bool AddFilter(const std::string& filter, HttpAuth::Target target);
43 // Adds a rule that bypasses all "local" hostnames.
44 void AddRuleToBypassLocal();
46 const ProxyBypassRules& rules() const { return rules_; }
48 // HttpAuthFilter methods:
49 bool IsValid(const GURL& url, HttpAuth::Target target) const override;
51 private:
52 // Installs the whitelist.
53 // |server_whitelist| is parsed by ProxyBypassRules.
54 void SetWhitelist(const std::string& server_whitelist);
56 // We are using ProxyBypassRules because they have the functionality that we
57 // want, but we are not using it for proxy bypass.
58 ProxyBypassRules rules_;
60 DISALLOW_COPY_AND_ASSIGN(HttpAuthFilterWhitelist);
63 } // namespace net
65 #endif // NET_HTTP_HTTP_AUTH_FILTER_H_