| 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_bypass_rules.h" | 13 #include "net/proxy/proxy_bypass_rules.h" |
| 14 #include "net/proxy/proxy_config_source.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; |
| 23 | 24 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 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 rules. |
| 56 void Apply(const GURL& url, ProxyInfo* result); | 57 void Apply(const GURL& url, ProxyInfo* result) const; |
| 57 | 58 |
| 58 // Parses the rules from a string, indicating which proxies to use. | 59 // Parses the rules from a string, indicating which proxies to use. |
| 59 // | 60 // |
| 60 // proxy-uri = [<proxy-scheme>"://"]<proxy-host>[":"<proxy-port>] | 61 // proxy-uri = [<proxy-scheme>"://"]<proxy-host>[":"<proxy-port>] |
| 61 // | 62 // |
| 62 // If the proxy to use depends on the scheme of the URL, can instead specify | 63 // If the proxy to use depends on the scheme of the URL, can instead specify |
| 63 // a semicolon separated list of: | 64 // a semicolon separated list of: |
| 64 // | 65 // |
| 65 // <url-scheme>"="<proxy-uri> | 66 // <url-scheme>"="<proxy-uri> |
| 66 // | 67 // |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 ProxyConfig(); | 116 ProxyConfig(); |
| 116 ProxyConfig(const ProxyConfig& config); | 117 ProxyConfig(const ProxyConfig& config); |
| 117 ~ProxyConfig(); | 118 ~ProxyConfig(); |
| 118 ProxyConfig& operator=(const ProxyConfig& config); | 119 ProxyConfig& operator=(const ProxyConfig& config); |
| 119 | 120 |
| 120 // Used to numerically identify this configuration. | 121 // Used to numerically identify this configuration. |
| 121 ID id() const { return id_; } | 122 ID id() const { return id_; } |
| 122 void set_id(ID id) { id_ = id; } | 123 void set_id(ID id) { id_ = id; } |
| 123 bool is_valid() const { return id_ != kInvalidConfigID; } | 124 bool is_valid() const { return id_ != kInvalidConfigID; } |
| 124 | 125 |
| 125 // Returns true if the given config is equivalent to this config. | 126 // Returns true if the given config is equivalent to this config. The |
| 127 // comparison ignores differences in |id()| and |source()|. |
| 126 bool Equals(const ProxyConfig& other) const; | 128 bool Equals(const ProxyConfig& other) const; |
| 127 | 129 |
| 128 // Returns true if this config contains any "automatic" settings. See the | 130 // Returns true if this config contains any "automatic" settings. See the |
| 129 // class description for what that means. | 131 // class description for what that means. |
| 130 bool HasAutomaticSettings() const; | 132 bool HasAutomaticSettings() const; |
| 131 | 133 |
| 132 void ClearAutomaticSettings(); | 134 void ClearAutomaticSettings(); |
| 133 | 135 |
| 134 // Creates a Value dump of this configuration. The caller is responsible for | 136 // Creates a Value dump of this configuration. The caller is responsible for |
| 135 // deleting the returned value. | 137 // deleting the returned value. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 164 } | 166 } |
| 165 | 167 |
| 166 void set_auto_detect(bool enable_auto_detect) { | 168 void set_auto_detect(bool enable_auto_detect) { |
| 167 auto_detect_ = enable_auto_detect; | 169 auto_detect_ = enable_auto_detect; |
| 168 } | 170 } |
| 169 | 171 |
| 170 bool auto_detect() const { | 172 bool auto_detect() const { |
| 171 return auto_detect_; | 173 return auto_detect_; |
| 172 } | 174 } |
| 173 | 175 |
| 176 void set_source(ProxyConfigSource source) { |
| 177 source_ = source; |
| 178 } |
| 179 |
| 180 ProxyConfigSource source() const { |
| 181 return source_; |
| 182 } |
| 183 |
| 174 // Helpers to construct some common proxy configurations. | 184 // Helpers to construct some common proxy configurations. |
| 175 | 185 |
| 176 static ProxyConfig CreateDirect() { | 186 static ProxyConfig CreateDirect() { |
| 177 return ProxyConfig(); | 187 return ProxyConfig(); |
| 178 } | 188 } |
| 179 | 189 |
| 180 static ProxyConfig CreateAutoDetect() { | 190 static ProxyConfig CreateAutoDetect() { |
| 181 ProxyConfig config; | 191 ProxyConfig config; |
| 182 config.set_auto_detect(true); | 192 config.set_auto_detect(true); |
| 183 return config; | 193 return config; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 198 // If non-empty, indicates the URL of the proxy auto-config file to use. | 208 // If non-empty, indicates the URL of the proxy auto-config file to use. |
| 199 GURL pac_url_; | 209 GURL pac_url_; |
| 200 | 210 |
| 201 // If true, blocks all traffic in case fetching the pac script from |pac_url_| | 211 // If true, blocks all traffic in case fetching the pac script from |pac_url_| |
| 202 // fails. Only valid if |pac_url_| is non-empty. | 212 // fails. Only valid if |pac_url_| is non-empty. |
| 203 bool pac_mandatory_; | 213 bool pac_mandatory_; |
| 204 | 214 |
| 205 // Manual proxy settings. | 215 // Manual proxy settings. |
| 206 ProxyRules proxy_rules_; | 216 ProxyRules proxy_rules_; |
| 207 | 217 |
| 218 // Source of proxy settings. |
| 219 ProxyConfigSource source_; |
| 220 |
| 208 ID id_; | 221 ID id_; |
| 209 }; | 222 }; |
| 210 | 223 |
| 211 } // namespace net | 224 } // namespace net |
| 212 | 225 |
| 213 | 226 |
| 214 | 227 |
| 215 #endif // NET_PROXY_PROXY_CONFIG_H_ | 228 #endif // NET_PROXY_PROXY_CONFIG_H_ |
| OLD | NEW |