diff options
author | battre@chromium.org <battre@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-16 11:59:52 +0000 |
---|---|---|
committer | battre@chromium.org <battre@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-16 11:59:52 +0000 |
commit | 310cd962fb636f9a6beb2282ff4c87cacfd6af27 (patch) | |
tree | 36b51fe888b71ddaa7e48321656774b8e2036670 /chrome/browser/extensions/extension_proxy_api.h | |
parent | ad21e5f0bcb4857a72414b5bf5cc9cf993611893 (diff) | |
download | chromium_src-310cd962fb636f9a6beb2282ff4c87cacfd6af27.zip chromium_src-310cd962fb636f9a6beb2282ff4c87cacfd6af27.tar.gz chromium_src-310cd962fb636f9a6beb2282ff4c87cacfd6af27.tar.bz2 |
Improve error handling in Proxy Settings API.
This CL sets |error_| in all cases that are not guarded by the format validation of extension_api.json
BUG=72705
TEST=
Review URL: http://codereview.chromium.org/6524013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75104 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_proxy_api.h')
-rw-r--r-- | chrome/browser/extensions/extension_proxy_api.h | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/chrome/browser/extensions/extension_proxy_api.h b/chrome/browser/extensions/extension_proxy_api.h index 6c9d3bd..aa408b2 100644 --- a/chrome/browser/extensions/extension_proxy_api.h +++ b/chrome/browser/extensions/extension_proxy_api.h @@ -8,10 +8,7 @@ #include <string> #include "chrome/browser/extensions/extension_function.h" - -namespace net { -class ProxyServer; -} +#include "net/proxy/proxy_config.h" class DictionaryValue; @@ -32,6 +29,30 @@ class UseCustomProxySettingsFunction : public ProxySettingsFunction { virtual bool RunImpl(); DECLARE_EXTENSION_FUNCTION_NAME("experimental.proxy.useCustomProxySettings") + private: + // Converts a proxy "rules" element passed by the API caller into a proxy + // configuration string that can be used by the proxy subsystem (see + // proxy_config.h). Returns true if successful and sets |error_| otherwise. + bool GetProxyRules(DictionaryValue* proxy_rules, std::string* out); + + // Converts a proxy server description |dict| as passed by the API caller + // (e.g. for the http proxy in the rules element) and converts it to a + // ProxyServer. Returns true if successful and sets |error_| otherwise. + bool GetProxyServer(const DictionaryValue* dict, + net::ProxyServer::Scheme default_scheme, + net::ProxyServer* proxy_server); + + // Joins a list of URLs (stored as StringValues) with |joiner| to |out|. + // Returns true if successful and sets |error_| otherwise. + bool JoinUrlList(ListValue* list, + const std::string& joiner, + std::string* out); + + // Creates a string of the "bypassList" entries of a ProxyRules object (see + // API documentation) by joining the elements with commas. + // Returns true if successful (i.e. string could be delivered or no + // "bypassList" exists in the |proxy_rules|) and sets |error_| otherwise. + bool GetBypassList(DictionaryValue* proxy_rules, std::string* out); }; class RemoveCustomProxySettingsFunction : public ProxySettingsFunction { @@ -55,7 +76,7 @@ class GetCurrentProxySettingsFunction : public ProxySettingsFunction { // that is stored in the pref stores to the format that is used by the API. // See ProxyServer type defined in |experimental.proxy|. bool ConvertToApiFormat(const DictionaryValue* proxy_prefs, - DictionaryValue* api_proxy_config) const; + DictionaryValue* api_proxy_config); bool ParseRules(const std::string& rules, DictionaryValue* out) const; DictionaryValue* ConvertToDictionary(const net::ProxyServer& proxy) const; }; |