OLD | NEW |
1 // Copyright (c) 2012 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_SERVICE_H_ | 5 #ifndef NET_PROXY_PROXY_SERVICE_H_ |
6 #define NET_PROXY_PROXY_SERVICE_H_ | 6 #define NET_PROXY_PROXY_SERVICE_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 #include <set> | 11 #include <set> |
12 #include <string> | 12 #include <string> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/gtest_prod_util.h" | 15 #include "base/gtest_prod_util.h" |
16 #include "base/macros.h" | 16 #include "base/macros.h" |
17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
18 #include "base/synchronization/waitable_event.h" | 18 #include "base/synchronization/waitable_event.h" |
19 #include "base/threading/non_thread_safe.h" | 19 #include "base/threading/non_thread_safe.h" |
20 #include "net/base/completion_callback.h" | 20 #include "net/base/completion_callback.h" |
21 #include "net/base/load_states.h" | 21 #include "net/base/load_states.h" |
22 #include "net/base/net_export.h" | 22 #include "net/base/net_export.h" |
23 #include "net/base/network_change_notifier.h" | 23 #include "net/base/network_change_notifier.h" |
24 #include "net/log/net_log.h" | 24 #include "net/log/net_log.h" |
25 #include "net/proxy/proxy_config_service.h" | 25 #include "net/proxy/proxy_config_service.h" |
26 #include "net/proxy/proxy_info.h" | 26 #include "net/proxy/proxy_info.h" |
27 #include "net/proxy/proxy_server.h" | 27 #include "net/proxy/proxy_server.h" |
| 28 #include "url/gurl.h" |
28 | 29 |
29 class GURL; | 30 class GURL; |
30 | 31 |
31 namespace base { | 32 namespace base { |
32 class SingleThreadTaskRunner; | 33 class SingleThreadTaskRunner; |
33 class TimeDelta; | 34 class TimeDelta; |
34 } // namespace base | 35 } // namespace base |
35 | 36 |
36 namespace net { | 37 namespace net { |
37 | 38 |
38 class DhcpProxyScriptFetcher; | 39 class DhcpProxyScriptFetcher; |
39 class HostResolver; | 40 class HostResolver; |
40 class ProxyDelegate; | 41 class ProxyDelegate; |
41 class ProxyResolver; | 42 class ProxyResolver; |
42 class ProxyResolverFactory; | 43 class ProxyResolverFactory; |
43 class ProxyResolverScriptData; | 44 class ProxyResolverScriptData; |
44 class ProxyScriptDecider; | 45 class ProxyScriptDecider; |
45 class ProxyScriptFetcher; | 46 class ProxyScriptFetcher; |
46 | 47 |
47 // This class can be used to resolve the proxy server to use when loading a | 48 // This class can be used to resolve the proxy server to use when loading a |
48 // HTTP(S) URL. It uses the given ProxyResolver to handle the actual proxy | 49 // HTTP(S) URL. It uses the given ProxyResolver to handle the actual proxy |
49 // resolution. See ProxyResolverV8 for example. | 50 // resolution. See ProxyResolverV8 for example. |
50 class NET_EXPORT ProxyService : public NetworkChangeNotifier::IPAddressObserver, | 51 class NET_EXPORT ProxyService : public NetworkChangeNotifier::IPAddressObserver, |
51 public NetworkChangeNotifier::DNSObserver, | 52 public NetworkChangeNotifier::DNSObserver, |
52 public ProxyConfigService::Observer, | 53 public ProxyConfigService::Observer, |
53 NON_EXPORTED_BASE(public base::NonThreadSafe) { | 54 NON_EXPORTED_BASE(public base::NonThreadSafe) { |
54 public: | 55 public: |
| 56 // Enumerates the policy to use when sanitizing URLs for proxy resolution |
| 57 // (before passing them off to PAC scripts). |
| 58 enum class SanitizeUrlPolicy { |
| 59 // Do a basic level of sanitization for URLs: |
| 60 // - strip embedded identities (ex: "username:password@") |
| 61 // - strip the fragment (ex: "#blah") |
| 62 // |
| 63 // This is considered "unsafe" because it does not do any additional |
| 64 // stripping for https:// URLs. |
| 65 UNSAFE, |
| 66 |
| 67 // SAFE does the same sanitization as UNSAFE, but additionally strips |
| 68 // everything but the (scheme,host,port) from cryptographic URL schemes |
| 69 // (https:// and wss://). |
| 70 // |
| 71 // In other words, it strips the path and query portion of https:// URLs. |
| 72 SAFE, |
| 73 }; |
| 74 |
55 static const size_t kDefaultNumPacThreads = 4; | 75 static const size_t kDefaultNumPacThreads = 4; |
56 | 76 |
57 // This interface defines the set of policies for when to poll the PAC | 77 // This interface defines the set of policies for when to poll the PAC |
58 // script for changes. | 78 // script for changes. |
59 // | 79 // |
60 // The polling policy decides what the next poll delay should be in | 80 // The polling policy decides what the next poll delay should be in |
61 // milliseconds. It also decides how to wait for this delay -- either | 81 // milliseconds. It also decides how to wait for this delay -- either |
62 // by starting a timer to do the poll at exactly |next_delay_ms| | 82 // by starting a timer to do the poll at exactly |next_delay_ms| |
63 // (MODE_USE_TIMER) or by waiting for the first network request issued after | 83 // (MODE_USE_TIMER) or by waiting for the first network request issued after |
64 // |next_delay_ms| (MODE_START_AFTER_ACTIVITY). | 84 // |next_delay_ms| (MODE_START_AFTER_ACTIVITY). |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 const PacPollPolicy* policy); | 309 const PacPollPolicy* policy); |
290 | 310 |
291 // This method should only be used by unit tests. Creates an instance | 311 // This method should only be used by unit tests. Creates an instance |
292 // of the default internal PacPollPolicy used by ProxyService. | 312 // of the default internal PacPollPolicy used by ProxyService. |
293 static std::unique_ptr<PacPollPolicy> CreateDefaultPacPollPolicy(); | 313 static std::unique_ptr<PacPollPolicy> CreateDefaultPacPollPolicy(); |
294 | 314 |
295 void set_quick_check_enabled(bool value) { | 315 void set_quick_check_enabled(bool value) { |
296 quick_check_enabled_ = value; | 316 quick_check_enabled_ = value; |
297 } | 317 } |
298 | 318 |
| 319 void set_sanitize_url_policy(SanitizeUrlPolicy policy) { |
| 320 sanitize_url_policy_ = policy; |
| 321 } |
| 322 |
299 private: | 323 private: |
300 FRIEND_TEST_ALL_PREFIXES(ProxyServiceTest, UpdateConfigAfterFailedAutodetect); | 324 FRIEND_TEST_ALL_PREFIXES(ProxyServiceTest, UpdateConfigAfterFailedAutodetect); |
301 FRIEND_TEST_ALL_PREFIXES(ProxyServiceTest, UpdateConfigFromPACToDirect); | 325 FRIEND_TEST_ALL_PREFIXES(ProxyServiceTest, UpdateConfigFromPACToDirect); |
302 friend class PacRequest; | 326 friend class PacRequest; |
303 class InitProxyResolver; | 327 class InitProxyResolver; |
304 class ProxyScriptDeciderPoller; | 328 class ProxyScriptDeciderPoller; |
305 | 329 |
306 typedef std::set<scoped_refptr<PacRequest>> PendingRequests; | 330 typedef std::set<scoped_refptr<PacRequest>> PendingRequests; |
307 | 331 |
308 enum State { | 332 enum State { |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 // The earliest time at which we should run any proxy auto-config. (Used to | 477 // The earliest time at which we should run any proxy auto-config. (Used to |
454 // stall re-configuration following an IP address change). | 478 // stall re-configuration following an IP address change). |
455 base::TimeTicks stall_proxy_autoconfig_until_; | 479 base::TimeTicks stall_proxy_autoconfig_until_; |
456 | 480 |
457 // The amount of time to stall requests following IP address changes. | 481 // The amount of time to stall requests following IP address changes. |
458 base::TimeDelta stall_proxy_auto_config_delay_; | 482 base::TimeDelta stall_proxy_auto_config_delay_; |
459 | 483 |
460 // Whether child ProxyScriptDeciders should use QuickCheck | 484 // Whether child ProxyScriptDeciders should use QuickCheck |
461 bool quick_check_enabled_; | 485 bool quick_check_enabled_; |
462 | 486 |
| 487 // The method to use for sanitizing URLs seen by the proxy resolver. |
| 488 SanitizeUrlPolicy sanitize_url_policy_; |
| 489 |
463 DISALLOW_COPY_AND_ASSIGN(ProxyService); | 490 DISALLOW_COPY_AND_ASSIGN(ProxyService); |
464 }; | 491 }; |
465 | 492 |
466 } // namespace net | 493 } // namespace net |
467 | 494 |
468 #endif // NET_PROXY_PROXY_SERVICE_H_ | 495 #endif // NET_PROXY_PROXY_SERVICE_H_ |
OLD | NEW |