diff options
author | battre@chromium.org <battre@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-18 11:38:29 +0000 |
---|---|---|
committer | battre@chromium.org <battre@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-18 11:38:29 +0000 |
commit | 0260c890252c47627fe7eabd831470191905666e (patch) | |
tree | 96a201e1b4e2a3bf905703d4ea832aee89bbdb6e /chrome/browser/extensions/extension_proxy_api_helpers.cc | |
parent | ffda1f6febd220ec443f1df3a073ceede66767cc (diff) | |
download | chromium_src-0260c890252c47627fe7eabd831470191905666e.zip chromium_src-0260c890252c47627fe7eabd831470191905666e.tar.gz chromium_src-0260c890252c47627fe7eabd831470191905666e.tar.bz2 |
CL Candidate for C++ Readability
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6791009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81936 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_proxy_api_helpers.cc')
-rw-r--r-- | chrome/browser/extensions/extension_proxy_api_helpers.cc | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/chrome/browser/extensions/extension_proxy_api_helpers.cc b/chrome/browser/extensions/extension_proxy_api_helpers.cc index 265c284..6429843 100644 --- a/chrome/browser/extensions/extension_proxy_api_helpers.cc +++ b/chrome/browser/extensions/extension_proxy_api_helpers.cc @@ -167,22 +167,21 @@ bool GetProxyRulesStringFromExtensionPref(const DictionaryValue* proxy_config, return true; // Local data into which the parameters will be parsed. has_proxy describes - // whether a setting was found for the scheme; proxy_dict holds the - // DictionaryValues which in turn contain proxy server descriptions, and - // proxy_server holds ProxyServer structs containing those descriptions. + // whether a setting was found for the scheme; proxy_server holds the + // respective ProxyServer objects containing those descriptions. bool has_proxy[keys::SCHEME_MAX + 1]; - DictionaryValue* proxy_dict[keys::SCHEME_MAX + 1]; net::ProxyServer proxy_server[keys::SCHEME_MAX + 1]; // Looking for all possible proxy types is inefficient if we have a // singleProxy that will supersede per-URL proxies, but it's worth it to keep // the code simple and extensible. for (size_t i = 0; i <= keys::SCHEME_MAX; ++i) { + DictionaryValue* proxy_dict = NULL; has_proxy[i] = proxy_rules->GetDictionary(keys::field_name[i], - &proxy_dict[i]); + &proxy_dict); if (has_proxy[i]) { net::ProxyServer::Scheme default_scheme = net::ProxyServer::SCHEME_HTTP; - if (!GetProxyServer(proxy_dict[i], default_scheme, + if (!GetProxyServer(proxy_dict, default_scheme, &proxy_server[i], error)) { // Don't set |error| here, as GetProxyServer takes care of that. return false; @@ -190,6 +189,8 @@ bool GetProxyRulesStringFromExtensionPref(const DictionaryValue* proxy_config, } } + COMPILE_ASSERT(keys::SCHEME_ALL == 0, singleProxy_must_be_first_option); + // Handle case that only singleProxy is specified. if (has_proxy[keys::SCHEME_ALL]) { for (size_t i = 1; i <= keys::SCHEME_MAX; ++i) { @@ -364,6 +365,9 @@ DictionaryValue* CreateProxyRulesDict( } break; } + + // If we add a new scheme some time, we need to also store a new dictionary + // representing this scheme in the code above. COMPILE_ASSERT(keys::SCHEME_MAX == 4, SCHEME_FORGOTTEN); if (proxy_config.HasBypassList()) { |