| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/api/proxy/proxy_api.h" | 7 #include "chrome/browser/extensions/api/proxy/proxy_api.h" |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 ProxyPrefTransformer::~ProxyPrefTransformer() { | 96 ProxyPrefTransformer::~ProxyPrefTransformer() { |
| 97 } | 97 } |
| 98 | 98 |
| 99 base::Value* ProxyPrefTransformer::ExtensionToBrowserPref( | 99 base::Value* ProxyPrefTransformer::ExtensionToBrowserPref( |
| 100 const base::Value* extension_pref, | 100 const base::Value* extension_pref, |
| 101 std::string* error, | 101 std::string* error, |
| 102 bool* bad_message) { | 102 bool* bad_message) { |
| 103 // When ExtensionToBrowserPref is called, the format of |extension_pref| | 103 // When ExtensionToBrowserPref is called, the format of |extension_pref| |
| 104 // has been verified already by the extension API to match the schema | 104 // has been verified already by the extension API to match the schema |
| 105 // defined in the extension API JSON. | 105 // defined in the extension API JSON. |
| 106 CHECK(extension_pref->IsType(base::Value::TYPE_DICTIONARY)); | 106 CHECK(extension_pref->IsType(base::Value::Type::DICTIONARY)); |
| 107 const base::DictionaryValue* config = | 107 const base::DictionaryValue* config = |
| 108 static_cast<const base::DictionaryValue*>(extension_pref); | 108 static_cast<const base::DictionaryValue*>(extension_pref); |
| 109 | 109 |
| 110 // Extract the various pieces of information passed to | 110 // Extract the various pieces of information passed to |
| 111 // chrome.proxy.settings.set(). Several of these strings will | 111 // chrome.proxy.settings.set(). Several of these strings will |
| 112 // remain blank no respective values have been passed to set(). | 112 // remain blank no respective values have been passed to set(). |
| 113 // If a values has been passed to set but could not be parsed, we bail | 113 // If a values has been passed to set but could not be parsed, we bail |
| 114 // out and return NULL. | 114 // out and return NULL. |
| 115 ProxyPrefs::ProxyMode mode_enum; | 115 ProxyPrefs::ProxyMode mode_enum; |
| 116 bool pac_mandatory; | 116 bool pac_mandatory; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 133 return NULL; | 133 return NULL; |
| 134 } | 134 } |
| 135 | 135 |
| 136 return helpers::CreateProxyConfigDict( | 136 return helpers::CreateProxyConfigDict( |
| 137 mode_enum, pac_mandatory, pac_url, pac_data, proxy_rules_string, | 137 mode_enum, pac_mandatory, pac_url, pac_data, proxy_rules_string, |
| 138 bypass_list, error); | 138 bypass_list, error); |
| 139 } | 139 } |
| 140 | 140 |
| 141 base::Value* ProxyPrefTransformer::BrowserToExtensionPref( | 141 base::Value* ProxyPrefTransformer::BrowserToExtensionPref( |
| 142 const base::Value* browser_pref) { | 142 const base::Value* browser_pref) { |
| 143 CHECK(browser_pref->IsType(base::Value::TYPE_DICTIONARY)); | 143 CHECK(browser_pref->IsType(base::Value::Type::DICTIONARY)); |
| 144 | 144 |
| 145 // This is a dictionary wrapper that exposes the proxy configuration stored in | 145 // This is a dictionary wrapper that exposes the proxy configuration stored in |
| 146 // the browser preferences. | 146 // the browser preferences. |
| 147 ProxyConfigDictionary config( | 147 ProxyConfigDictionary config( |
| 148 static_cast<const base::DictionaryValue*>(browser_pref)); | 148 static_cast<const base::DictionaryValue*>(browser_pref)); |
| 149 | 149 |
| 150 ProxyPrefs::ProxyMode mode; | 150 ProxyPrefs::ProxyMode mode; |
| 151 if (!config.GetMode(&mode)) { | 151 if (!config.GetMode(&mode)) { |
| 152 LOG(ERROR) << "Cannot determine proxy mode."; | 152 LOG(ERROR) << "Cannot determine proxy mode."; |
| 153 return NULL; | 153 return NULL; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 extension_pref->Set(keys::kProxyConfigRules, proxy_rules_dict); | 185 extension_pref->Set(keys::kProxyConfigRules, proxy_rules_dict); |
| 186 break; | 186 break; |
| 187 } | 187 } |
| 188 case ProxyPrefs::kModeCount: | 188 case ProxyPrefs::kModeCount: |
| 189 NOTREACHED(); | 189 NOTREACHED(); |
| 190 } | 190 } |
| 191 return extension_pref.release(); | 191 return extension_pref.release(); |
| 192 } | 192 } |
| 193 | 193 |
| 194 } // namespace extensions | 194 } // namespace extensions |
| OLD | NEW |