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

Unified Diff: net/proxy/proxy_service.cc

Issue 6871019: Enable (optional) blocking of webrequests in case a PAC script cannot be fetched or is invalid. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments Created 9 years, 8 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 side-by-side diff with in-line comments
Download patch
« net/proxy/proxy_config.cc ('K') | « net/proxy/proxy_service.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/proxy/proxy_service.cc
diff --git a/net/proxy/proxy_service.cc b/net/proxy/proxy_service.cc
index ca3629ebcdcdb6361921b2daf14d0b1bd7acd984..3915f86a7b05d76a2e0ea1c5aa189190b9671a3b 100644
--- a/net/proxy/proxy_service.cc
+++ b/net/proxy/proxy_service.cc
@@ -552,6 +552,11 @@ int ProxyService::TryToCompleteSynchronously(const GURL& url,
DCHECK_NE(config_.id(), ProxyConfig::INVALID_ID);
+ // If it was impossible to fetch or parse the PAC script, we cannot complete
+ // the request here and bail out.
+ if (permanent_error_ != OK)
+ return permanent_error_;
+
if (config_.HasAutomaticSettings())
return ERR_IO_PENDING; // Must submit the request to the proxy resolver.
@@ -642,11 +647,20 @@ void ProxyService::OnInitProxyResolverComplete(int result) {
init_proxy_resolver_.reset();
if (result != OK) {
- VLOG(1) << "Failed configuring with PAC script, falling-back to manual "
- "proxy servers.";
- config_ = fetched_config_;
- config_.ClearAutomaticSettings();
+ if (fetched_config_.pac_mandatory()) {
+ VLOG(1) << "Failed configuring with mandatory PAC script, blocking all "
+ "traffic.";
+ config_ = fetched_config_;
+ result = ERR_MANDATORY_PROXY_CONFIGURATION_FAILED;
+ } else {
+ VLOG(1) << "Failed configuring with PAC script, falling-back to manual "
+ "proxy servers.";
+ config_ = fetched_config_;
+ config_.ClearAutomaticSettings();
+ result = OK;
+ }
}
+ permanent_error_ = result;
config_.set_id(fetched_config_.id());
@@ -723,15 +737,19 @@ int ProxyService::DidFinishResolvingProxy(ProxyInfo* result,
make_scoped_refptr(new NetLogIntegerParameter(
"net_error", result_code)));
- // Fall-back to direct when the proxy resolver fails. This corresponds
- // with a javascript runtime error in the PAC script.
- //
- // This implicit fall-back to direct matches Firefox 3.5 and
- // Internet Explorer 8. For more information, see:
- //
- // http://www.chromium.org/developers/design-documents/proxy-settings-fallback
- result->UseDirect();
- result_code = OK;
+ if (!config_.pac_mandatory()) {
+ // Fall-back to direct when the proxy resolver fails. This corresponds
+ // with a javascript runtime error in the PAC script.
+ //
+ // This implicit fall-back to direct matches Firefox 3.5 and
+ // Internet Explorer 8. For more information, see:
+ //
+ // http://www.chromium.org/developers/design-documents/proxy-settings-fallback
+ result->UseDirect();
+ result_code = OK;
+ } else {
+ result_code = ERR_MANDATORY_PROXY_CONFIGURATION_FAILED;
+ }
}
net_log.EndEvent(NetLog::TYPE_PROXY_SERVICE, NULL);
@@ -756,6 +774,7 @@ ProxyService::State ProxyService::ResetProxyConfig(bool reset_fetched_config) {
DCHECK(CalledOnValidThread());
State previous_state = current_state_;
+ permanent_error_ = OK;
proxy_retry_info_.clear();
init_proxy_resolver_.reset();
SuspendAllPendingRequests();
« net/proxy/proxy_config.cc ('K') | « net/proxy/proxy_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698