Chromium Code Reviews| 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 265c28447a8aebfbc0bd3d4089bb1cffc25a28df..1744bdb50ec751f27e2540b8c23b6e228142d695 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."; |
|
Bernhard Bauer
2011/04/15 18:38:47
Hm, this should already be covered by the JSON sch
battre
2011/04/26 15:31:30
I have added a TODO, in order to do this in a sepa
|
| + return false; |
| + } |
| + *out = mandatory_pac; |
| + return true; |
| +} |
| + |
| bool GetPacUrlFromExtensionPref(const DictionaryValue* proxy_config, |
| std::string* out, |
| std::string* error) { |
| @@ -271,6 +290,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, |
| @@ -298,7 +318,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: { |
| @@ -415,6 +436,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; |
| @@ -426,6 +452,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(); |
| } |