OLD | NEW |
1 // Copyright (c) 2011 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 |
11 // caught this error before. In all other cases we are dealing with internal | 11 // caught this error before. In all other cases we are dealing with internal |
12 // errors and log to LOG(ERROR). | 12 // errors and log to LOG(ERROR). |
13 | 13 |
14 #include "chrome/browser/extensions/extension_proxy_api_helpers.h" | 14 #include "chrome/browser/extensions/api/proxy/proxy_api_helpers.h" |
15 | 15 |
16 #include "base/base64.h" | 16 #include "base/base64.h" |
17 #include "base/basictypes.h" | 17 #include "base/basictypes.h" |
18 #include "base/string_tokenizer.h" | 18 #include "base/string_tokenizer.h" |
19 #include "base/string_util.h" | 19 #include "base/string_util.h" |
20 #include "base/utf_string_conversions.h" | 20 #include "base/utf_string_conversions.h" |
21 #include "base/values.h" | 21 #include "base/values.h" |
22 #include "chrome/browser/extensions/extension_proxy_api_constants.h" | 22 #include "chrome/browser/extensions/api/proxy/proxy_api_constants.h" |
23 #include "chrome/browser/prefs/proxy_config_dictionary.h" | 23 #include "chrome/browser/prefs/proxy_config_dictionary.h" |
24 #include "chrome/common/extensions/extension_error_utils.h" | 24 #include "chrome/common/extensions/extension_error_utils.h" |
25 #include "net/proxy/proxy_config.h" | 25 #include "net/proxy/proxy_config.h" |
26 | 26 |
27 namespace keys = extension_proxy_api_constants; | 27 namespace extensions { |
28 | 28 |
29 namespace extension_proxy_api_helpers { | 29 namespace keys = proxy_api_constants; |
| 30 |
| 31 namespace proxy_api_helpers { |
30 | 32 |
31 bool CreateDataURLFromPACScript(const std::string& pac_script, | 33 bool CreateDataURLFromPACScript(const std::string& pac_script, |
32 std::string* pac_script_url_base64_encoded) { | 34 std::string* pac_script_url_base64_encoded) { |
33 // Encode pac_script in base64. | 35 // Encode pac_script in base64. |
34 std::string pac_script_base64_encoded; | 36 std::string pac_script_base64_encoded; |
35 if (!base::Base64Encode(pac_script, &pac_script_base64_encoded)) | 37 if (!base::Base64Encode(pac_script, &pac_script_base64_encoded)) |
36 return false; | 38 return false; |
37 | 39 |
38 // Make it a correct data url. | 40 // Make it a correct data url. |
39 *pac_script_url_base64_encoded = | 41 *pac_script_url_base64_encoded = |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 | 480 |
479 ListValue* TokenizeToStringList(const std::string& in, | 481 ListValue* TokenizeToStringList(const std::string& in, |
480 const std::string& delims) { | 482 const std::string& delims) { |
481 ListValue* out = new ListValue; | 483 ListValue* out = new ListValue; |
482 StringTokenizer entries(in, delims); | 484 StringTokenizer entries(in, delims); |
483 while (entries.GetNext()) | 485 while (entries.GetNext()) |
484 out->Append(Value::CreateStringValue(entries.token())); | 486 out->Append(Value::CreateStringValue(entries.token())); |
485 return out; | 487 return out; |
486 } | 488 } |
487 | 489 |
488 } // namespace extension_proxy_api_helpers | 490 } // namespace proxy_api_helpers |
| 491 } // namespace extensions |
OLD | NEW |