OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef NET_PROXY_PROXY_CONFIG_H_ | 5 #ifndef NET_PROXY_PROXY_CONFIG_H_ |
6 #define NET_PROXY_PROXY_CONFIG_H_ | 6 #define NET_PROXY_PROXY_CONFIG_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "googleurl/src/gurl.h" | 11 #include "googleurl/src/gurl.h" |
12 #include "net/base/net_export.h" | 12 #include "net/base/net_export.h" |
13 #include "net/proxy/proxy_config_source.h" | |
eroman
2012/05/18 03:58:56
I believe this should be sorted lower.
asanka
2012/05/18 16:27:01
Done.
| |
13 #include "net/proxy/proxy_bypass_rules.h" | 14 #include "net/proxy/proxy_bypass_rules.h" |
14 #include "net/proxy/proxy_server.h" | 15 #include "net/proxy/proxy_server.h" |
15 | 16 |
16 namespace base { | 17 namespace base { |
17 class Value; | 18 class Value; |
18 } | 19 } |
19 | 20 |
20 namespace net { | 21 namespace net { |
21 | 22 |
22 class ProxyInfo; | 23 class ProxyInfo; |
(...skipping 22 matching lines...) Expand all Loading... | |
45 | 46 |
46 // Note that the default of TYPE_NO_RULES results in direct connections | 47 // Note that the default of TYPE_NO_RULES results in direct connections |
47 // being made when using this ProxyConfig. | 48 // being made when using this ProxyConfig. |
48 ProxyRules(); | 49 ProxyRules(); |
49 ~ProxyRules(); | 50 ~ProxyRules(); |
50 | 51 |
51 bool empty() const { | 52 bool empty() const { |
52 return type == TYPE_NO_RULES; | 53 return type == TYPE_NO_RULES; |
53 } | 54 } |
54 | 55 |
55 // Sets |result| with the proxy to use for |url| based on the current rules. | 56 // Sets |result| with the proxy to use for |url| based on the current |
56 void Apply(const GURL& url, ProxyInfo* result); | 57 // rules. Returns true if applicable rules were found and |result| was set |
58 // accordingly. If no rules are applicable, sets |result| to use direct | |
59 // connections and returns false. | |
60 bool Apply(const GURL& url, ProxyInfo* result) const; | |
57 | 61 |
58 // Parses the rules from a string, indicating which proxies to use. | 62 // Parses the rules from a string, indicating which proxies to use. |
59 // | 63 // |
60 // proxy-uri = [<proxy-scheme>"://"]<proxy-host>[":"<proxy-port>] | 64 // proxy-uri = [<proxy-scheme>"://"]<proxy-host>[":"<proxy-port>] |
61 // | 65 // |
62 // If the proxy to use depends on the scheme of the URL, can instead specify | 66 // If the proxy to use depends on the scheme of the URL, can instead specify |
63 // a semicolon separated list of: | 67 // a semicolon separated list of: |
64 // | 68 // |
65 // <url-scheme>"="<proxy-uri> | 69 // <url-scheme>"="<proxy-uri> |
66 // | 70 // |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
115 ProxyConfig(); | 119 ProxyConfig(); |
116 ProxyConfig(const ProxyConfig& config); | 120 ProxyConfig(const ProxyConfig& config); |
117 ~ProxyConfig(); | 121 ~ProxyConfig(); |
118 ProxyConfig& operator=(const ProxyConfig& config); | 122 ProxyConfig& operator=(const ProxyConfig& config); |
119 | 123 |
120 // Used to numerically identify this configuration. | 124 // Used to numerically identify this configuration. |
121 ID id() const { return id_; } | 125 ID id() const { return id_; } |
122 void set_id(ID id) { id_ = id; } | 126 void set_id(ID id) { id_ = id; } |
123 bool is_valid() const { return id_ != kInvalidConfigID; } | 127 bool is_valid() const { return id_ != kInvalidConfigID; } |
124 | 128 |
125 // Returns true if the given config is equivalent to this config. | 129 // Returns true if the given config is equivalent to this config. The |
130 // comparison ignores differences in |id()| and |source()|. | |
126 bool Equals(const ProxyConfig& other) const; | 131 bool Equals(const ProxyConfig& other) const; |
127 | 132 |
128 // Returns true if this config contains any "automatic" settings. See the | 133 // Returns true if this config contains any "automatic" settings. See the |
129 // class description for what that means. | 134 // class description for what that means. |
130 bool HasAutomaticSettings() const; | 135 bool HasAutomaticSettings() const; |
131 | 136 |
132 void ClearAutomaticSettings(); | 137 void ClearAutomaticSettings(); |
133 | 138 |
134 // Creates a Value dump of this configuration. The caller is responsible for | 139 // Creates a Value dump of this configuration. The caller is responsible for |
135 // deleting the returned value. | 140 // deleting the returned value. |
(...skipping 28 matching lines...) Expand all Loading... | |
164 } | 169 } |
165 | 170 |
166 void set_auto_detect(bool enable_auto_detect) { | 171 void set_auto_detect(bool enable_auto_detect) { |
167 auto_detect_ = enable_auto_detect; | 172 auto_detect_ = enable_auto_detect; |
168 } | 173 } |
169 | 174 |
170 bool auto_detect() const { | 175 bool auto_detect() const { |
171 return auto_detect_; | 176 return auto_detect_; |
172 } | 177 } |
173 | 178 |
179 void set_source(ProxyConfigSource source) { | |
180 source_ = source; | |
181 } | |
182 | |
183 ProxyConfigSource source() const { | |
184 return source_; | |
185 } | |
186 | |
174 // Helpers to construct some common proxy configurations. | 187 // Helpers to construct some common proxy configurations. |
175 | 188 |
176 static ProxyConfig CreateDirect() { | 189 static ProxyConfig CreateDirect() { |
177 return ProxyConfig(); | 190 return ProxyConfig(); |
178 } | 191 } |
179 | 192 |
180 static ProxyConfig CreateAutoDetect() { | 193 static ProxyConfig CreateAutoDetect() { |
181 ProxyConfig config; | 194 ProxyConfig config; |
182 config.set_auto_detect(true); | 195 config.set_auto_detect(true); |
183 return config; | 196 return config; |
(...skipping 14 matching lines...) Expand all Loading... | |
198 // If non-empty, indicates the URL of the proxy auto-config file to use. | 211 // If non-empty, indicates the URL of the proxy auto-config file to use. |
199 GURL pac_url_; | 212 GURL pac_url_; |
200 | 213 |
201 // If true, blocks all traffic in case fetching the pac script from |pac_url_| | 214 // If true, blocks all traffic in case fetching the pac script from |pac_url_| |
202 // fails. Only valid if |pac_url_| is non-empty. | 215 // fails. Only valid if |pac_url_| is non-empty. |
203 bool pac_mandatory_; | 216 bool pac_mandatory_; |
204 | 217 |
205 // Manual proxy settings. | 218 // Manual proxy settings. |
206 ProxyRules proxy_rules_; | 219 ProxyRules proxy_rules_; |
207 | 220 |
221 // Source of proxy settings. | |
222 ProxyConfigSource source_; | |
223 | |
208 ID id_; | 224 ID id_; |
209 }; | 225 }; |
210 | 226 |
211 } // namespace net | 227 } // namespace net |
212 | 228 |
213 | 229 |
214 | 230 |
215 #endif // NET_PROXY_PROXY_CONFIG_H_ | 231 #endif // NET_PROXY_PROXY_CONFIG_H_ |
OLD | NEW |