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

Unified Diff: chrome/browser/prefs/proxy_config_dictionary.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
Index: chrome/browser/prefs/proxy_config_dictionary.cc
diff --git a/chrome/browser/prefs/proxy_config_dictionary.cc b/chrome/browser/prefs/proxy_config_dictionary.cc
index 0c063cd826ff1283fa12c99eac3c551cabf75d08..a99fa7ca2d4bdd09ff98719805d1b866bc879ed3 100644
--- a/chrome/browser/prefs/proxy_config_dictionary.cc
+++ b/chrome/browser/prefs/proxy_config_dictionary.cc
@@ -19,6 +19,10 @@ const char kProxyMode[] = "mode";
const char kProxyServer[] = "server";
// URL to the proxy .pac file.
const char kProxyPacUrl[] = "pac_url";
+// Optional boolean flag indicating whether a valid PAC script is mandatory.
+// If true, network traffic does not fall back to direct connections in case the
+// PAC script is not available.
+const char kProxyPacMandatory[] = "pac_mandatory";
// String containing proxy bypass rules. For a specification of the
// expected syntax see net::ProxyBypassRules::ParseFromString().
const char kProxyBypassList[] = "bypass_list";
@@ -41,6 +45,14 @@ bool ProxyConfigDictionary::GetPacUrl(std::string* out) const {
return dict_->GetString(kProxyPacUrl, out);
}
+bool ProxyConfigDictionary::GetPacMandatory(bool* out) const {
+ if (!dict_->HasKey(kProxyPacMandatory)) {
+ *out = false;
+ return true;
+ }
+ return dict_->GetBoolean(kProxyPacMandatory, out);
+}
+
bool ProxyConfigDictionary::GetProxyServer(std::string* out) const {
return dict_->GetString(kProxyServer, out);
}
@@ -55,18 +67,20 @@ bool ProxyConfigDictionary::HasBypassList() const {
// static
DictionaryValue* ProxyConfigDictionary::CreateDirect() {
- return CreateDictionary(ProxyPrefs::MODE_DIRECT, "", "", "");
+ return CreateDictionary(ProxyPrefs::MODE_DIRECT, "", false, "", "");
}
// static
DictionaryValue* ProxyConfigDictionary::CreateAutoDetect() {
- return CreateDictionary(ProxyPrefs::MODE_AUTO_DETECT, "", "", "");
+ return CreateDictionary(ProxyPrefs::MODE_AUTO_DETECT, "", false, "", "");
}
// static
DictionaryValue* ProxyConfigDictionary::CreatePacScript(
- const std::string& pac_url) {
- return CreateDictionary(ProxyPrefs::MODE_PAC_SCRIPT, pac_url, "", "");
+ const std::string& pac_url,
+ bool pac_mandatory) {
+ return CreateDictionary(ProxyPrefs::MODE_PAC_SCRIPT,
+ pac_url, pac_mandatory, "", "");
}
// static
@@ -75,7 +89,7 @@ DictionaryValue* ProxyConfigDictionary::CreateFixedServers(
const std::string& bypass_list) {
if (!proxy_server.empty()) {
return CreateDictionary(
- ProxyPrefs::MODE_FIXED_SERVERS, "", proxy_server, bypass_list);
+ ProxyPrefs::MODE_FIXED_SERVERS, "", false, proxy_server, bypass_list);
} else {
return CreateDirect();
}
@@ -83,19 +97,22 @@ DictionaryValue* ProxyConfigDictionary::CreateFixedServers(
// static
DictionaryValue* ProxyConfigDictionary::CreateSystem() {
- return CreateDictionary(ProxyPrefs::MODE_SYSTEM, "", "", "");
+ return CreateDictionary(ProxyPrefs::MODE_SYSTEM, "", false, "", "");
}
// static
DictionaryValue* ProxyConfigDictionary::CreateDictionary(
ProxyPrefs::ProxyMode mode,
const std::string& pac_url,
+ bool pac_mandatory,
const std::string& proxy_server,
const std::string& bypass_list) {
DictionaryValue* dict = new DictionaryValue();
dict->SetString(kProxyMode, ProxyModeToString(mode));
- if (!pac_url.empty())
+ if (!pac_url.empty()) {
dict->SetString(kProxyPacUrl, pac_url);
+ dict->SetBoolean(kProxyPacMandatory, pac_mandatory);
+ }
if (!proxy_server.empty())
dict->SetString(kProxyServer, proxy_server);
if (!bypass_list.empty())
« no previous file with comments | « chrome/browser/prefs/proxy_config_dictionary.h ('k') | chrome/browser/prefs/proxy_config_dictionary_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698