diff options
author | mnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-24 14:44:02 +0000 |
---|---|---|
committer | mnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-24 14:44:02 +0000 |
commit | cc5bfd4de6d8b8c6f33ff1f4a9b28eecf562ec9d (patch) | |
tree | bc595667061dde2db1c835dde6e7505ae257a54d /chrome/browser/net/chrome_url_request_context.cc | |
parent | 8e0e513103bb5dc6ff104c669432c3aba4af18d3 (diff) | |
download | chromium_src-cc5bfd4de6d8b8c6f33ff1f4a9b28eecf562ec9d.zip chromium_src-cc5bfd4de6d8b8c6f33ff1f4a9b28eecf562ec9d.tar.gz chromium_src-cc5bfd4de6d8b8c6f33ff1f4a9b28eecf562ec9d.tar.bz2 |
Dynamically refresh pref-configured proxies.
BUG=63175,48930
TEST=unit tests
Review URL: http://codereview.chromium.org/5005002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@67261 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/net/chrome_url_request_context.cc')
-rw-r--r-- | chrome/browser/net/chrome_url_request_context.cc | 91 |
1 files changed, 15 insertions, 76 deletions
diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context.cc index 4ec3939..bd3e9c6 100644 --- a/chrome/browser/net/chrome_url_request_context.cc +++ b/chrome/browser/net/chrome_url_request_context.cc @@ -18,6 +18,7 @@ #include "chrome/browser/net/chrome_net_log.h" #include "chrome/browser/net/sqlite_persistent_cookie_store.h" #include "chrome/browser/net/predictor_api.h" +#include "chrome/browser/net/pref_proxy_config_service.h" #include "chrome/browser/profile.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_switches.h" @@ -68,26 +69,25 @@ net::ProxyConfigService* CreateProxyConfigService(Profile* profile) { // from the UI thread. CheckCurrentlyOnMainThread(); - scoped_ptr<net::ProxyConfig> proxy_config(CreateProxyConfig( - profile->GetPrefs())); + // Create a baseline service that provides proxy configuration in case nothing + // is configured through prefs (Note: prefs include command line and + // configuration policy). + net::ProxyConfigService* base_service = NULL; - if (!proxy_config.get()) { - // Use system settings. - // TODO(port): the IO and FILE message loops are only used by Linux. Can - // that code be moved to chrome/browser instead of being in net, so that it - // can use BrowserThread instead of raw MessageLoop pointers? See bug 25354. + // TODO(port): the IO and FILE message loops are only used by Linux. Can + // that code be moved to chrome/browser instead of being in net, so that it + // can use BrowserThread instead of raw MessageLoop pointers? See bug 25354. #if defined(OS_CHROMEOS) - return new chromeos::ProxyConfigService( - profile->GetChromeOSProxyConfigServiceImpl()); + base_service = new chromeos::ProxyConfigService( + profile->GetChromeOSProxyConfigServiceImpl()); #else - return net::ProxyService::CreateSystemProxyConfigService( - g_browser_process->io_thread()->message_loop(), - g_browser_process->file_thread()->message_loop()); + base_service = net::ProxyService::CreateSystemProxyConfigService( + g_browser_process->io_thread()->message_loop(), + g_browser_process->file_thread()->message_loop()); #endif // defined(OS_CHROMEOS) - } - // Otherwise use the fixed settings from the command line. - return new net::ProxyConfigServiceFixed(*proxy_config.get()); + return new PrefProxyConfigService(profile->GetProxyConfigTracker(), + base_service); } // Create a proxy service according to the options on command line. @@ -982,64 +982,3 @@ void ChromeURLRequestContextFactory::ApplyProfileParametersToContext( context->set_browser_file_system_context(browser_file_system_context_); context->set_extension_info_map(extension_info_map_); } - -// ---------------------------------------------------------------------------- - -net::ProxyConfig* CreateProxyConfig(const PrefService* pref_service) { - // Scan for all "enable" type proxy switches. - static const char* proxy_prefs[] = { - prefs::kProxyPacUrl, - prefs::kProxyServer, - prefs::kProxyBypassList, - prefs::kProxyAutoDetect - }; - - // Check whether the preference system holds a valid proxy configuration. Note - // that preferences coming from a lower-priority source than the user settings - // are ignored. That's because chrome treats the system settings as the - // default values, which should apply if there's no explicit value forced by - // policy or the user. - bool found_enable_proxy_pref = false; - for (size_t i = 0; i < arraysize(proxy_prefs); i++) { - const PrefService::Preference* pref = - pref_service->FindPreference(proxy_prefs[i]); - DCHECK(pref); - if (pref && (!pref->IsUserModifiable() || pref->HasUserSetting())) { - found_enable_proxy_pref = true; - break; - } - } - - if (!found_enable_proxy_pref && - !pref_service->GetBoolean(prefs::kNoProxyServer)) { - return NULL; - } - - net::ProxyConfig* proxy_config = new net::ProxyConfig(); - if (pref_service->GetBoolean(prefs::kNoProxyServer)) { - // Ignore all the other proxy config preferences if the use of a proxy - // has been explicitly disabled. - return proxy_config; - } - - if (pref_service->HasPrefPath(prefs::kProxyServer)) { - std::string proxy_server = pref_service->GetString(prefs::kProxyServer); - proxy_config->proxy_rules().ParseFromString(proxy_server); - } - - if (pref_service->HasPrefPath(prefs::kProxyPacUrl)) { - std::string proxy_pac = pref_service->GetString(prefs::kProxyPacUrl); - proxy_config->set_pac_url(GURL(proxy_pac)); - } - - proxy_config->set_auto_detect(pref_service->GetBoolean( - prefs::kProxyAutoDetect)); - - if (pref_service->HasPrefPath(prefs::kProxyBypassList)) { - std::string proxy_bypass = - pref_service->GetString(prefs::kProxyBypassList); - proxy_config->proxy_rules().bypass_rules.ParseFromString(proxy_bypass); - } - - return proxy_config; -} |