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 helper functions for the Chrome Extensions Proxy Settings | 5 // Implementation of helper functions for the Chrome Extensions Proxy Settings |
6 // API. | 6 // API. |
7 // | 7 // |
8 // Throughout this code, we report errors to the user by setting an |error| | 8 // Throughout this code, we report errors to the user by setting an |error| |
9 // parameter, if and only if these errors can be cause by invalid input | 9 // parameter, if and only if these errors can be cause by invalid input |
10 // from the extension and we cannot expect that the extensions API has | 10 // from the extension and we cannot expect that the extensions API has |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 const base::ListValue* bypass_list = NULL; | 300 const base::ListValue* bypass_list = NULL; |
301 if (!proxy_rules->GetList(keys::kProxyConfigBypassList, &bypass_list)) { | 301 if (!proxy_rules->GetList(keys::kProxyConfigBypassList, &bypass_list)) { |
302 LOG(ERROR) << "'rules.bypassList' could not be parsed."; | 302 LOG(ERROR) << "'rules.bypassList' could not be parsed."; |
303 *bad_message = true; | 303 *bad_message = true; |
304 return false; | 304 return false; |
305 } | 305 } |
306 | 306 |
307 return JoinUrlList(bypass_list, ",", out, error, bad_message); | 307 return JoinUrlList(bypass_list, ",", out, error, bad_message); |
308 } | 308 } |
309 | 309 |
310 base::DictionaryValue* CreateProxyConfigDict( | 310 std::unique_ptr<base::DictionaryValue> CreateProxyConfigDict( |
311 ProxyPrefs::ProxyMode mode_enum, | 311 ProxyPrefs::ProxyMode mode_enum, |
312 bool pac_mandatory, | 312 bool pac_mandatory, |
313 const std::string& pac_url, | 313 const std::string& pac_url, |
314 const std::string& pac_data, | 314 const std::string& pac_data, |
315 const std::string& proxy_rules_string, | 315 const std::string& proxy_rules_string, |
316 const std::string& bypass_list, | 316 const std::string& bypass_list, |
317 std::string* error) { | 317 std::string* error) { |
318 base::DictionaryValue* result_proxy_config = NULL; | 318 std::unique_ptr<base::DictionaryValue> result_proxy_config; |
319 switch (mode_enum) { | 319 switch (mode_enum) { |
320 case ProxyPrefs::MODE_DIRECT: | 320 case ProxyPrefs::MODE_DIRECT: |
321 result_proxy_config = ProxyConfigDictionary::CreateDirect(); | 321 result_proxy_config = ProxyConfigDictionary::CreateDirect(); |
322 break; | 322 break; |
323 case ProxyPrefs::MODE_AUTO_DETECT: | 323 case ProxyPrefs::MODE_AUTO_DETECT: |
324 result_proxy_config = ProxyConfigDictionary::CreateAutoDetect(); | 324 result_proxy_config = ProxyConfigDictionary::CreateAutoDetect(); |
325 break; | 325 break; |
326 case ProxyPrefs::MODE_PAC_SCRIPT: { | 326 case ProxyPrefs::MODE_PAC_SCRIPT: { |
327 std::string url; | 327 std::string url; |
328 if (!pac_url.empty()) { | 328 if (!pac_url.empty()) { |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 const std::string& delims) { | 494 const std::string& delims) { |
495 base::ListValue* out = new base::ListValue; | 495 base::ListValue* out = new base::ListValue; |
496 base::StringTokenizer entries(in, delims); | 496 base::StringTokenizer entries(in, delims); |
497 while (entries.GetNext()) | 497 while (entries.GetNext()) |
498 out->AppendString(entries.token()); | 498 out->AppendString(entries.token()); |
499 return out; | 499 return out; |
500 } | 500 } |
501 | 501 |
502 } // namespace proxy_api_helpers | 502 } // namespace proxy_api_helpers |
503 } // namespace extensions | 503 } // namespace extensions |
OLD | NEW |