Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(884)

Side by Side Diff: net/http/http_auth_filter.cc

Issue 6339012: More net/ method ordering. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More done while waiting for previous patch to clear Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/http/http_auth_filter.h ('k') | net/http/http_auth_handler_digest.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_filter.h" 5 #include "net/http/http_auth_filter.h"
6 #include "base/string_util.h" 6 #include "base/string_util.h"
7 #include "googleurl/src/gurl.h" 7 #include "googleurl/src/gurl.h"
8 8
9 namespace net { 9 namespace net {
10 10
11 // Using a std::set<> has the benefit of removing duplicates automatically. 11 // Using a std::set<> has the benefit of removing duplicates automatically.
12 typedef std::set<string16> RegistryWhitelist; 12 typedef std::set<string16> RegistryWhitelist;
13 13
14 // TODO(ahendrickson) -- Determine if we want separate whitelists for HTTP and 14 // TODO(ahendrickson) -- Determine if we want separate whitelists for HTTP and
15 // HTTPS, one for both, or only an HTTP one. My understanding is that the HTTPS 15 // HTTPS, one for both, or only an HTTP one. My understanding is that the HTTPS
16 // entries in the registry mean that you are only allowed to connect to the site 16 // entries in the registry mean that you are only allowed to connect to the site
17 // via HTTPS and still be considered 'safe'. 17 // via HTTPS and still be considered 'safe'.
18 18
19 HttpAuthFilterWhitelist::HttpAuthFilterWhitelist( 19 HttpAuthFilterWhitelist::HttpAuthFilterWhitelist(
20 const std::string& server_whitelist) { 20 const std::string& server_whitelist) {
21 SetWhitelist(server_whitelist); 21 SetWhitelist(server_whitelist);
22 } 22 }
23 23
24 HttpAuthFilterWhitelist::~HttpAuthFilterWhitelist() { 24 HttpAuthFilterWhitelist::~HttpAuthFilterWhitelist() {
25 } 25 }
26 26
27 void HttpAuthFilterWhitelist::SetWhitelist(
28 const std::string& server_whitelist) {
29 rules_.ParseFromString(server_whitelist);
30 }
31
32 bool HttpAuthFilterWhitelist::IsValid(const GURL& url,
33 HttpAuth::Target target) const {
34 if ((target != HttpAuth::AUTH_SERVER) && (target != HttpAuth::AUTH_PROXY))
35 return false;
36 // All proxies pass
37 if (target == HttpAuth::AUTH_PROXY)
38 return true;
39 return rules_.Matches(url);
40 }
41
42 // Add a new domain |filter| to the whitelist, if it's not already there 27 // Add a new domain |filter| to the whitelist, if it's not already there
43 bool HttpAuthFilterWhitelist::AddFilter(const std::string& filter, 28 bool HttpAuthFilterWhitelist::AddFilter(const std::string& filter,
44 HttpAuth::Target target) { 29 HttpAuth::Target target) {
45 if ((target != HttpAuth::AUTH_SERVER) && (target != HttpAuth::AUTH_PROXY)) 30 if ((target != HttpAuth::AUTH_SERVER) && (target != HttpAuth::AUTH_PROXY))
46 return false; 31 return false;
47 // All proxies pass 32 // All proxies pass
48 if (target == HttpAuth::AUTH_PROXY) 33 if (target == HttpAuth::AUTH_PROXY)
49 return true; 34 return true;
50 rules_.AddRuleFromString(filter); 35 rules_.AddRuleFromString(filter);
51 return true; 36 return true;
52 } 37 }
53 38
54 void HttpAuthFilterWhitelist::AddRuleToBypassLocal() { 39 void HttpAuthFilterWhitelist::AddRuleToBypassLocal() {
55 rules_.AddRuleToBypassLocal(); 40 rules_.AddRuleToBypassLocal();
56 } 41 }
57 42
43 bool HttpAuthFilterWhitelist::IsValid(const GURL& url,
44 HttpAuth::Target target) const {
45 if ((target != HttpAuth::AUTH_SERVER) && (target != HttpAuth::AUTH_PROXY))
46 return false;
47 // All proxies pass
48 if (target == HttpAuth::AUTH_PROXY)
49 return true;
50 return rules_.Matches(url);
51 }
52
53 void HttpAuthFilterWhitelist::SetWhitelist(
54 const std::string& server_whitelist) {
55 rules_.ParseFromString(server_whitelist);
56 }
57
58 } // namespace net 58 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_auth_filter.h ('k') | net/http/http_auth_handler_digest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698