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

Side by Side Diff: chrome/browser/extensions/api/networking_private/networking_private_linux.cc

Issue 779053002: Support checking RsnFlags as well as WpaFlags so that security type is reported correctly for all n… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add blank line after comment Created 6 years 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
« no previous file with comments | « chrome/browser/extensions/api/networking_private/network_config_dbus_constants_linux.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/extensions/api/networking_private/networking_private_li nux.h" 5 #include "chrome/browser/extensions/api/networking_private/networking_private_li nux.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 if (!reader.PopVariantOfByte(&strength)) { 573 if (!reader.PopVariantOfByte(&strength)) {
574 LOG(ERROR) << "Unexpected response for " << access_point_path.value() 574 LOG(ERROR) << "Unexpected response for " << access_point_path.value()
575 << ": " << response->ToString(); 575 << ": " << response->ToString();
576 return false; 576 return false;
577 } 577 }
578 578
579 access_point_info->SetInteger(kAccessPointInfoWifiSignalStrengthDotted, 579 access_point_info->SetInteger(kAccessPointInfoWifiSignalStrengthDotted,
580 strength); 580 strength);
581 } 581 }
582 582
583 // Read the security type. 583 // Read the security type. This is from the WpaFlags and RsnFlags property
584 // which are of the same type and can be OR'd together to find all supported
585 // security modes.
586
587 uint32 wpa_security_flags = 0;
584 { 588 {
585 scoped_ptr<dbus::Response> response(GetAccessPointProperty( 589 scoped_ptr<dbus::Response> response(GetAccessPointProperty(
586 access_point_proxy, 590 access_point_proxy,
587 networking_private::kNetworkManagerWpaFlagsProperty)); 591 networking_private::kNetworkManagerWpaFlagsProperty));
588 if (!response) { 592 if (!response) {
589 return false; 593 return false;
590 } 594 }
591 595
592 dbus::MessageReader reader(response.get()); 596 dbus::MessageReader reader(response.get());
593 uint32 security_flags = 0; 597
594 if (!reader.PopVariantOfUint32(&security_flags)) { 598 if (!reader.PopVariantOfUint32(&wpa_security_flags)) {
595 LOG(ERROR) << "Unexpected response for " << access_point_path.value() 599 LOG(ERROR) << "Unexpected response for " << access_point_path.value()
596 << ": " << response->ToString(); 600 << ": " << response->ToString();
597 return false; 601 return false;
598 } 602 }
599
600 std::string security;
601 MapSecurityFlagsToString(security_flags, &security);
602 access_point_info->SetString(kAccessPointInfoWifiSecurityDotted, security);
603 } 603 }
604 604
605 uint32 rsn_security_flags = 0;
606 {
607 scoped_ptr<dbus::Response> response(GetAccessPointProperty(
608 access_point_proxy,
609 networking_private::kNetworkManagerRsnFlagsProperty));
610 if (!response) {
611 return false;
612 }
613
614 dbus::MessageReader reader(response.get());
615
616 if (!reader.PopVariantOfUint32(&rsn_security_flags)) {
617 LOG(ERROR) << "Unexpected response for " << access_point_path.value()
618 << ": " << response->ToString();
619 return false;
620 }
621 }
622
623 std::string security;
624 MapSecurityFlagsToString(rsn_security_flags | wpa_security_flags, &security);
625 access_point_info->SetString(kAccessPointInfoWifiSecurityDotted, security);
605 access_point_info->SetString(kAccessPointInfoType, kAccessPointInfoTypeWifi); 626 access_point_info->SetString(kAccessPointInfoType, kAccessPointInfoTypeWifi);
606 access_point_info->SetBoolean(kAccessPointInfoConnectable, true); 627 access_point_info->SetBoolean(kAccessPointInfoConnectable, true);
607 return true; 628 return true;
608 } 629 }
609 630
610 bool NetworkingPrivateLinux::AddAccessPointsFromDevice( 631 bool NetworkingPrivateLinux::AddAccessPointsFromDevice(
611 const dbus::ObjectPath& device_path, 632 const dbus::ObjectPath& device_path,
612 NetworkMap* network_map) { 633 NetworkMap* network_map) {
613 AssertOnDBusThread(); 634 AssertOnDBusThread();
614 dbus::ObjectPath connected_access_point; 635 dbus::ObjectPath connected_access_point;
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 connection_state); 731 connection_state);
711 existing_access_point->SetInteger( 732 existing_access_point->SetInteger(
712 kAccessPointInfoWifiSignalStrengthDotted, signal_strength); 733 kAccessPointInfoWifiSignalStrengthDotted, signal_strength);
713 existing_access_point->SetString(kAccessPointInfoGuid, network_guid); 734 existing_access_point->SetString(kAccessPointInfoGuid, network_guid);
714 } 735 }
715 } 736 }
716 } 737 }
717 738
718 void NetworkingPrivateLinux::MapSecurityFlagsToString(uint32 security_flags, 739 void NetworkingPrivateLinux::MapSecurityFlagsToString(uint32 security_flags,
719 std::string* security) { 740 std::string* security) {
720 // TODO(zentaro): Correct mapping - this may not be correct but the underlying
721 // API appears not to work on Trusty so I can't verify yet.
722 // Everything returns 0.
723 // Valid values are None, WEP-PSK, WEP-8021X, WPA-PSK, WPA-EAP 741 // Valid values are None, WEP-PSK, WEP-8021X, WPA-PSK, WPA-EAP
724 if (security_flags == NetworkingPrivateLinux::NM_802_11_AP_SEC_NONE) { 742 if (security_flags == NetworkingPrivateLinux::NM_802_11_AP_SEC_NONE) {
725 *security = kAccessPointSecurityNone; 743 *security = kAccessPointSecurityNone;
726 } else if (security_flags & 744 } else if (security_flags &
727 NetworkingPrivateLinux::NM_802_11_AP_SEC_KEY_MGMT_PSK) { 745 NetworkingPrivateLinux::NM_802_11_AP_SEC_KEY_MGMT_PSK) {
728 *security = kAccessPointSecurityWpaPsk; 746 *security = kAccessPointSecurityWpaPsk;
729 } else if (security_flags & 747 } else if (security_flags &
730 NetworkingPrivateLinux::NM_802_11_AP_SEC_KEY_MGMT_802_1X) { 748 NetworkingPrivateLinux::NM_802_11_AP_SEC_KEY_MGMT_802_1X) {
731 *security = kAccessPointSecurity9021X; 749 *security = kAccessPointSecurity9021X;
732 } else { 750 } else {
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
874 892
875 if (!variant_reader.PopObjectPath(access_point_path)) { 893 if (!variant_reader.PopObjectPath(access_point_path)) {
876 LOG(ERROR) << "Unexpected response: " << response->ToString(); 894 LOG(ERROR) << "Unexpected response: " << response->ToString();
877 return false; 895 return false;
878 } 896 }
879 897
880 return true; 898 return true;
881 } 899 }
882 900
883 } // namespace extensions 901 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/networking_private/network_config_dbus_constants_linux.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698