Chromium Code Reviews| 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 #include "net/proxy/proxy_service.h" | 5 #include "net/proxy/proxy_service.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 342 void AddObserver(Observer* observer) override {} | 342 void AddObserver(Observer* observer) override {} |
| 343 void RemoveObserver(Observer* observer) override {} | 343 void RemoveObserver(Observer* observer) override {} |
| 344 ConfigAvailability GetLatestProxyConfig(ProxyConfig* config) override { | 344 ConfigAvailability GetLatestProxyConfig(ProxyConfig* config) override { |
| 345 return CONFIG_UNSET; | 345 return CONFIG_UNSET; |
| 346 } | 346 } |
| 347 }; | 347 }; |
| 348 #endif | 348 #endif |
| 349 | 349 |
| 350 } // namespace | 350 } // namespace |
| 351 | 351 |
| 352 GURL SanitizeUrlForPacScript(const GURL& url, | |
| 353 SanitizeUrlForPacScriptPolicy policy) { | |
| 354 DCHECK(url.is_valid()); | |
| 355 GURL::Replacements replacements; | |
| 356 replacements.ClearUsername(); | |
| 357 replacements.ClearPassword(); | |
| 358 replacements.ClearRef(); | |
| 359 | |
| 360 if (policy == SanitizeUrlForPacScriptPolicy::SAFE && | |
| 361 url.SchemeIsCryptographic()) { | |
| 362 replacements.ClearPath(); | |
| 363 replacements.ClearQuery(); | |
| 364 } | |
|
mmenke
2016/05/19 22:33:23
An alternative approach would be to do:
if (polic
eroman
2016/05/19 23:26:05
I added a TODO to explore that, will follow-up.
T
| |
| 365 | |
| 366 return url.ReplaceComponents(replacements); | |
| 367 } | |
| 368 | |
| 352 // ProxyService::InitProxyResolver -------------------------------------------- | 369 // ProxyService::InitProxyResolver -------------------------------------------- |
| 353 | 370 |
| 354 // This glues together two asynchronous steps: | 371 // This glues together two asynchronous steps: |
| 355 // (1) ProxyScriptDecider -- try to fetch/validate a sequence of PAC scripts | 372 // (1) ProxyScriptDecider -- try to fetch/validate a sequence of PAC scripts |
| 356 // to figure out what we should configure against. | 373 // to figure out what we should configure against. |
| 357 // (2) Feed the fetched PAC script into the ProxyResolver. | 374 // (2) Feed the fetched PAC script into the ProxyResolver. |
| 358 // | 375 // |
| 359 // InitProxyResolver is a single-use class which encapsulates cancellation as | 376 // InitProxyResolver is a single-use class which encapsulates cancellation as |
| 360 // part of its destructor. Start() or StartSkipDecider() should be called just | 377 // part of its destructor. Start() or StartSkipDecider() should be called just |
| 361 // once. The instance can be destroyed at any time, and the request will be | 378 // once. The instance can be destroyed at any time, and the request will be |
| (...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1043 | 1060 |
| 1044 // Notify our polling-based dependencies that a resolve is taking place. | 1061 // Notify our polling-based dependencies that a resolve is taking place. |
| 1045 // This way they can schedule their polls in response to network activity. | 1062 // This way they can schedule their polls in response to network activity. |
| 1046 config_service_->OnLazyPoll(); | 1063 config_service_->OnLazyPoll(); |
| 1047 if (script_poller_.get()) | 1064 if (script_poller_.get()) |
| 1048 script_poller_->OnLazyPoll(); | 1065 script_poller_->OnLazyPoll(); |
| 1049 | 1066 |
| 1050 if (current_state_ == STATE_NONE) | 1067 if (current_state_ == STATE_NONE) |
| 1051 ApplyProxyConfigIfAvailable(); | 1068 ApplyProxyConfigIfAvailable(); |
| 1052 | 1069 |
| 1053 // Strip away any reference fragments and the username/password, as they | 1070 // Sanitize the URL before passing it on to the proxy resolver (i.e. PAC |
| 1054 // are not relevant to proxy resolution. | 1071 // script). The goal is to remove sensitive data (like embedded user names |
| 1055 GURL url = SimplifyUrlForRequest(raw_url); | 1072 // and password), and local data (i.e. reference fragment). |
| 1073 GURL url = | |
| 1074 SanitizeUrlForPacScript(raw_url, sanitize_url_for_pac_script_policy_); | |
|
mmenke
2016/05/19 22:33:23
Should we only do this when we create the PacReque
eroman
2016/05/19 23:26:05
I hope to merge this CL to M52 so don't want to ch
| |
| 1056 | 1075 |
| 1057 // Check if the request can be completed right away. (This is the case when | 1076 // Check if the request can be completed right away. (This is the case when |
| 1058 // using a direct connection for example). | 1077 // using a direct connection for example). |
| 1059 int rv = TryToCompleteSynchronously(url, load_flags, proxy_delegate, result); | 1078 int rv = TryToCompleteSynchronously(url, load_flags, proxy_delegate, result); |
| 1060 if (rv != ERR_IO_PENDING) { | 1079 if (rv != ERR_IO_PENDING) { |
| 1061 rv = DidFinishResolvingProxy( | 1080 rv = DidFinishResolvingProxy( |
| 1062 url, method, load_flags, proxy_delegate, result, rv, net_log, | 1081 url, method, load_flags, proxy_delegate, result, rv, net_log, |
| 1063 callback.is_null() ? TimeTicks() : TimeTicks::Now(), false); | 1082 callback.is_null() ? TimeTicks() : TimeTicks::Now(), false); |
| 1064 return rv; | 1083 return rv; |
| 1065 } | 1084 } |
| (...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1655 State previous_state = ResetProxyConfig(false); | 1674 State previous_state = ResetProxyConfig(false); |
| 1656 if (previous_state != STATE_NONE) | 1675 if (previous_state != STATE_NONE) |
| 1657 ApplyProxyConfigIfAvailable(); | 1676 ApplyProxyConfigIfAvailable(); |
| 1658 } | 1677 } |
| 1659 | 1678 |
| 1660 void ProxyService::OnDNSChanged() { | 1679 void ProxyService::OnDNSChanged() { |
| 1661 OnIPAddressChanged(); | 1680 OnIPAddressChanged(); |
| 1662 } | 1681 } |
| 1663 | 1682 |
| 1664 } // namespace net | 1683 } // namespace net |
| OLD | NEW |