| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Implementation of the Chrome Extensions Proxy Settings API. | 5 // Implementation of the Chrome Extensions Proxy Settings API. |
| 6 | 6 |
| 7 #include "chrome/browser/extensions/extension_proxy_api.h" | 7 #include "chrome/browser/extensions/extension_proxy_api.h" |
| 8 | 8 |
| 9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 CHECK(extension_pref->IsType(Value::TYPE_DICTIONARY)); | 66 CHECK(extension_pref->IsType(Value::TYPE_DICTIONARY)); |
| 67 const DictionaryValue* config = | 67 const DictionaryValue* config = |
| 68 static_cast<const DictionaryValue*>(extension_pref); | 68 static_cast<const DictionaryValue*>(extension_pref); |
| 69 | 69 |
| 70 // Extract the various pieces of information passed to | 70 // Extract the various pieces of information passed to |
| 71 // chrome.experimental.proxy.settings.set(). Several of these strings will | 71 // chrome.experimental.proxy.settings.set(). Several of these strings will |
| 72 // remain blank no respective values have been passed to set(). | 72 // remain blank no respective values have been passed to set(). |
| 73 // If a values has been passed to set but could not be parsed, we bail | 73 // If a values has been passed to set but could not be parsed, we bail |
| 74 // out and return NULL. | 74 // out and return NULL. |
| 75 ProxyPrefs::ProxyMode mode_enum; | 75 ProxyPrefs::ProxyMode mode_enum; |
| 76 bool pac_mandatory; |
| 76 std::string pac_url; | 77 std::string pac_url; |
| 77 std::string pac_data; | 78 std::string pac_data; |
| 78 std::string proxy_rules_string; | 79 std::string proxy_rules_string; |
| 79 std::string bypass_list; | 80 std::string bypass_list; |
| 80 if (!helpers::GetProxyModeFromExtensionPref(config, &mode_enum, error) || | 81 if (!helpers::GetProxyModeFromExtensionPref(config, &mode_enum, error) || |
| 82 !helpers::GetPacMandatoryFromExtensionPref(config, &pac_mandatory, |
| 83 error) || |
| 81 !helpers::GetPacUrlFromExtensionPref(config, &pac_url, error) || | 84 !helpers::GetPacUrlFromExtensionPref(config, &pac_url, error) || |
| 82 !helpers::GetPacDataFromExtensionPref(config, &pac_data, error) || | 85 !helpers::GetPacDataFromExtensionPref(config, &pac_data, error) || |
| 83 !helpers::GetProxyRulesStringFromExtensionPref( | 86 !helpers::GetProxyRulesStringFromExtensionPref( |
| 84 config, &proxy_rules_string, error) || | 87 config, &proxy_rules_string, error) || |
| 85 !helpers::GetBypassListFromExtensionPref(config, &bypass_list, error)) { | 88 !helpers::GetBypassListFromExtensionPref(config, &bypass_list, error)) { |
| 86 return NULL; | 89 return NULL; |
| 87 } | 90 } |
| 88 | 91 |
| 89 return helpers::CreateProxyConfigDict( | 92 return helpers::CreateProxyConfigDict( |
| 90 mode_enum, pac_url, pac_data, proxy_rules_string, bypass_list, error); | 93 mode_enum, pac_mandatory, pac_url, pac_data, proxy_rules_string, |
| 94 bypass_list, error); |
| 91 } | 95 } |
| 92 | 96 |
| 93 Value* ProxyPrefTransformer::BrowserToExtensionPref(const Value* browser_pref) { | 97 Value* ProxyPrefTransformer::BrowserToExtensionPref(const Value* browser_pref) { |
| 94 CHECK(browser_pref->IsType(Value::TYPE_DICTIONARY)); | 98 CHECK(browser_pref->IsType(Value::TYPE_DICTIONARY)); |
| 95 | 99 |
| 96 // This is a dictionary wrapper that exposes the proxy configuration stored in | 100 // This is a dictionary wrapper that exposes the proxy configuration stored in |
| 97 // the browser preferences. | 101 // the browser preferences. |
| 98 ProxyConfigDictionary config( | 102 ProxyConfigDictionary config( |
| 99 static_cast<const DictionaryValue*>(browser_pref)); | 103 static_cast<const DictionaryValue*>(browser_pref)); |
| 100 | 104 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 if (!proxy_rules_dict) | 136 if (!proxy_rules_dict) |
| 133 return NULL; | 137 return NULL; |
| 134 extension_pref->Set(keys::kProxyConfigRules, proxy_rules_dict); | 138 extension_pref->Set(keys::kProxyConfigRules, proxy_rules_dict); |
| 135 break; | 139 break; |
| 136 } | 140 } |
| 137 case ProxyPrefs::kModeCount: | 141 case ProxyPrefs::kModeCount: |
| 138 NOTREACHED(); | 142 NOTREACHED(); |
| 139 } | 143 } |
| 140 return extension_pref.release(); | 144 return extension_pref.release(); |
| 141 } | 145 } |
| OLD | NEW |