| 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/ui/webui/chromeos/login/network_state_informer.h" | 5 #include "chrome/browser/ui/webui/chromeos/login/network_state_informer.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "chrome/browser/chromeos/proxy_config_service_impl.h" | 10 #include "chrome/browser/prefs/proxy_config_dictionary.h" |
| 11 #include "chrome/browser/prefs/proxy_prefs.h" |
| 11 #include "chrome/common/chrome_notification_types.h" | 12 #include "chrome/common/chrome_notification_types.h" |
| 12 #include "chromeos/network/network_state.h" | 13 #include "chromeos/network/network_state.h" |
| 13 #include "chromeos/network/network_state_handler.h" | 14 #include "chromeos/network/network_state_handler.h" |
| 14 #include "net/proxy/proxy_config.h" | 15 #include "net/proxy/proxy_config.h" |
| 15 #include "third_party/cros_system_api/dbus/service_constants.h" | 16 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 16 | 17 |
| 17 namespace { | 18 namespace { |
| 18 | 19 |
| 19 // Timeout to smooth temporary network state transitions for flaky networks. | 20 // Timeout to smooth temporary network state transitions for flaky networks. |
| 20 const int kNetworkStateCheckDelaySec = 3; | 21 const int kNetworkStateCheckDelaySec = 3; |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 return ONLINE; | 206 return ONLINE; |
| 206 if (network->connection_state() == flimflam::kStatePortal) | 207 if (network->connection_state() == flimflam::kStatePortal) |
| 207 return CAPTIVE_PORTAL; | 208 return CAPTIVE_PORTAL; |
| 208 } | 209 } |
| 209 return OFFLINE; | 210 return OFFLINE; |
| 210 } | 211 } |
| 211 | 212 |
| 212 bool NetworkStateInformer::IsProxyConfigured(const NetworkState* network) { | 213 bool NetworkStateInformer::IsProxyConfigured(const NetworkState* network) { |
| 213 DCHECK(network); | 214 DCHECK(network); |
| 214 | 215 |
| 215 ProxyStateMap::iterator it = proxy_state_map_.find(network->guid()); | 216 ProxyConfigDictionary proxy_dict(&network->proxy_config()); |
| 216 if (it != proxy_state_map_.end() && | 217 ProxyPrefs::ProxyMode mode; |
| 217 it->second.proxy_config == network->proxy_config()) { | 218 return !proxy_dict.GetMode(&mode) || mode == ProxyPrefs::MODE_FIXED_SERVERS; |
| 218 return it->second.configured; | |
| 219 } | |
| 220 net::ProxyConfig proxy_config; | |
| 221 if (!ProxyConfigServiceImpl::ParseProxyConfig(network->proxy_config(), | |
| 222 &proxy_config)) | |
| 223 return false; | |
| 224 bool configured = !proxy_config.proxy_rules().empty(); | |
| 225 proxy_state_map_[network->guid()] = | |
| 226 ProxyState(network->proxy_config(), configured); | |
| 227 return configured; | |
| 228 } | 219 } |
| 229 | 220 |
| 230 } // namespace chromeos | 221 } // namespace chromeos |
| OLD | NEW |