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

Unified Diff: chrome/browser/extensions/extension_proxy_api_helpers.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/extensions/extension_proxy_api_helpers.cc
diff --git a/chrome/browser/extensions/extension_proxy_api_helpers.cc b/chrome/browser/extensions/extension_proxy_api_helpers.cc
index 642984305fd72c96304bf55253625c462f0257d6..8c258b093489bcaa35628f34f0a5b472de37d013 100644
--- a/chrome/browser/extensions/extension_proxy_api_helpers.cc
+++ b/chrome/browser/extensions/extension_proxy_api_helpers.cc
@@ -72,6 +72,25 @@ bool GetProxyModeFromExtensionPref(const DictionaryValue* proxy_config,
return true;
}
+bool GetPacMandatoryFromExtensionPref(const DictionaryValue* proxy_config,
+ bool* out,
+ std::string* error){
+ DictionaryValue* pac_dict = NULL;
+ proxy_config->GetDictionary(keys::kProxyConfigPacScript, &pac_dict);
+ if (!pac_dict)
+ return true;
+
+ bool mandatory_pac = false;
+ if (pac_dict->HasKey(keys::kProxyConfigPacScriptMandatory) &&
+ !pac_dict->GetBoolean(keys::kProxyConfigPacScriptMandatory,
+ &mandatory_pac)) {
+ LOG(ERROR) << "'pacScript.mandatory' could not be parsed.";
+ return false;
+ }
+ *out = mandatory_pac;
+ return true;
+}
+
bool GetPacUrlFromExtensionPref(const DictionaryValue* proxy_config,
std::string* out,
std::string* error) {
@@ -272,6 +291,7 @@ bool GetBypassListFromExtensionPref(const DictionaryValue* proxy_config,
}
DictionaryValue* CreateProxyConfigDict(ProxyPrefs::ProxyMode mode_enum,
+ bool pac_mandatory,
const std::string& pac_url,
const std::string& pac_data,
const std::string& proxy_rules_string,
@@ -299,7 +319,8 @@ DictionaryValue* CreateProxyConfigDict(ProxyPrefs::ProxyMode mode_enum,
"either a 'url' field or a 'data' field.";
return NULL;
}
- result_proxy_config = ProxyConfigDictionary::CreatePacScript(url);
+ result_proxy_config =
+ ProxyConfigDictionary::CreatePacScript(url, pac_mandatory);
break;
}
case ProxyPrefs::MODE_FIXED_SERVERS: {
@@ -419,6 +440,11 @@ DictionaryValue* CreatePacScriptDict(
LOG(ERROR) << "Invalid proxy configuration. Missing PAC URL.";
return NULL;
}
+ bool pac_mandatory = false;
+ if (!proxy_config.GetPacMandatory(&pac_mandatory)) {
+ LOG(ERROR) << "Invalid proxy configuration. Missing PAC mandatory field.";
+ return NULL;
+ }
if (pac_url.find("data") == 0) {
std::string pac_data;
@@ -430,6 +456,8 @@ DictionaryValue* CreatePacScriptDict(
} else {
pac_script_dict->SetString(keys::kProxyConfigPacScriptUrl, pac_url);
}
+ pac_script_dict->SetBoolean(keys::kProxyConfigPacScriptMandatory,
+ pac_mandatory);
return pac_script_dict.release();
}

Powered by Google App Engine
This is Rietveld 408576698