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/onc/onc_translator.h" | 5 #include "chromeos/network/onc/onc_translator.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
11 #include "base/json/json_writer.h" | 11 #include "base/json/json_writer.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
14 #include "base/values.h" | 14 #include "base/values.h" |
15 #include "chromeos/network/network_profile_handler.h" | 15 #include "chromeos/network/network_profile_handler.h" |
16 #include "chromeos/network/network_state.h" | 16 #include "chromeos/network/network_state.h" |
17 #include "chromeos/network/network_util.h" | 17 #include "chromeos/network/network_util.h" |
18 #include "chromeos/network/onc/onc_signature.h" | 18 #include "chromeos/network/onc/onc_signature.h" |
19 #include "chromeos/network/onc/onc_translation_tables.h" | 19 #include "chromeos/network/onc/onc_translation_tables.h" |
20 #include "chromeos/network/onc/onc_utils.h" | 20 #include "chromeos/network/onc/onc_utils.h" |
21 #include "chromeos/network/shill_property_util.h" | 21 #include "chromeos/network/shill_property_util.h" |
22 #include "components/onc/onc_constants.h" | 22 #include "components/onc/onc_constants.h" |
23 #include "third_party/cros_system_api/dbus/service_constants.h" | 23 #include "third_party/cros_system_api/dbus/service_constants.h" |
24 | 24 |
25 namespace chromeos { | 25 namespace chromeos { |
26 namespace onc { | 26 namespace onc { |
27 | 27 |
28 namespace { | 28 namespace { |
29 | 29 |
30 const char kKeyManagementIEEE8021X[] = "IEEE8021X"; | |
stevenjb
2015/11/04 18:36:00
nit: TODO
| |
31 | |
30 // Converts |str| to a base::Value of the given |type|. If the conversion fails, | 32 // Converts |str| to a base::Value of the given |type|. If the conversion fails, |
31 // returns NULL. | 33 // returns NULL. |
32 scoped_ptr<base::Value> ConvertStringToValue(const std::string& str, | 34 scoped_ptr<base::Value> ConvertStringToValue(const std::string& str, |
33 base::Value::Type type) { | 35 base::Value::Type type) { |
34 scoped_ptr<base::Value> value; | 36 scoped_ptr<base::Value> value; |
35 if (type == base::Value::TYPE_STRING) { | 37 if (type == base::Value::TYPE_STRING) { |
36 value.reset(new base::StringValue(str)); | 38 value.reset(new base::StringValue(str)); |
37 } else { | 39 } else { |
38 value = base::JSONReader::Read(str); | 40 value = base::JSONReader::Read(str); |
39 } | 41 } |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
322 bool save_credentials; | 324 bool save_credentials; |
323 if (onc_provider_type != ::onc::vpn::kThirdPartyVpn && | 325 if (onc_provider_type != ::onc::vpn::kThirdPartyVpn && |
324 shill_dictionary_->GetBooleanWithoutPathExpansion( | 326 shill_dictionary_->GetBooleanWithoutPathExpansion( |
325 shill::kSaveCredentialsProperty, &save_credentials)) { | 327 shill::kSaveCredentialsProperty, &save_credentials)) { |
326 SetNestedOncValue(provider_type_dictionary, ::onc::vpn::kSaveCredentials, | 328 SetNestedOncValue(provider_type_dictionary, ::onc::vpn::kSaveCredentials, |
327 base::FundamentalValue(save_credentials)); | 329 base::FundamentalValue(save_credentials)); |
328 } | 330 } |
329 } | 331 } |
330 | 332 |
331 void ShillToONCTranslator::TranslateWiFiWithState() { | 333 void ShillToONCTranslator::TranslateWiFiWithState() { |
332 TranslateWithTableAndSet(shill::kSecurityClassProperty, kWiFiSecurityTable, | 334 std::string shill_security; |
333 ::onc::wifi::kSecurity); | 335 std::string shill_key_mgmt; |
336 if (shill_dictionary_->GetStringWithoutPathExpansion( | |
337 shill::kSecurityClassProperty, &shill_security) && | |
338 shill_security == shill::kSecurityWep && | |
339 shill_dictionary_->GetStringWithoutPathExpansion( | |
340 shill::kEapKeyMgmtProperty, &shill_key_mgmt) && | |
341 shill_key_mgmt == kKeyManagementIEEE8021X) { | |
342 onc_object_->SetStringWithoutPathExpansion(::onc::wifi::kSecurity, | |
343 ::onc::wifi::kWEP_8021X); | |
344 } else { | |
345 TranslateWithTableAndSet(shill::kSecurityClassProperty, kWiFiSecurityTable, | |
346 ::onc::wifi::kSecurity); | |
347 } | |
348 | |
334 bool unknown_encoding = true; | 349 bool unknown_encoding = true; |
335 std::string ssid = shill_property_util::GetSSIDFromProperties( | 350 std::string ssid = shill_property_util::GetSSIDFromProperties( |
336 *shill_dictionary_, false /* verbose_logging */, &unknown_encoding); | 351 *shill_dictionary_, false /* verbose_logging */, &unknown_encoding); |
337 if (!unknown_encoding && !ssid.empty()) | 352 if (!unknown_encoding && !ssid.empty()) |
338 onc_object_->SetStringWithoutPathExpansion(::onc::wifi::kSSID, ssid); | 353 onc_object_->SetStringWithoutPathExpansion(::onc::wifi::kSSID, ssid); |
339 | 354 |
340 bool link_monitor_disable; | 355 bool link_monitor_disable; |
341 if (shill_dictionary_->GetBooleanWithoutPathExpansion( | 356 if (shill_dictionary_->GetBooleanWithoutPathExpansion( |
342 shill::kLinkMonitorDisableProperty, &link_monitor_disable)) { | 357 shill::kLinkMonitorDisableProperty, &link_monitor_disable)) { |
343 onc_object_->SetBooleanWithoutPathExpansion( | 358 onc_object_->SetBooleanWithoutPathExpansion( |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
765 const NetworkState* network_state) { | 780 const NetworkState* network_state) { |
766 CHECK(onc_signature != NULL); | 781 CHECK(onc_signature != NULL); |
767 | 782 |
768 ShillToONCTranslator translator(shill_dictionary, onc_source, *onc_signature, | 783 ShillToONCTranslator translator(shill_dictionary, onc_source, *onc_signature, |
769 network_state); | 784 network_state); |
770 return translator.CreateTranslatedONCObject(); | 785 return translator.CreateTranslatedONCObject(); |
771 } | 786 } |
772 | 787 |
773 } // namespace onc | 788 } // namespace onc |
774 } // namespace chromeos | 789 } // namespace chromeos |
OLD | NEW |