| Index: chrome/browser/chromeos/ui_proxy_config_service.cc
|
| diff --git a/chrome/browser/chromeos/ui_proxy_config_service.cc b/chrome/browser/chromeos/ui_proxy_config_service.cc
|
| index a191ed8435cb80b75f854ad3b9f90026f7378228..3c0d4b085c59ec110a01831f0246229f7ed4daa1 100644
|
| --- a/chrome/browser/chromeos/ui_proxy_config_service.cc
|
| +++ b/chrome/browser/chromeos/ui_proxy_config_service.cc
|
| @@ -7,11 +7,10 @@
|
| #include "base/logging.h"
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/values.h"
|
| -#include "chrome/browser/chromeos/cros/cros_library.h"
|
| -#include "chrome/browser/chromeos/cros/network_library.h"
|
| -#include "chrome/browser/chromeos/cros/network_property_ui_data.h"
|
| +#include "chrome/browser/chromeos/net/proxy_config_handler.h"
|
| #include "chrome/browser/chromeos/proxy_config_service_impl.h"
|
| -#include "chromeos/network/onc/onc_utils.h"
|
| +#include "chromeos/network/network_state.h"
|
| +#include "chromeos/network/network_state_handler.h"
|
| #include "grit/generated_resources.h"
|
| #include "net/proxy/proxy_config.h"
|
|
|
| @@ -36,38 +35,23 @@ const char* ModeToString(UIProxyConfig::Mode mode) {
|
| return "";
|
| }
|
|
|
| -bool ParseProxyConfig(const std::string& pref_proxy_config,
|
| - net::ProxyConfig* proxy_config) {
|
| - if (pref_proxy_config.empty())
|
| +// Writes the proxy config of |network| to |proxy_config|. Returns false if no
|
| +// proxy was configured for this network.
|
| +bool GetProxyConfig(const NetworkState& network,
|
| + net::ProxyConfig* proxy_config) {
|
| + scoped_ptr<ProxyConfigDictionary> proxy_dict =
|
| + proxy_config::GetProxyConfigOfNetwork(network);
|
| + if (!proxy_dict)
|
| return false;
|
| -
|
| - scoped_ptr<base::DictionaryValue> proxy_config_dict(
|
| - chromeos::onc::ReadDictionaryFromJson(pref_proxy_config));
|
| - if (!proxy_config_dict) {
|
| - LOG(WARNING) << "Failed to parse proxy config.";
|
| - return false;
|
| - }
|
| -
|
| - ProxyConfigDictionary proxy_config_dict_wrapper(proxy_config_dict.get());
|
| - return PrefProxyConfigTrackerImpl::PrefConfigToNetConfig(
|
| - proxy_config_dict_wrapper,
|
| - proxy_config);
|
| + return PrefProxyConfigTrackerImpl::PrefConfigToNetConfig(*proxy_dict,
|
| + proxy_config);
|
| }
|
|
|
| // Returns true if proxy settings of |network| are editable.
|
| -bool IsNetworkProxySettingsEditable(const Network& network) {
|
| - NetworkLibrary* network_library = CrosLibrary::Get()->GetNetworkLibrary();
|
| - const base::DictionaryValue* onc =
|
| - network_library->FindOncForNetwork(network.unique_id());
|
| - if (!onc)
|
| - return true;
|
| -
|
| - NetworkPropertyUIData proxy_settings_ui_data;
|
| - proxy_settings_ui_data.ParseOncProperty(
|
| - network.ui_data().onc_source(),
|
| - onc,
|
| - onc::network_config::kProxySettings);
|
| - return proxy_settings_ui_data.IsEditable();
|
| +bool IsNetworkProxySettingsEditable(const NetworkState& network) {
|
| + onc::ONCSource source = network.onc_source();
|
| + return source != onc::ONC_SOURCE_DEVICE_POLICY &&
|
| + source != onc::ONC_SOURCE_USER_POLICY;
|
| }
|
|
|
| } // namespace
|
| @@ -84,9 +68,9 @@ void UIProxyConfigService::SetPrefs(PrefService* pref_service) {
|
|
|
| void UIProxyConfigService::SetCurrentNetwork(
|
| const std::string& current_network) {
|
| - Network* network = NULL;
|
| + const NetworkState* network = NULL;
|
| if (!current_network.empty()) {
|
| - network = CrosLibrary::Get()->GetNetworkLibrary()->FindNetworkByPath(
|
| + network = NetworkHandler::Get()->network_state_handler()->GetNetworkState(
|
| current_network);
|
| LOG_IF(ERROR, !network)
|
| << "Can't find requested network " << current_network;
|
| @@ -115,24 +99,28 @@ void UIProxyConfigService::SetProxyConfig(const UIProxyConfig& config) {
|
| if (current_ui_network_.empty())
|
| return;
|
|
|
| - // Update config to shill.
|
| - std::string value;
|
| - if (!current_ui_config_.SerializeForNetwork(&value))
|
| - return;
|
| -
|
| - VLOG(1) << "Set proxy for " << current_ui_network_ << " to " << value;
|
| - current_ui_config_.state = ProxyPrefs::CONFIG_SYSTEM;
|
| -
|
| - Network* network = CrosLibrary::Get()->GetNetworkLibrary()->FindNetworkByPath(
|
| - current_ui_network_);
|
| + const NetworkState* network =
|
| + NetworkHandler::Get()->network_state_handler()->
|
| + GetNetworkState(current_ui_network_);
|
| if (!network) {
|
| LOG(ERROR) << "Can't find requested network " << current_ui_network_;
|
| return;
|
| }
|
| - network->SetProxyConfig(value);
|
| +
|
| + // Store config for this network.
|
| + scoped_ptr<base::DictionaryValue> proxy_config_value(
|
| + config.ToPrefProxyConfig());
|
| + ProxyConfigDictionary proxy_config_dict(proxy_config_value.get());
|
| +
|
| + VLOG(1) << "Set proxy for " << current_ui_network_
|
| + << " to " << *proxy_config_value;
|
| +
|
| + proxy_config::SetProxyConfigOfNetwork(proxy_config_dict, *network);
|
| + current_ui_config_.state = ProxyPrefs::CONFIG_SYSTEM;
|
| }
|
|
|
| -void UIProxyConfigService::DetermineEffectiveConfig(const Network& network) {
|
| +void UIProxyConfigService::DetermineEffectiveConfig(
|
| + const NetworkState& network) {
|
| DCHECK(pref_service_);
|
|
|
| // Get prefs proxy config if available.
|
| @@ -144,7 +132,7 @@ void UIProxyConfigService::DetermineEffectiveConfig(const Network& network) {
|
| net::ProxyConfig network_config;
|
| net::ProxyConfigService::ConfigAvailability network_availability =
|
| net::ProxyConfigService::CONFIG_UNSET;
|
| - if (ParseProxyConfig(network.proxy_config(), &network_config)) {
|
| + if (chromeos::GetProxyConfig(network, &network_config)) {
|
| // Network is private or shared with user using shared proxies.
|
| VLOG(1) << this << ": using network proxy: " << network.proxy_config();
|
| network_availability = net::ProxyConfigService::CONFIG_VALID;
|
| @@ -172,7 +160,7 @@ void UIProxyConfigService::DetermineEffectiveConfig(const Network& network) {
|
| current_ui_config_.user_modifiable =
|
| !ProxyConfigServiceImpl::IgnoreProxy(pref_service_,
|
| network.profile_path(),
|
| - network.ui_data().onc_source());
|
| + network.onc_source());
|
| }
|
| }
|
|
|
|
|