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 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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()) { |
329 url = pac_url; | 329 url = pac_url; |
330 } else if (!pac_data.empty()) { | 330 } else if (!pac_data.empty()) { |
331 if (!CreateDataURLFromPACScript(pac_data, &url)) { | 331 if (!CreateDataURLFromPACScript(pac_data, &url)) { |
332 *error = "Internal error, at base64 encoding of 'pacScript.data'."; | 332 *error = "Internal error, at base64 encoding of 'pacScript.data'."; |
333 return NULL; | 333 return nullptr; |
334 } | 334 } |
335 } else { | 335 } else { |
336 *error = "Proxy mode 'pac_script' requires a 'pacScript' field with " | 336 *error = "Proxy mode 'pac_script' requires a 'pacScript' field with " |
337 "either a 'url' field or a 'data' field."; | 337 "either a 'url' field or a 'data' field."; |
338 return NULL; | 338 return nullptr; |
339 } | 339 } |
340 result_proxy_config = | 340 result_proxy_config = |
341 ProxyConfigDictionary::CreatePacScript(url, pac_mandatory); | 341 ProxyConfigDictionary::CreatePacScript(url, pac_mandatory); |
342 break; | 342 break; |
343 } | 343 } |
344 case ProxyPrefs::MODE_FIXED_SERVERS: { | 344 case ProxyPrefs::MODE_FIXED_SERVERS: { |
345 if (proxy_rules_string.empty()) { | 345 if (proxy_rules_string.empty()) { |
346 *error = "Proxy mode 'fixed_servers' requires a 'rules' field."; | 346 *error = "Proxy mode 'fixed_servers' requires a 'rules' field."; |
347 return NULL; | 347 return nullptr; |
348 } | 348 } |
349 result_proxy_config = ProxyConfigDictionary::CreateFixedServers( | 349 result_proxy_config = ProxyConfigDictionary::CreateFixedServers( |
350 proxy_rules_string, bypass_list); | 350 proxy_rules_string, bypass_list); |
351 break; | 351 break; |
352 } | 352 } |
353 case ProxyPrefs::MODE_SYSTEM: | 353 case ProxyPrefs::MODE_SYSTEM: |
354 result_proxy_config = ProxyConfigDictionary::CreateSystem(); | 354 result_proxy_config = ProxyConfigDictionary::CreateSystem(); |
355 break; | 355 break; |
356 case ProxyPrefs::kModeCount: | 356 case ProxyPrefs::kModeCount: |
357 NOTREACHED(); | 357 NOTREACHED(); |
(...skipping 136 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 |