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/net/proxy_config_handler.h" | 15 #include "chrome/browser/chromeos/net/proxy_config_handler.h" |
16 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 16 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
17 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
18 #include "chromeos/network/network_profile.h" | 18 #include "chromeos/network/network_profile.h" |
19 #include "chromeos/network/network_profile_handler.h" | 19 #include "chromeos/network/network_profile_handler.h" |
20 #include "chromeos/network/network_state.h" | 20 #include "chromeos/network/network_state.h" |
21 #include "chromeos/network/network_state_handler.h" | 21 #include "chromeos/network/network_state_handler.h" |
22 #include "chromeos/network/onc/onc_utils.h" | 22 #include "chromeos/network/onc/onc_utils.h" |
23 #include "components/policy/core/common/cloud/cloud_policy_constants.h" | 23 #include "components/policy/core/common/cloud/cloud_policy_constants.h" |
| 24 #include "components/proxy_config/pref_proxy_config_tracker_impl.h" |
24 #include "components/proxy_config/proxy_config_dictionary.h" | 25 #include "components/proxy_config/proxy_config_dictionary.h" |
25 #include "components/proxy_config/proxy_prefs.h" | 26 #include "components/proxy_config/proxy_prefs.h" |
26 #include "components/user_manager/user_manager.h" | 27 #include "components/user_manager/user_manager.h" |
| 28 #include "content/public/browser/browser_thread.h" |
27 | 29 |
28 namespace chromeos { | 30 namespace chromeos { |
29 | 31 |
30 namespace { | 32 namespace { |
31 | 33 |
32 // Writes the proxy config of |network| to |proxy_config|. Set |onc_source| to | 34 // Writes the proxy config of |network| to |proxy_config|. Set |onc_source| to |
33 // the source of this configuration. Returns false if no | 35 // the source of this configuration. Returns false if no |
34 // proxy was configured for this network. | 36 // proxy was configured for this network. |
35 bool GetProxyConfig(const PrefService* profile_prefs, | 37 bool GetProxyConfig(const PrefService* profile_prefs, |
36 const PrefService* local_state_prefs, | 38 const PrefService* local_state_prefs, |
37 const NetworkState& network, | 39 const NetworkState& network, |
38 net::ProxyConfig* proxy_config, | 40 net::ProxyConfig* proxy_config, |
39 ::onc::ONCSource* onc_source) { | 41 ::onc::ONCSource* onc_source) { |
40 scoped_ptr<ProxyConfigDictionary> proxy_dict = | 42 scoped_ptr<ProxyConfigDictionary> proxy_dict = |
41 proxy_config::GetProxyConfigForNetwork( | 43 proxy_config::GetProxyConfigForNetwork( |
42 profile_prefs, local_state_prefs, network, onc_source); | 44 profile_prefs, local_state_prefs, network, onc_source); |
43 if (!proxy_dict) | 45 if (!proxy_dict) |
44 return false; | 46 return false; |
45 return PrefProxyConfigTrackerImpl::PrefConfigToNetConfig(*proxy_dict, | 47 return PrefProxyConfigTrackerImpl::PrefConfigToNetConfig(*proxy_dict, |
46 proxy_config); | 48 proxy_config); |
47 } | 49 } |
48 | 50 |
49 } // namespace | 51 } // namespace |
50 | 52 |
51 ProxyConfigServiceImpl::ProxyConfigServiceImpl(PrefService* profile_prefs, | 53 ProxyConfigServiceImpl::ProxyConfigServiceImpl(PrefService* profile_prefs, |
52 PrefService* local_state_prefs) | 54 PrefService* local_state_prefs) |
53 : PrefProxyConfigTrackerImpl(profile_prefs ? profile_prefs | 55 : PrefProxyConfigTrackerImpl( |
54 : local_state_prefs), | 56 profile_prefs ? profile_prefs : local_state_prefs, |
| 57 content::BrowserThread::GetMessageLoopProxyForThread( |
| 58 content::BrowserThread::IO)), |
55 active_config_state_(ProxyPrefs::CONFIG_UNSET), | 59 active_config_state_(ProxyPrefs::CONFIG_UNSET), |
56 profile_prefs_(profile_prefs), | 60 profile_prefs_(profile_prefs), |
57 local_state_prefs_(local_state_prefs), | 61 local_state_prefs_(local_state_prefs), |
58 pointer_factory_(this) { | 62 pointer_factory_(this) { |
59 const base::Closure proxy_change_callback = base::Bind( | 63 const base::Closure proxy_change_callback = base::Bind( |
60 &ProxyConfigServiceImpl::OnProxyPrefChanged, base::Unretained(this)); | 64 &ProxyConfigServiceImpl::OnProxyPrefChanged, base::Unretained(this)); |
61 | 65 |
62 if (profile_prefs) { | 66 if (profile_prefs) { |
63 profile_pref_registrar_.Init(profile_prefs); | 67 profile_pref_registrar_.Init(profile_prefs); |
64 profile_pref_registrar_.Add(prefs::kOpenNetworkConfiguration, | 68 profile_pref_registrar_.Add(prefs::kOpenNetworkConfiguration, |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 if (VLOG_IS_ON(1) && !update_pending()) { // Update was successful. | 236 if (VLOG_IS_ON(1) && !update_pending()) { // Update was successful. |
233 scoped_ptr<base::DictionaryValue> config_dict(effective_config.ToValue()); | 237 scoped_ptr<base::DictionaryValue> config_dict(effective_config.ToValue()); |
234 VLOG(1) << this << ": Proxy changed: " | 238 VLOG(1) << this << ": Proxy changed: " |
235 << ProxyPrefs::ConfigStateToDebugString(active_config_state_) | 239 << ProxyPrefs::ConfigStateToDebugString(active_config_state_) |
236 << ", " << *config_dict; | 240 << ", " << *config_dict; |
237 } | 241 } |
238 } | 242 } |
239 } | 243 } |
240 | 244 |
241 } // namespace chromeos | 245 } // namespace chromeos |
OLD | NEW |