| 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 "chromeos/network/network_state.h" | 5 #include "chromeos/network/network_state.h" |
| 6 | 6 |
| 7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "chromeos/network/network_profile_handler.h" | 10 #include "chromeos/network/network_profile_handler.h" |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 if (proxy_config_dict) { | 158 if (proxy_config_dict) { |
| 159 // Warning: The DictionaryValue returned from | 159 // Warning: The DictionaryValue returned from |
| 160 // ReadDictionaryFromJson/JSONParser is an optimized derived class that | 160 // ReadDictionaryFromJson/JSONParser is an optimized derived class that |
| 161 // doesn't allow releasing ownership of nested values. A Swap in the wrong | 161 // doesn't allow releasing ownership of nested values. A Swap in the wrong |
| 162 // order leads to memory access errors. | 162 // order leads to memory access errors. |
| 163 proxy_config_.MergeDictionary(proxy_config_dict.get()); | 163 proxy_config_.MergeDictionary(proxy_config_dict.get()); |
| 164 } else { | 164 } else { |
| 165 NET_LOG(ERROR) << "Failed to parse " << path() << "." << key; | 165 NET_LOG(ERROR) << "Failed to parse " << path() << "." << key; |
| 166 } | 166 } |
| 167 return true; | 167 return true; |
| 168 } else if (key == shill::kProviderProperty) { |
| 169 const base::DictionaryValue* dict; |
| 170 std::string provider_type; |
| 171 if (!value.GetAsDictionary(&dict) || |
| 172 !dict->GetStringWithoutPathExpansion(shill::kTypeProperty, |
| 173 &provider_type)) { |
| 174 return false; |
| 175 } |
| 176 |
| 177 if (provider_type != shill::kProviderThirdPartyVpn) { |
| 178 // If the network uses the built-in OpenVPN and L2TP support, set the |
| 179 // provider ID to an empty string. |
| 180 vpn_provider_id_.clear(); |
| 181 return true; |
| 182 } |
| 183 |
| 184 // If the network uses a third-party VPN provider, set the provider ID to |
| 185 // the third-party VPN provider's extension ID, which is held in the |
| 186 // |shill::kHostProperty|. |
| 187 return dict->GetStringWithoutPathExpansion(shill::kHostProperty, |
| 188 &vpn_provider_id_); |
| 168 } | 189 } |
| 169 return false; | 190 return false; |
| 170 } | 191 } |
| 171 | 192 |
| 172 bool NetworkState::InitialPropertiesReceived( | 193 bool NetworkState::InitialPropertiesReceived( |
| 173 const base::DictionaryValue& properties) { | 194 const base::DictionaryValue& properties) { |
| 174 NET_LOG(EVENT) << "InitialPropertiesReceived: " << path() << ": " << name() | 195 NET_LOG(EVENT) << "InitialPropertiesReceived: " << path() << ": " << name() |
| 175 << " State: " << connection_state_ << " Visible: " << visible_; | 196 << " State: " << connection_state_ << " Visible: " << visible_; |
| 176 if (!properties.HasKey(shill::kTypeProperty)) { | 197 if (!properties.HasKey(shill::kTypeProperty)) { |
| 177 NET_LOG(ERROR) << "NetworkState has no type: " | 198 NET_LOG(ERROR) << "NetworkState has no type: " |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 return IsCaptivePortalState(shill_properties, false /* log */); | 398 return IsCaptivePortalState(shill_properties, false /* log */); |
| 378 } | 399 } |
| 379 | 400 |
| 380 // static | 401 // static |
| 381 bool NetworkState::ErrorIsValid(const std::string& error) { | 402 bool NetworkState::ErrorIsValid(const std::string& error) { |
| 382 // Shill uses "Unknown" to indicate an unset or cleared error state. | 403 // Shill uses "Unknown" to indicate an unset or cleared error state. |
| 383 return !error.empty() && error != kErrorUnknown; | 404 return !error.empty() && error != kErrorUnknown; |
| 384 } | 405 } |
| 385 | 406 |
| 386 } // namespace chromeos | 407 } // namespace chromeos |
| OLD | NEW |