diff options
author | pneubeck@chromium.org <pneubeck@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-17 05:25:42 +0000 |
---|---|---|
committer | pneubeck@chromium.org <pneubeck@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-17 05:25:42 +0000 |
commit | e2930d090607fd6008caca45121d0aba3ed65b46 (patch) | |
tree | 5a701f6267cc8e3b6ef1f0e03a22cad8b84c764c /chrome/browser/chromeos/proxy_config_service_impl.cc | |
parent | cb89a48ff5746ac31b9eda9b57cf05ddeb439dad (diff) | |
download | chromium_src-e2930d090607fd6008caca45121d0aba3ed65b46.zip chromium_src-e2930d090607fd6008caca45121d0aba3ed65b46.tar.gz chromium_src-e2930d090607fd6008caca45121d0aba3ed65b46.tar.bz2 |
Cleanup the UseSharedProxies preference.
- remove the UserSharedProxies pref from local state
- fix the default value of the pref in the profile pref service
- make the conditionals, when to use or ignore proxy settings, more explicit and clearer.
BUG=258835
TEST=Manually checked all combinations of {DevicePolicy, UserPolicy, SharedNetwork, NotSharedNetwork} x {before, after login} x {enabled, disabled UseSharedProxies} for proxies of the system context, signin profile and user's profile. I checked the proxies by looking at the vlogs and the UI (like net-internals and settings page). I did not test the actual network connectivity of each context.
TBR=battre@chromium.org, nkostylev@chromium.org
Review URL: https://codereview.chromium.org/18112018
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@211954 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos/proxy_config_service_impl.cc')
-rw-r--r-- | chrome/browser/chromeos/proxy_config_service_impl.cc | 80 |
1 files changed, 28 insertions, 52 deletions
diff --git a/chrome/browser/chromeos/proxy_config_service_impl.cc b/chrome/browser/chromeos/proxy_config_service_impl.cc index f9cceac..95f4f19 100644 --- a/chrome/browser/chromeos/proxy_config_service_impl.cc +++ b/chrome/browser/chromeos/proxy_config_service_impl.cc @@ -7,7 +7,6 @@ #include "base/bind.h" #include "base/location.h" #include "base/logging.h" -#include "base/prefs/pref_registry_simple.h" #include "base/prefs/pref_service.h" #include "base/values.h" #include "chrome/browser/browser_process.h" @@ -23,7 +22,6 @@ #include "chromeos/network/network_state.h" #include "chromeos/network/network_state_handler.h" #include "chromeos/network/onc/onc_utils.h" -#include "components/user_prefs/pref_registry_syncable.h" namespace chromeos { @@ -43,15 +41,19 @@ bool GetProxyConfig(const NetworkState& network, } // namespace -ProxyConfigServiceImpl::ProxyConfigServiceImpl(PrefService* pref_service) - : PrefProxyConfigTrackerImpl(pref_service), +ProxyConfigServiceImpl::ProxyConfigServiceImpl(PrefService* profile_prefs, + PrefService* local_state_prefs) + : PrefProxyConfigTrackerImpl(profile_prefs ? profile_prefs + : local_state_prefs), active_config_state_(ProxyPrefs::CONFIG_UNSET), + profile_prefs_(profile_prefs), pointer_factory_(this) { - // Register for notifications of UseSharedProxies user preference. - if (pref_service->FindPreference(prefs::kUseSharedProxies)) { + if (profile_prefs) { + DCHECK(profile_prefs->FindPreference(prefs::kUseSharedProxies)); use_shared_proxies_.Init( - prefs::kUseSharedProxies, pref_service, + prefs::kUseSharedProxies, + profile_prefs, base::Bind(&ProxyConfigServiceImpl::OnUseSharedProxiesChanged, base::Unretained(this))); } @@ -79,24 +81,8 @@ void ProxyConfigServiceImpl::OnProxyConfigChanged( DetermineEffectiveConfigFromDefaultNetwork(); } -// static -void ProxyConfigServiceImpl::RegisterPrefs(PrefRegistrySimple* registry) { - // Use shared proxies default to off. GetUseSharedProxies will return the - // correct value based on pre-login and login. - registry->RegisterBooleanPref(prefs::kUseSharedProxies, true); -} - -// static -void ProxyConfigServiceImpl::RegisterProfilePrefs( - user_prefs::PrefRegistrySyncable* registry) { - registry->RegisterBooleanPref( - prefs::kUseSharedProxies, - true, - user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); -} - void ProxyConfigServiceImpl::OnUseSharedProxiesChanged() { - VLOG(1) << "New use-shared-proxies = " << GetUseSharedProxies(prefs()); + VLOG(1) << "use-shared-proxies pref changed."; DetermineEffectiveConfigFromDefaultNetwork(); } @@ -119,43 +105,30 @@ void ProxyConfigServiceImpl::DefaultNetworkChanged( } // static -bool ProxyConfigServiceImpl::GetUseSharedProxies( - const PrefService* pref_service) { - const PrefService::Preference* use_shared_proxies_pref = - pref_service->FindPreference(prefs::kUseSharedProxies); - if (!use_shared_proxies_pref || !use_shared_proxies_pref->GetValue()) { - if (UserManager::Get()->IsUserLoggedIn()) { - VLOG(1) << "use-shared-proxies not set, defaulting to false/IgnoreProxy."; - return false; - } else { - // Make sure that proxies are always enabled at sign in screen. - VLOG(1) << "Use proxy on login screen."; - return true; - } - } - bool use_shared_proxies = false; - use_shared_proxies_pref->GetValue()->GetAsBoolean(&use_shared_proxies); - return use_shared_proxies; -} - -// static -bool ProxyConfigServiceImpl::IgnoreProxy(const PrefService* pref_service, +bool ProxyConfigServiceImpl::IgnoreProxy(const PrefService* profile_prefs, const std::string network_profile_path, onc::ONCSource onc_source) { + if (!profile_prefs) { + // If the profile preference are not available, this must be the object + // associated to local state used for system requests or login-profile. Make + // sure that proxies are enabled. + VLOG(1) << "Use proxy for system requests and sign-in screen."; + return false; + } + const NetworkProfile* profile = NetworkHandler::Get()->network_profile_handler()-> GetProfileForPath(network_profile_path); if (!profile) { - LOG(WARNING) << "Unknown profile_path " << network_profile_path; + LOG(WARNING) << "Unknown profile_path '" << network_profile_path + << "'. Ignoring proxy."; return true; } if (profile->type() == NetworkProfile::TYPE_USER) { VLOG(1) << "Respect proxy of not-shared networks."; return false; } - - if (onc_source == onc::ONC_SOURCE_DEVICE_POLICY && - UserManager::Get()->IsUserLoggedIn()) { + if (onc_source == onc::ONC_SOURCE_DEVICE_POLICY) { policy::BrowserPolicyConnector* connector = g_browser_process->browser_policy_connector(); const User* logged_in_user = UserManager::Get()->GetLoggedInUser(); @@ -167,7 +140,10 @@ bool ProxyConfigServiceImpl::IgnoreProxy(const PrefService* pref_service, } } - return !GetUseSharedProxies(pref_service); + // This network is shared and not managed by the user's domain. + bool use_shared_proxies = profile_prefs->GetBoolean(prefs::kUseSharedProxies); + VLOG(1) << "Use proxy of shared network: " << use_shared_proxies; + return !use_shared_proxies; } void ProxyConfigServiceImpl::DetermineEffectiveConfigFromDefaultNetwork() { @@ -184,8 +160,8 @@ void ProxyConfigServiceImpl::DetermineEffectiveConfigFromDefaultNetwork() { net::ProxyConfigService::CONFIG_UNSET; bool ignore_proxy = true; if (network) { - ignore_proxy = - IgnoreProxy(prefs(), network->profile_path(), network->onc_source()); + ignore_proxy = IgnoreProxy( + profile_prefs_, network->profile_path(), network->onc_source()); // If network is shared but use-shared-proxies is off, use direct mode. if (ignore_proxy) { VLOG(1) << "Shared network && !use-shared-proxies, use direct"; |