OLD | NEW |
1 // Copyright (c) 2012 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 #include "chrome/browser/chromeos/proxy_config_service_impl.h" | 5 #include "chrome/browser/chromeos/proxy_config_service_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 VLOG_IF(1, new_network) << "New network: name=" << new_network->name() | 110 VLOG_IF(1, new_network) << "New network: name=" << new_network->name() |
111 << ", profile=" << new_network->profile_path(); | 111 << ", profile=" << new_network->profile_path(); |
112 | 112 |
113 // Even if the default network is the same, its proxy config (e.g. if private | 113 // Even if the default network is the same, its proxy config (e.g. if private |
114 // version of network replaces the shared version after login), or | 114 // version of network replaces the shared version after login), or |
115 // use-shared-proxies setting (e.g. after login) may have changed, so | 115 // use-shared-proxies setting (e.g. after login) may have changed, so |
116 // re-determine effective proxy config, and activate if different. | 116 // re-determine effective proxy config, and activate if different. |
117 DetermineEffectiveConfigFromDefaultNetwork(); | 117 DetermineEffectiveConfigFromDefaultNetwork(); |
118 } | 118 } |
119 | 119 |
| 120 void ProxyConfigServiceImpl::OnShuttingDown() { |
| 121 // Ownership of this class is complicated. Stop observing NetworkStateHandler |
| 122 // when the class shuts down. |
| 123 NetworkHandler::Get()->network_state_handler()->RemoveObserver(this, |
| 124 FROM_HERE); |
| 125 } |
| 126 |
120 // static | 127 // static |
121 bool ProxyConfigServiceImpl::IgnoreProxy(const PrefService* profile_prefs, | 128 bool ProxyConfigServiceImpl::IgnoreProxy(const PrefService* profile_prefs, |
122 const std::string network_profile_path, | 129 const std::string network_profile_path, |
123 ::onc::ONCSource onc_source) { | 130 ::onc::ONCSource onc_source) { |
124 if (!profile_prefs) { | 131 if (!profile_prefs) { |
125 // If the profile preference are not available, this must be the object | 132 // If the profile preference are not available, this must be the object |
126 // associated to local state used for system requests or login-profile. Make | 133 // associated to local state used for system requests or login-profile. Make |
127 // sure that proxies are enabled. | 134 // sure that proxies are enabled. |
128 VLOG(1) << "Use proxy for system requests and sign-in screen."; | 135 VLOG(1) << "Use proxy for system requests and sign-in screen."; |
129 return false; | 136 return false; |
(...skipping 30 matching lines...) Expand all Loading... |
160 } | 167 } |
161 } | 168 } |
162 | 169 |
163 // This network is shared and not managed by the user's domain. | 170 // This network is shared and not managed by the user's domain. |
164 bool use_shared_proxies = profile_prefs->GetBoolean(prefs::kUseSharedProxies); | 171 bool use_shared_proxies = profile_prefs->GetBoolean(prefs::kUseSharedProxies); |
165 VLOG(1) << "Use proxy of shared network: " << use_shared_proxies; | 172 VLOG(1) << "Use proxy of shared network: " << use_shared_proxies; |
166 return !use_shared_proxies; | 173 return !use_shared_proxies; |
167 } | 174 } |
168 | 175 |
169 void ProxyConfigServiceImpl::DetermineEffectiveConfigFromDefaultNetwork() { | 176 void ProxyConfigServiceImpl::DetermineEffectiveConfigFromDefaultNetwork() { |
| 177 if (!NetworkHandler::IsInitialized()) |
| 178 return; |
| 179 |
170 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); | 180 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); |
171 const NetworkState* network = handler->DefaultNetwork(); | 181 const NetworkState* network = handler->DefaultNetwork(); |
172 | 182 |
173 // Get prefs proxy config if available. | 183 // Get prefs proxy config if available. |
174 net::ProxyConfig pref_config; | 184 net::ProxyConfig pref_config; |
175 ProxyPrefs::ConfigState pref_state = GetProxyConfig(&pref_config); | 185 ProxyPrefs::ConfigState pref_state = GetProxyConfig(&pref_config); |
176 | 186 |
177 // Get network proxy config if available. | 187 // Get network proxy config if available. |
178 net::ProxyConfig network_config; | 188 net::ProxyConfig network_config; |
179 net::ProxyConfigService::ConfigAvailability network_availability = | 189 net::ProxyConfigService::ConfigAvailability network_availability = |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 if (VLOG_IS_ON(1) && !update_pending()) { // Update was successful. | 242 if (VLOG_IS_ON(1) && !update_pending()) { // Update was successful. |
233 scoped_ptr<base::DictionaryValue> config_dict(effective_config.ToValue()); | 243 scoped_ptr<base::DictionaryValue> config_dict(effective_config.ToValue()); |
234 VLOG(1) << this << ": Proxy changed: " | 244 VLOG(1) << this << ": Proxy changed: " |
235 << ProxyPrefs::ConfigStateToDebugString(active_config_state_) | 245 << ProxyPrefs::ConfigStateToDebugString(active_config_state_) |
236 << ", " << *config_dict; | 246 << ", " << *config_dict; |
237 } | 247 } |
238 } | 248 } |
239 } | 249 } |
240 | 250 |
241 } // namespace chromeos | 251 } // namespace chromeos |
OLD | NEW |