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

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

Issue 1549643002: Switch to standard integer types in extensions/browser/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@clean
Patch Set: Created 5 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
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 "extensions/browser/api/networking_private/networking_private_linux.h" 5 #include "extensions/browser/api/networking_private/networking_private_linux.h"
6 6
7 #include <stddef.h>
8
7 #include "base/bind.h" 9 #include "base/bind.h"
8 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
9 #include "base/callback.h" 11 #include "base/callback.h"
10 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
11 #include "base/strings/string16.h" 13 #include "base/strings/string16.h"
12 #include "base/strings/string_split.h" 14 #include "base/strings/string_split.h"
13 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
14 #include "base/threading/sequenced_worker_pool.h" 16 #include "base/threading/sequenced_worker_pool.h"
15 #include "components/onc/onc_constants.h" 17 #include "components/onc/onc_constants.h"
16 #include "content/public/browser/browser_context.h" 18 #include "content/public/browser/browser_context.h"
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 dict_writer.OpenArray("{sv}", &wifi_array); 383 dict_writer.OpenArray("{sv}", &wifi_array);
382 384
383 dbus::MessageWriter wifi_dict_writer(&method_call); 385 dbus::MessageWriter wifi_dict_writer(&method_call);
384 wifi_array.OpenDictEntry(&wifi_dict_writer); 386 wifi_array.OpenDictEntry(&wifi_dict_writer);
385 wifi_dict_writer.AppendString( 387 wifi_dict_writer.AppendString(
386 networking_private::kNetworkManagerConnectionConfigSsid); 388 networking_private::kNetworkManagerConnectionConfigSsid);
387 389
388 dbus::MessageWriter variant_writer(&method_call); 390 dbus::MessageWriter variant_writer(&method_call);
389 wifi_dict_writer.OpenVariant("ay", &variant_writer); 391 wifi_dict_writer.OpenVariant("ay", &variant_writer);
390 variant_writer.AppendArrayOfBytes( 392 variant_writer.AppendArrayOfBytes(
391 reinterpret_cast<const uint8*>(ssid.c_str()), ssid.size()); 393 reinterpret_cast<const uint8_t*>(ssid.c_str()), ssid.size());
392 394
393 // Close all the arrays and dicts. 395 // Close all the arrays and dicts.
394 wifi_dict_writer.CloseContainer(&variant_writer); 396 wifi_dict_writer.CloseContainer(&variant_writer);
395 wifi_array.CloseContainer(&wifi_dict_writer); 397 wifi_array.CloseContainer(&wifi_dict_writer);
396 dict_writer.CloseContainer(&wifi_array); 398 dict_writer.CloseContainer(&wifi_array);
397 array_writer.CloseContainer(&dict_writer); 399 array_writer.CloseContainer(&dict_writer);
398 builder.CloseContainer(&array_writer); 400 builder.CloseContainer(&array_writer);
399 401
400 builder.AppendObjectPath(device_path); 402 builder.AppendObjectPath(device_path);
401 builder.AppendObjectPath(access_point_path); 403 builder.AppendObjectPath(access_point_path);
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 scoped_ptr<dbus::Response> response(device_proxy->CallMethodAndBlock( 687 scoped_ptr<dbus::Response> response(device_proxy->CallMethodAndBlock(
686 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT)); 688 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT));
687 689
688 if (!response) { 690 if (!response) {
689 LOG(ERROR) << "Failed to get the device type for device " 691 LOG(ERROR) << "Failed to get the device type for device "
690 << device_path.value(); 692 << device_path.value();
691 return NetworkingPrivateLinux::NM_DEVICE_TYPE_UNKNOWN; 693 return NetworkingPrivateLinux::NM_DEVICE_TYPE_UNKNOWN;
692 } 694 }
693 695
694 dbus::MessageReader reader(response.get()); 696 dbus::MessageReader reader(response.get());
695 uint32 device_type = 0; 697 uint32_t device_type = 0;
696 if (!reader.PopVariantOfUint32(&device_type)) { 698 if (!reader.PopVariantOfUint32(&device_type)) {
697 LOG(ERROR) << "Unexpected response for device " << device_type << ": " 699 LOG(ERROR) << "Unexpected response for device " << device_type << ": "
698 << response->ToString(); 700 << response->ToString();
699 return NM_DEVICE_TYPE_UNKNOWN; 701 return NM_DEVICE_TYPE_UNKNOWN;
700 } 702 }
701 703
702 return static_cast<NetworkingPrivateLinux::DeviceType>(device_type); 704 return static_cast<NetworkingPrivateLinux::DeviceType>(device_type);
703 } 705 }
704 706
705 void NetworkingPrivateLinux::GetAllWiFiAccessPoints(bool configured_only, 707 void NetworkingPrivateLinux::GetAllWiFiAccessPoints(bool configured_only,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 768
767 // The response should contain a variant that contains an array of bytes. 769 // The response should contain a variant that contains an array of bytes.
768 dbus::MessageReader reader(response.get()); 770 dbus::MessageReader reader(response.get());
769 dbus::MessageReader variant_reader(response.get()); 771 dbus::MessageReader variant_reader(response.get());
770 if (!reader.PopVariant(&variant_reader)) { 772 if (!reader.PopVariant(&variant_reader)) {
771 LOG(ERROR) << "Unexpected response for " << access_point_path.value() 773 LOG(ERROR) << "Unexpected response for " << access_point_path.value()
772 << ": " << response->ToString(); 774 << ": " << response->ToString();
773 return false; 775 return false;
774 } 776 }
775 777
776 const uint8* ssid_bytes = NULL; 778 const uint8_t* ssid_bytes = NULL;
777 size_t ssid_length = 0; 779 size_t ssid_length = 0;
778 if (!variant_reader.PopArrayOfBytes(&ssid_bytes, &ssid_length)) { 780 if (!variant_reader.PopArrayOfBytes(&ssid_bytes, &ssid_length)) {
779 LOG(ERROR) << "Unexpected response for " << access_point_path.value() 781 LOG(ERROR) << "Unexpected response for " << access_point_path.value()
780 << ": " << response->ToString(); 782 << ": " << response->ToString();
781 return false; 783 return false;
782 } 784 }
783 785
784 std::string ssidUTF8(ssid_bytes, ssid_bytes + ssid_length); 786 std::string ssidUTF8(ssid_bytes, ssid_bytes + ssid_length);
785 base::string16 ssid = base::UTF8ToUTF16(ssidUTF8); 787 base::string16 ssid = base::UTF8ToUTF16(ssidUTF8);
786 788
787 access_point_info->SetString(kAccessPointInfoName, ssid); 789 access_point_info->SetString(kAccessPointInfoName, ssid);
788 } 790 }
789 791
790 // Read signal strength. 792 // Read signal strength.
791 { 793 {
792 scoped_ptr<dbus::Response> response(GetAccessPointProperty( 794 scoped_ptr<dbus::Response> response(GetAccessPointProperty(
793 access_point_proxy, 795 access_point_proxy,
794 networking_private::kNetworkManagerStrengthProperty)); 796 networking_private::kNetworkManagerStrengthProperty));
795 if (!response) { 797 if (!response) {
796 return false; 798 return false;
797 } 799 }
798 800
799 dbus::MessageReader reader(response.get()); 801 dbus::MessageReader reader(response.get());
800 uint8 strength = 0; 802 uint8_t strength = 0;
801 if (!reader.PopVariantOfByte(&strength)) { 803 if (!reader.PopVariantOfByte(&strength)) {
802 LOG(ERROR) << "Unexpected response for " << access_point_path.value() 804 LOG(ERROR) << "Unexpected response for " << access_point_path.value()
803 << ": " << response->ToString(); 805 << ": " << response->ToString();
804 return false; 806 return false;
805 } 807 }
806 808
807 access_point_info->SetInteger(kAccessPointInfoWifiSignalStrengthDotted, 809 access_point_info->SetInteger(kAccessPointInfoWifiSignalStrengthDotted,
808 strength); 810 strength);
809 } 811 }
810 812
811 // Read the security type. This is from the WpaFlags and RsnFlags property 813 // Read the security type. This is from the WpaFlags and RsnFlags property
812 // which are of the same type and can be OR'd together to find all supported 814 // which are of the same type and can be OR'd together to find all supported
813 // security modes. 815 // security modes.
814 816
815 uint32 wpa_security_flags = 0; 817 uint32_t wpa_security_flags = 0;
816 { 818 {
817 scoped_ptr<dbus::Response> response(GetAccessPointProperty( 819 scoped_ptr<dbus::Response> response(GetAccessPointProperty(
818 access_point_proxy, 820 access_point_proxy,
819 networking_private::kNetworkManagerWpaFlagsProperty)); 821 networking_private::kNetworkManagerWpaFlagsProperty));
820 if (!response) { 822 if (!response) {
821 return false; 823 return false;
822 } 824 }
823 825
824 dbus::MessageReader reader(response.get()); 826 dbus::MessageReader reader(response.get());
825 827
826 if (!reader.PopVariantOfUint32(&wpa_security_flags)) { 828 if (!reader.PopVariantOfUint32(&wpa_security_flags)) {
827 LOG(ERROR) << "Unexpected response for " << access_point_path.value() 829 LOG(ERROR) << "Unexpected response for " << access_point_path.value()
828 << ": " << response->ToString(); 830 << ": " << response->ToString();
829 return false; 831 return false;
830 } 832 }
831 } 833 }
832 834
833 uint32 rsn_security_flags = 0; 835 uint32_t rsn_security_flags = 0;
834 { 836 {
835 scoped_ptr<dbus::Response> response(GetAccessPointProperty( 837 scoped_ptr<dbus::Response> response(GetAccessPointProperty(
836 access_point_proxy, 838 access_point_proxy,
837 networking_private::kNetworkManagerRsnFlagsProperty)); 839 networking_private::kNetworkManagerRsnFlagsProperty));
838 if (!response) { 840 if (!response) {
839 return false; 841 return false;
840 } 842 }
841 843
842 dbus::MessageReader reader(response.get()); 844 dbus::MessageReader reader(response.get());
843 845
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 signal_strength > existing_signal_strength)) { 956 signal_strength > existing_signal_strength)) {
955 existing_access_point->SetString(kAccessPointInfoConnectionState, 957 existing_access_point->SetString(kAccessPointInfoConnectionState,
956 connection_state); 958 connection_state);
957 existing_access_point->SetInteger( 959 existing_access_point->SetInteger(
958 kAccessPointInfoWifiSignalStrengthDotted, signal_strength); 960 kAccessPointInfoWifiSignalStrengthDotted, signal_strength);
959 existing_access_point->SetString(kAccessPointInfoGuid, network_guid); 961 existing_access_point->SetString(kAccessPointInfoGuid, network_guid);
960 } 962 }
961 } 963 }
962 } 964 }
963 965
964 void NetworkingPrivateLinux::MapSecurityFlagsToString(uint32 security_flags, 966 void NetworkingPrivateLinux::MapSecurityFlagsToString(uint32_t security_flags,
965 std::string* security) { 967 std::string* security) {
966 // Valid values are None, WEP-PSK, WEP-8021X, WPA-PSK, WPA-EAP 968 // Valid values are None, WEP-PSK, WEP-8021X, WPA-PSK, WPA-EAP
967 if (security_flags == NetworkingPrivateLinux::NM_802_11_AP_SEC_NONE) { 969 if (security_flags == NetworkingPrivateLinux::NM_802_11_AP_SEC_NONE) {
968 *security = kAccessPointSecurityNone; 970 *security = kAccessPointSecurityNone;
969 } else if (security_flags & 971 } else if (security_flags &
970 NetworkingPrivateLinux::NM_802_11_AP_SEC_KEY_MGMT_PSK) { 972 NetworkingPrivateLinux::NM_802_11_AP_SEC_KEY_MGMT_PSK) {
971 *security = kAccessPointSecurityWpaPsk; 973 *security = kAccessPointSecurityWpaPsk;
972 } else if (security_flags & 974 } else if (security_flags &
973 NetworkingPrivateLinux::NM_802_11_AP_SEC_KEY_MGMT_802_1X) { 975 NetworkingPrivateLinux::NM_802_11_AP_SEC_KEY_MGMT_802_1X) {
974 *security = kAccessPointSecurity9021X; 976 *security = kAccessPointSecurity9021X;
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
1196 base::Unretained(this), base::Passed(&guid_list))); 1198 base::Unretained(this), base::Passed(&guid_list)));
1197 } 1199 }
1198 1200
1199 void NetworkingPrivateLinux::OnNetworksChangedEventTask( 1201 void NetworkingPrivateLinux::OnNetworksChangedEventTask(
1200 scoped_ptr<GuidList> guid_list) { 1202 scoped_ptr<GuidList> guid_list) {
1201 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 1203 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
1202 OnNetworksChangedEventOnUIThread(*guid_list); 1204 OnNetworksChangedEventOnUIThread(*guid_list);
1203 } 1205 }
1204 1206
1205 } // namespace extensions 1207 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698