Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(580)

Side by Side Diff: chromeos/network/onc/onc_translator_shill_to_onc.cc

Issue 1412283006: Translate 802.1x WEP ("Enterprise WEP") (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added TODOs Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 // TODO(pstew): Remove once crosreview.com/310644 lands and merges to Chrome.
31 const char kKeyManagementIEEE8021X[] = "IEEE8021X";
32
30 // Converts |str| to a base::Value of the given |type|. If the conversion fails, 33 // Converts |str| to a base::Value of the given |type|. If the conversion fails,
31 // returns NULL. 34 // returns NULL.
32 scoped_ptr<base::Value> ConvertStringToValue(const std::string& str, 35 scoped_ptr<base::Value> ConvertStringToValue(const std::string& str,
33 base::Value::Type type) { 36 base::Value::Type type) {
34 scoped_ptr<base::Value> value; 37 scoped_ptr<base::Value> value;
35 if (type == base::Value::TYPE_STRING) { 38 if (type == base::Value::TYPE_STRING) {
36 value.reset(new base::StringValue(str)); 39 value.reset(new base::StringValue(str));
37 } else { 40 } else {
38 value = base::JSONReader::Read(str); 41 value = base::JSONReader::Read(str);
39 } 42 }
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 bool save_credentials; 325 bool save_credentials;
323 if (onc_provider_type != ::onc::vpn::kThirdPartyVpn && 326 if (onc_provider_type != ::onc::vpn::kThirdPartyVpn &&
324 shill_dictionary_->GetBooleanWithoutPathExpansion( 327 shill_dictionary_->GetBooleanWithoutPathExpansion(
325 shill::kSaveCredentialsProperty, &save_credentials)) { 328 shill::kSaveCredentialsProperty, &save_credentials)) {
326 SetNestedOncValue(provider_type_dictionary, ::onc::vpn::kSaveCredentials, 329 SetNestedOncValue(provider_type_dictionary, ::onc::vpn::kSaveCredentials,
327 base::FundamentalValue(save_credentials)); 330 base::FundamentalValue(save_credentials));
328 } 331 }
329 } 332 }
330 333
331 void ShillToONCTranslator::TranslateWiFiWithState() { 334 void ShillToONCTranslator::TranslateWiFiWithState() {
332 TranslateWithTableAndSet(shill::kSecurityClassProperty, kWiFiSecurityTable, 335 std::string shill_security;
333 ::onc::wifi::kSecurity); 336 std::string shill_key_mgmt;
337 if (shill_dictionary_->GetStringWithoutPathExpansion(
338 shill::kSecurityClassProperty, &shill_security) &&
339 shill_security == shill::kSecurityWep &&
340 shill_dictionary_->GetStringWithoutPathExpansion(
341 shill::kEapKeyMgmtProperty, &shill_key_mgmt) &&
342 shill_key_mgmt == kKeyManagementIEEE8021X) {
343 onc_object_->SetStringWithoutPathExpansion(::onc::wifi::kSecurity,
344 ::onc::wifi::kWEP_8021X);
345 } else {
346 TranslateWithTableAndSet(shill::kSecurityClassProperty, kWiFiSecurityTable,
347 ::onc::wifi::kSecurity);
348 }
349
334 bool unknown_encoding = true; 350 bool unknown_encoding = true;
335 std::string ssid = shill_property_util::GetSSIDFromProperties( 351 std::string ssid = shill_property_util::GetSSIDFromProperties(
336 *shill_dictionary_, false /* verbose_logging */, &unknown_encoding); 352 *shill_dictionary_, false /* verbose_logging */, &unknown_encoding);
337 if (!unknown_encoding && !ssid.empty()) 353 if (!unknown_encoding && !ssid.empty())
338 onc_object_->SetStringWithoutPathExpansion(::onc::wifi::kSSID, ssid); 354 onc_object_->SetStringWithoutPathExpansion(::onc::wifi::kSSID, ssid);
339 355
340 bool link_monitor_disable; 356 bool link_monitor_disable;
341 if (shill_dictionary_->GetBooleanWithoutPathExpansion( 357 if (shill_dictionary_->GetBooleanWithoutPathExpansion(
342 shill::kLinkMonitorDisableProperty, &link_monitor_disable)) { 358 shill::kLinkMonitorDisableProperty, &link_monitor_disable)) {
343 onc_object_->SetBooleanWithoutPathExpansion( 359 onc_object_->SetBooleanWithoutPathExpansion(
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 const NetworkState* network_state) { 781 const NetworkState* network_state) {
766 CHECK(onc_signature != NULL); 782 CHECK(onc_signature != NULL);
767 783
768 ShillToONCTranslator translator(shill_dictionary, onc_source, *onc_signature, 784 ShillToONCTranslator translator(shill_dictionary, onc_source, *onc_signature,
769 network_state); 785 network_state);
770 return translator.CreateTranslatedONCObject(); 786 return translator.CreateTranslatedONCObject();
771 } 787 }
772 788
773 } // namespace onc 789 } // namespace onc
774 } // namespace chromeos 790 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/onc/onc_translator_onc_to_shill.cc ('k') | chromeos/network/onc/onc_translator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698