| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/ui_proxy_config_service.h" | 5 #include "chromeos/network/proxy/ui_proxy_config_service.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| 11 #include "chrome/browser/chromeos/net/proxy_config_handler.h" | |
| 12 #include "chrome/browser/chromeos/proxy_config_service_impl.h" | |
| 13 #include "chromeos/network/network_state.h" | 11 #include "chromeos/network/network_state.h" |
| 14 #include "chromeos/network/network_state_handler.h" | 12 #include "chromeos/network/network_state_handler.h" |
| 13 #include "chromeos/network/proxy/proxy_config_handler.h" |
| 14 #include "chromeos/network/proxy/proxy_config_service_impl.h" |
| 15 #include "components/device_event_log/device_event_log.h" | 15 #include "components/device_event_log/device_event_log.h" |
| 16 #include "components/proxy_config/pref_proxy_config_tracker_impl.h" | 16 #include "components/proxy_config/pref_proxy_config_tracker_impl.h" |
| 17 #include "net/proxy/proxy_config.h" | 17 #include "net/proxy/proxy_config.h" |
| 18 | 18 |
| 19 namespace chromeos { | 19 namespace chromeos { |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 const char* ModeToString(UIProxyConfig::Mode mode) { | 23 const char* ModeToString(UIProxyConfig::Mode mode) { |
| 24 switch (mode) { | 24 switch (mode) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 | 56 |
| 57 // Returns true if proxy settings from |onc_source| are editable. | 57 // Returns true if proxy settings from |onc_source| are editable. |
| 58 bool IsNetworkProxySettingsEditable(const onc::ONCSource onc_source) { | 58 bool IsNetworkProxySettingsEditable(const onc::ONCSource onc_source) { |
| 59 return onc_source != onc::ONC_SOURCE_DEVICE_POLICY && | 59 return onc_source != onc::ONC_SOURCE_DEVICE_POLICY && |
| 60 onc_source != onc::ONC_SOURCE_USER_POLICY; | 60 onc_source != onc::ONC_SOURCE_USER_POLICY; |
| 61 } | 61 } |
| 62 | 62 |
| 63 } // namespace | 63 } // namespace |
| 64 | 64 |
| 65 UIProxyConfigService::UIProxyConfigService() | 65 UIProxyConfigService::UIProxyConfigService() |
| 66 : profile_prefs_(nullptr), local_state_prefs_(nullptr) { | 66 : profile_prefs_(nullptr), local_state_prefs_(nullptr) {} |
| 67 } | |
| 68 | 67 |
| 69 UIProxyConfigService::~UIProxyConfigService() { | 68 UIProxyConfigService::~UIProxyConfigService() {} |
| 70 } | |
| 71 | 69 |
| 72 void UIProxyConfigService::SetPrefs(PrefService* profile_prefs, | 70 void UIProxyConfigService::SetPrefs(PrefService* profile_prefs, |
| 73 PrefService* local_state_prefs) { | 71 PrefService* local_state_prefs) { |
| 74 profile_prefs_ = profile_prefs; | 72 profile_prefs_ = profile_prefs; |
| 75 local_state_prefs_ = local_state_prefs; | 73 local_state_prefs_ = local_state_prefs; |
| 76 } | 74 } |
| 77 | 75 |
| 78 void UIProxyConfigService::SetCurrentNetworkGuid( | 76 void UIProxyConfigService::SetCurrentNetworkGuid( |
| 79 const std::string& current_guid) { | 77 const std::string& current_guid) { |
| 80 current_ui_network_guid_ = current_guid; | 78 current_ui_network_guid_ = current_guid; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 const NetworkState& network) { | 134 const NetworkState& network) { |
| 137 DCHECK(local_state_prefs_); | 135 DCHECK(local_state_prefs_); |
| 138 | 136 |
| 139 // The pref service to read proxy settings that apply to all networks. | 137 // The pref service to read proxy settings that apply to all networks. |
| 140 // Settings from the profile overrule local state. | 138 // Settings from the profile overrule local state. |
| 141 PrefService* top_pref_service = | 139 PrefService* top_pref_service = |
| 142 profile_prefs_ ? profile_prefs_ : local_state_prefs_; | 140 profile_prefs_ ? profile_prefs_ : local_state_prefs_; |
| 143 | 141 |
| 144 // Get prefs proxy config if available. | 142 // Get prefs proxy config if available. |
| 145 net::ProxyConfig pref_config; | 143 net::ProxyConfig pref_config; |
| 146 ProxyPrefs::ConfigState pref_state = ProxyConfigServiceImpl::ReadPrefConfig( | 144 ProxyPrefs::ConfigState pref_state = |
| 147 top_pref_service, &pref_config); | 145 ProxyConfigServiceImpl::ReadPrefConfig(top_pref_service, &pref_config); |
| 148 | 146 |
| 149 // Get network proxy config if available. | 147 // Get network proxy config if available. |
| 150 net::ProxyConfig network_config; | 148 net::ProxyConfig network_config; |
| 151 net::ProxyConfigService::ConfigAvailability network_availability = | 149 net::ProxyConfigService::ConfigAvailability network_availability = |
| 152 net::ProxyConfigService::CONFIG_UNSET; | 150 net::ProxyConfigService::CONFIG_UNSET; |
| 153 onc::ONCSource onc_source = onc::ONC_SOURCE_NONE; | 151 onc::ONCSource onc_source = onc::ONC_SOURCE_NONE; |
| 154 if (chromeos::GetProxyConfig(profile_prefs_, | 152 if (chromeos::GetProxyConfig(profile_prefs_, local_state_prefs_, network, |
| 155 local_state_prefs_, | 153 &network_config, &onc_source)) { |
| 156 network, | |
| 157 &network_config, | |
| 158 &onc_source)) { | |
| 159 // Network is private or shared with user using shared proxies. | 154 // Network is private or shared with user using shared proxies. |
| 160 VLOG(1) << this << ": using proxy of network: " << network.path(); | 155 VLOG(1) << this << ": using proxy of network: " << network.path(); |
| 161 network_availability = net::ProxyConfigService::CONFIG_VALID; | 156 network_availability = net::ProxyConfigService::CONFIG_VALID; |
| 162 } | 157 } |
| 163 | 158 |
| 164 // Determine effective proxy config, either from prefs or network. | 159 // Determine effective proxy config, either from prefs or network. |
| 165 ProxyPrefs::ConfigState effective_config_state; | 160 ProxyPrefs::ConfigState effective_config_state; |
| 166 net::ProxyConfig effective_config; | 161 net::ProxyConfig effective_config; |
| 167 ProxyConfigServiceImpl::GetEffectiveProxyConfig( | 162 ProxyConfigServiceImpl::GetEffectiveProxyConfig( |
| 168 pref_state, pref_config, | 163 pref_state, pref_config, network_availability, network_config, false, |
| 169 network_availability, network_config, false, | |
| 170 &effective_config_state, &effective_config); | 164 &effective_config_state, &effective_config); |
| 171 | 165 |
| 172 // Store effective proxy into |current_ui_config_|. | 166 // Store effective proxy into |current_ui_config_|. |
| 173 current_ui_config_.FromNetProxyConfig(effective_config); | 167 current_ui_config_.FromNetProxyConfig(effective_config); |
| 174 current_ui_config_.state = effective_config_state; | 168 current_ui_config_.state = effective_config_state; |
| 175 if (ProxyConfigServiceImpl::PrefPrecedes(effective_config_state)) { | 169 if (ProxyConfigServiceImpl::PrefPrecedes(effective_config_state)) { |
| 176 current_ui_config_.user_modifiable = false; | 170 current_ui_config_.user_modifiable = false; |
| 177 } else if (!IsNetworkProxySettingsEditable(onc_source)) { | 171 } else if (!IsNetworkProxySettingsEditable(onc_source)) { |
| 178 current_ui_config_.state = ProxyPrefs::CONFIG_POLICY; | 172 current_ui_config_.state = ProxyPrefs::CONFIG_POLICY; |
| 179 current_ui_config_.user_modifiable = false; | 173 current_ui_config_.user_modifiable = false; |
| 180 } else { | 174 } else { |
| 181 current_ui_config_.user_modifiable = !ProxyConfigServiceImpl::IgnoreProxy( | 175 current_ui_config_.user_modifiable = !ProxyConfigServiceImpl::IgnoreProxy( |
| 182 profile_prefs_, network.profile_path(), onc_source); | 176 profile_prefs_, network.profile_path(), onc_source); |
| 183 } | 177 } |
| 184 } | 178 } |
| 185 | 179 |
| 186 } // namespace chromeos | 180 } // namespace chromeos |
| OLD | NEW |