| 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 "chrome/browser/chromeos/ui_proxy_config_service.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/browser/chromeos/net/proxy_config_handler.h" | 10 #include "chrome/browser/chromeos/net/proxy_config_handler.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 | 49 |
| 50 // Returns true if proxy settings of |network| are editable. | 50 // Returns true if proxy settings of |network| are editable. |
| 51 bool IsNetworkProxySettingsEditable(const NetworkState& network) { | 51 bool IsNetworkProxySettingsEditable(const NetworkState& network) { |
| 52 onc::ONCSource source = network.onc_source(); | 52 onc::ONCSource source = network.onc_source(); |
| 53 return source != onc::ONC_SOURCE_DEVICE_POLICY && | 53 return source != onc::ONC_SOURCE_DEVICE_POLICY && |
| 54 source != onc::ONC_SOURCE_USER_POLICY; | 54 source != onc::ONC_SOURCE_USER_POLICY; |
| 55 } | 55 } |
| 56 | 56 |
| 57 } // namespace | 57 } // namespace |
| 58 | 58 |
| 59 UIProxyConfigService::UIProxyConfigService() { | 59 UIProxyConfigService::UIProxyConfigService() |
| 60 : signin_screen_(false), |
| 61 pref_service_(NULL) { |
| 60 } | 62 } |
| 61 | 63 |
| 62 UIProxyConfigService::~UIProxyConfigService() { | 64 UIProxyConfigService::~UIProxyConfigService() { |
| 63 } | 65 } |
| 64 | 66 |
| 65 void UIProxyConfigService::SetPrefs(PrefService* pref_service) { | 67 void UIProxyConfigService::SetPrefs(bool signin_screen, |
| 68 PrefService* pref_service) { |
| 69 signin_screen_ = signin_screen; |
| 66 pref_service_ = pref_service; | 70 pref_service_ = pref_service; |
| 67 } | 71 } |
| 68 | 72 |
| 69 void UIProxyConfigService::SetCurrentNetwork( | 73 void UIProxyConfigService::SetCurrentNetwork( |
| 70 const std::string& current_network) { | 74 const std::string& current_network) { |
| 71 const NetworkState* network = NULL; | 75 const NetworkState* network = NULL; |
| 72 if (!current_network.empty()) { | 76 if (!current_network.empty()) { |
| 73 network = NetworkHandler::Get()->network_state_handler()->GetNetworkState( | 77 network = NetworkHandler::Get()->network_state_handler()->GetNetworkState( |
| 74 current_network); | 78 current_network); |
| 75 LOG_IF(ERROR, !network) | 79 LOG_IF(ERROR, !network) |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 current_ui_config_.FromNetProxyConfig(effective_config); | 154 current_ui_config_.FromNetProxyConfig(effective_config); |
| 151 current_ui_config_.state = effective_config_state; | 155 current_ui_config_.state = effective_config_state; |
| 152 if (ProxyConfigServiceImpl::PrefPrecedes(effective_config_state)) { | 156 if (ProxyConfigServiceImpl::PrefPrecedes(effective_config_state)) { |
| 153 current_ui_config_.user_modifiable = false; | 157 current_ui_config_.user_modifiable = false; |
| 154 } else if (!IsNetworkProxySettingsEditable(network)) { | 158 } else if (!IsNetworkProxySettingsEditable(network)) { |
| 155 // TODO(xiyuan): Figure out the right way to set config state for managed | 159 // TODO(xiyuan): Figure out the right way to set config state for managed |
| 156 // network. | 160 // network. |
| 157 current_ui_config_.state = ProxyPrefs::CONFIG_POLICY; | 161 current_ui_config_.state = ProxyPrefs::CONFIG_POLICY; |
| 158 current_ui_config_.user_modifiable = false; | 162 current_ui_config_.user_modifiable = false; |
| 159 } else { | 163 } else { |
| 160 current_ui_config_.user_modifiable = | 164 current_ui_config_.user_modifiable = !ProxyConfigServiceImpl::IgnoreProxy( |
| 161 !ProxyConfigServiceImpl::IgnoreProxy(pref_service_, | 165 signin_screen_ ? NULL : pref_service_, |
| 162 network.profile_path(), | 166 network.profile_path(), |
| 163 network.onc_source()); | 167 network.onc_source()); |
| 164 } | 168 } |
| 165 } | 169 } |
| 166 | 170 |
| 167 } // namespace chromeos | 171 } // namespace chromeos |
| OLD | NEW |