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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 } | 74 } |
75 | 75 |
76 void UIProxyConfigService::SetCurrentNetwork( | 76 void UIProxyConfigService::SetCurrentNetwork( |
77 const std::string& current_network) { | 77 const std::string& current_network) { |
78 current_ui_network_ = current_network; | 78 current_ui_network_ = current_network; |
79 } | 79 } |
80 | 80 |
81 void UIProxyConfigService::UpdateFromPrefs() { | 81 void UIProxyConfigService::UpdateFromPrefs() { |
82 const FavoriteState* network = NULL; | 82 const FavoriteState* network = NULL; |
83 if (!current_ui_network_.empty()) { | 83 if (!current_ui_network_.empty()) { |
84 network = NetworkHandler::Get()->network_state_handler()->GetFavoriteState( | 84 network = NetworkHandler::Get() |
85 current_ui_network_); | 85 ->network_state_handler() |
| 86 ->GetFavoriteStateFromServicePath(current_ui_network_, |
| 87 true /* configured_only */); |
86 LOG_IF(ERROR, !network) << "Couldn't find FavoriteState for network " | 88 LOG_IF(ERROR, !network) << "Couldn't find FavoriteState for network " |
87 << current_ui_network_; | 89 << current_ui_network_; |
88 } | 90 } |
89 if (!network) { | 91 if (!network) { |
90 current_ui_network_.clear(); | 92 current_ui_network_.clear(); |
91 current_ui_config_ = UIProxyConfig(); | 93 current_ui_config_ = UIProxyConfig(); |
92 return; | 94 return; |
93 } | 95 } |
94 | 96 |
95 DetermineEffectiveConfig(*network); | 97 DetermineEffectiveConfig(*network); |
96 VLOG(1) << "Current ui network: " << network->name() << ", " | 98 VLOG(1) << "Current ui network: " << network->name() << ", " |
97 << ModeToString(current_ui_config_.mode) << ", " | 99 << ModeToString(current_ui_config_.mode) << ", " |
98 << ProxyPrefs::ConfigStateToDebugString(current_ui_config_.state) | 100 << ProxyPrefs::ConfigStateToDebugString(current_ui_config_.state) |
99 << ", modifiable:" << current_ui_config_.user_modifiable; | 101 << ", modifiable:" << current_ui_config_.user_modifiable; |
100 } | 102 } |
101 | 103 |
102 void UIProxyConfigService::GetProxyConfig(UIProxyConfig* config) const { | 104 void UIProxyConfigService::GetProxyConfig(UIProxyConfig* config) const { |
103 *config = current_ui_config_; | 105 *config = current_ui_config_; |
104 } | 106 } |
105 | 107 |
106 void UIProxyConfigService::SetProxyConfig(const UIProxyConfig& config) { | 108 void UIProxyConfigService::SetProxyConfig(const UIProxyConfig& config) { |
107 current_ui_config_ = config; | 109 current_ui_config_ = config; |
108 if (current_ui_network_.empty()) | 110 if (current_ui_network_.empty()) |
109 return; | 111 return; |
110 | 112 |
111 const FavoriteState* network = | 113 const FavoriteState* network = |
112 NetworkHandler::Get()->network_state_handler()->GetFavoriteState( | 114 NetworkHandler::Get() |
113 current_ui_network_); | 115 ->network_state_handler() |
| 116 ->GetFavoriteStateFromServicePath(current_ui_network_, |
| 117 true /* configured_only */); |
114 if (!network) { | 118 if (!network) { |
115 LOG(ERROR) << "Couldn't find FavoriteState for network " | 119 LOG(ERROR) << "Couldn't find FavoriteState for network " |
116 << current_ui_network_; | 120 << current_ui_network_; |
117 return; | 121 return; |
118 } | 122 } |
119 | 123 |
120 // Store config for this network. | 124 // Store config for this network. |
121 scoped_ptr<base::DictionaryValue> proxy_config_value( | 125 scoped_ptr<base::DictionaryValue> proxy_config_value( |
122 config.ToPrefProxyConfig()); | 126 config.ToPrefProxyConfig()); |
123 ProxyConfigDictionary proxy_config_dict(proxy_config_value.get()); | 127 ProxyConfigDictionary proxy_config_dict(proxy_config_value.get()); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 } else if (!IsNetworkProxySettingsEditable(onc_source)) { | 178 } else if (!IsNetworkProxySettingsEditable(onc_source)) { |
175 current_ui_config_.state = ProxyPrefs::CONFIG_POLICY; | 179 current_ui_config_.state = ProxyPrefs::CONFIG_POLICY; |
176 current_ui_config_.user_modifiable = false; | 180 current_ui_config_.user_modifiable = false; |
177 } else { | 181 } else { |
178 current_ui_config_.user_modifiable = !ProxyConfigServiceImpl::IgnoreProxy( | 182 current_ui_config_.user_modifiable = !ProxyConfigServiceImpl::IgnoreProxy( |
179 profile_prefs_, network.profile_path(), onc_source); | 183 profile_prefs_, network.profile_path(), onc_source); |
180 } | 184 } |
181 } | 185 } |
182 | 186 |
183 } // namespace chromeos | 187 } // namespace chromeos |
OLD | NEW |