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" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
13 #include "base/values.h" | 13 #include "base/values.h" |
14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
15 #include "chrome/browser/chromeos/login/users/user_manager.h" | 15 #include "chrome/browser/chromeos/login/users/user_manager.h" |
16 #include "chrome/browser/chromeos/net/proxy_config_handler.h" | 16 #include "chrome/browser/chromeos/net/proxy_config_handler.h" |
17 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 17 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
18 #include "chrome/browser/prefs/proxy_config_dictionary.h" | 18 #include "chrome/browser/prefs/proxy_config_dictionary.h" |
19 #include "chrome/browser/prefs/proxy_prefs.h" | 19 #include "chrome/browser/prefs/proxy_prefs.h" |
20 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
21 #include "chromeos/network/favorite_state.h" | |
22 #include "chromeos/network/network_profile.h" | 21 #include "chromeos/network/network_profile.h" |
23 #include "chromeos/network/network_profile_handler.h" | 22 #include "chromeos/network/network_profile_handler.h" |
24 #include "chromeos/network/network_state.h" | 23 #include "chromeos/network/network_state.h" |
25 #include "chromeos/network/network_state_handler.h" | 24 #include "chromeos/network/network_state_handler.h" |
26 #include "chromeos/network/onc/onc_utils.h" | 25 #include "chromeos/network/onc/onc_utils.h" |
27 #include "components/policy/core/common/cloud/cloud_policy_constants.h" | 26 #include "components/policy/core/common/cloud/cloud_policy_constants.h" |
28 | 27 |
29 namespace chromeos { | 28 namespace chromeos { |
30 | 29 |
31 namespace { | 30 namespace { |
32 | 31 |
33 // Writes the proxy config of |network| to |proxy_config|. Set |onc_source| to | 32 // Writes the proxy config of |network| to |proxy_config|. Set |onc_source| to |
34 // the source of this configuration. Returns false if no | 33 // the source of this configuration. Returns false if no |
35 // proxy was configured for this network. | 34 // proxy was configured for this network. |
36 bool GetProxyConfig(const PrefService* profile_prefs, | 35 bool GetProxyConfig(const PrefService* profile_prefs, |
37 const PrefService* local_state_prefs, | 36 const PrefService* local_state_prefs, |
38 const FavoriteState& network, | 37 const NetworkState& network, |
39 net::ProxyConfig* proxy_config, | 38 net::ProxyConfig* proxy_config, |
40 ::onc::ONCSource* onc_source) { | 39 ::onc::ONCSource* onc_source) { |
41 scoped_ptr<ProxyConfigDictionary> proxy_dict = | 40 scoped_ptr<ProxyConfigDictionary> proxy_dict = |
42 proxy_config::GetProxyConfigForFavoriteNetwork( | 41 proxy_config::GetProxyConfigForNetwork( |
43 profile_prefs, local_state_prefs, network, onc_source); | 42 profile_prefs, local_state_prefs, network, onc_source); |
44 if (!proxy_dict) | 43 if (!proxy_dict) |
45 return false; | 44 return false; |
46 return PrefProxyConfigTrackerImpl::PrefConfigToNetConfig(*proxy_dict, | 45 return PrefProxyConfigTrackerImpl::PrefConfigToNetConfig(*proxy_dict, |
47 proxy_config); | 46 proxy_config); |
48 } | 47 } |
49 | 48 |
50 } // namespace | 49 } // namespace |
51 | 50 |
52 ProxyConfigServiceImpl::ProxyConfigServiceImpl(PrefService* profile_prefs, | 51 ProxyConfigServiceImpl::ProxyConfigServiceImpl(PrefService* profile_prefs, |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 } | 153 } |
155 | 154 |
156 // This network is shared and not managed by the user's domain. | 155 // This network is shared and not managed by the user's domain. |
157 bool use_shared_proxies = profile_prefs->GetBoolean(prefs::kUseSharedProxies); | 156 bool use_shared_proxies = profile_prefs->GetBoolean(prefs::kUseSharedProxies); |
158 VLOG(1) << "Use proxy of shared network: " << use_shared_proxies; | 157 VLOG(1) << "Use proxy of shared network: " << use_shared_proxies; |
159 return !use_shared_proxies; | 158 return !use_shared_proxies; |
160 } | 159 } |
161 | 160 |
162 void ProxyConfigServiceImpl::DetermineEffectiveConfigFromDefaultNetwork() { | 161 void ProxyConfigServiceImpl::DetermineEffectiveConfigFromDefaultNetwork() { |
163 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); | 162 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); |
164 const FavoriteState* network = handler->DefaultFavoriteNetwork(); | 163 const NetworkState* network = handler->DefaultNetwork(); |
165 | 164 |
166 // Get prefs proxy config if available. | 165 // Get prefs proxy config if available. |
167 net::ProxyConfig pref_config; | 166 net::ProxyConfig pref_config; |
168 ProxyPrefs::ConfigState pref_state = GetProxyConfig(&pref_config); | 167 ProxyPrefs::ConfigState pref_state = GetProxyConfig(&pref_config); |
169 | 168 |
170 // Get network proxy config if available. | 169 // Get network proxy config if available. |
171 net::ProxyConfig network_config; | 170 net::ProxyConfig network_config; |
172 net::ProxyConfigService::ConfigAvailability network_availability = | 171 net::ProxyConfigService::ConfigAvailability network_availability = |
173 net::ProxyConfigService::CONFIG_UNSET; | 172 net::ProxyConfigService::CONFIG_UNSET; |
174 bool ignore_proxy = true; | 173 bool ignore_proxy = true; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 if (VLOG_IS_ON(1) && !update_pending()) { // Update was successful. | 224 if (VLOG_IS_ON(1) && !update_pending()) { // Update was successful. |
226 scoped_ptr<base::DictionaryValue> config_dict(effective_config.ToValue()); | 225 scoped_ptr<base::DictionaryValue> config_dict(effective_config.ToValue()); |
227 VLOG(1) << this << ": Proxy changed: " | 226 VLOG(1) << this << ": Proxy changed: " |
228 << ProxyPrefs::ConfigStateToDebugString(active_config_state_) | 227 << ProxyPrefs::ConfigStateToDebugString(active_config_state_) |
229 << ", " << *config_dict; | 228 << ", " << *config_dict; |
230 } | 229 } |
231 } | 230 } |
232 } | 231 } |
233 | 232 |
234 } // namespace chromeos | 233 } // namespace chromeos |
OLD | NEW |