#include "extensions/browser/api/networking_private/networking_private_linux.h"
#include <stddef.h>
#include <memory>
#include <string>
#include <utility>
#include "base/containers/span.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/scoped_refptr.h"
#include "base/observer_list.h"
#include "base/strings/string_split.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "components/onc/onc_constants.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "dbus/bus.h"
#include "dbus/message.h"
#include "dbus/object_path.h"
#include "dbus/object_proxy.h"
#include "extensions/browser/api/networking_private/network_config_dbus_constants_linux.h"
#include "extensions/browser/api/networking_private/networking_private_api.h"
#include "extensions/browser/api/networking_private/networking_private_delegate_observer.h"
namespace extensions {
namespace {
const char kAccessPointInfoName[] = …;
const char kAccessPointInfoGuid[] = …;
const char kAccessPointInfoConnectable[] = …;
const char kAccessPointInfoConnectionState[] = …;
const char kAccessPointInfoType[] = …;
const char kAccessPointInfoTypeWifi[] = …;
const char kAccessPointInfoWifiSignalStrengthDotted[] = …;
const char kAccessPointInfoWifiSecurityDotted[] = …;
const char kAccessPointSecurityNone[] = …;
const char kAccessPointSecurityUnknown[] = …;
const char kAccessPointSecurityWpaPsk[] = …;
const char kAccessPointSecurity9021X[] = …;
bool ParseNetworkGuid(const std::string& guid,
std::string* device_path,
std::string* access_point_path,
std::string* ssid) { … }
bool GuidToSsid(const std::string& guid, std::string* ssid) { … }
base::Value::List CopyNetworkMapToList(
const NetworkingPrivateLinux::NetworkMap& network_map) { … }
std::string ConstructNetworkGuid(const dbus::ObjectPath& device_path,
const dbus::ObjectPath& access_point_path,
const std::string& ssid) { … }
void ReportNotSupported(
const std::string& method_name,
NetworkingPrivateDelegate::FailureCallback failure_callback) { … }
void OnNetworkConnectOperationCompleted(
std::unique_ptr<std::string> error,
NetworkingPrivateDelegate::VoidCallback success_callback,
NetworkingPrivateDelegate::FailureCallback failure_callback) { … }
void GetCachedNetworkPropertiesCallback(
std::unique_ptr<std::string> error,
std::unique_ptr<base::Value::Dict> properties,
NetworkingPrivateDelegate::DictionaryCallback success_callback,
NetworkingPrivateDelegate::FailureCallback failure_callback) { … }
void GetCachedNetworkPropertiesResultCallback(
std::unique_ptr<std::string> error,
std::unique_ptr<base::Value::Dict> properties,
NetworkingPrivateDelegate::PropertiesCallback callback) { … }
}
NetworkingPrivateLinux::NetworkingPrivateLinux()
: … { … }
NetworkingPrivateLinux::~NetworkingPrivateLinux() { … }
void NetworkingPrivateLinux::AssertOnDBusThread() { … }
void NetworkingPrivateLinux::Initialize() { … }
bool NetworkingPrivateLinux::CheckNetworkManagerSupported() { … }
void NetworkingPrivateLinux::GetProperties(const std::string& guid,
PropertiesCallback callback) { … }
void NetworkingPrivateLinux::GetManagedProperties(const std::string& guid,
PropertiesCallback callback) { … }
void NetworkingPrivateLinux::GetState(const std::string& guid,
DictionaryCallback success_callback,
FailureCallback failure_callback) { … }
void NetworkingPrivateLinux::GetCachedNetworkProperties(
const std::string& guid,
base::Value::Dict* properties,
std::string* error) { … }
void NetworkingPrivateLinux::SetProperties(const std::string& guid,
base::Value::Dict properties,
bool allow_set_shared_config,
VoidCallback success_callback,
FailureCallback failure_callback) { … }
void NetworkingPrivateLinux::CreateNetwork(bool shared,
base::Value::Dict properties,
StringCallback success_callback,
FailureCallback failure_callback) { … }
void NetworkingPrivateLinux::ForgetNetwork(const std::string& guid,
bool allow_forget_shared_config,
VoidCallback success_callback,
FailureCallback failure_callback) { … }
void NetworkingPrivateLinux::GetNetworks(const std::string& network_type,
bool configured_only,
bool visible_only,
int limit,
NetworkListCallback success_callback,
FailureCallback failure_callback) { … }
bool NetworkingPrivateLinux::GetNetworksForScanRequest() { … }
void NetworkingPrivateLinux::ConnectToNetwork(const std::string& guid,
std::string* error) { … }
void NetworkingPrivateLinux::DisconnectFromNetwork(const std::string& guid,
std::string* error) { … }
void NetworkingPrivateLinux::StartConnect(const std::string& guid,
VoidCallback success_callback,
FailureCallback failure_callback) { … }
void NetworkingPrivateLinux::StartDisconnect(const std::string& guid,
VoidCallback success_callback,
FailureCallback failure_callback) { … }
void NetworkingPrivateLinux::GetCaptivePortalStatus(
const std::string& guid,
StringCallback success_callback,
FailureCallback failure_callback) { … }
void NetworkingPrivateLinux::UnlockCellularSim(
const std::string& guid,
const std::string& pin,
const std::string& puk,
VoidCallback success_callback,
FailureCallback failure_callback) { … }
void NetworkingPrivateLinux::SetCellularSimState(
const std::string& guid,
bool require_pin,
const std::string& current_pin,
const std::string& new_pin,
VoidCallback success_callback,
FailureCallback failure_callback) { … }
void NetworkingPrivateLinux::SelectCellularMobileNetwork(
const std::string& guid,
const std::string& network_id,
VoidCallback success_callback,
FailureCallback failure_callback) { … }
void NetworkingPrivateLinux::GetEnabledNetworkTypes(
EnabledNetworkTypesCallback callback) { … }
void NetworkingPrivateLinux::GetDeviceStateList(
DeviceStateListCallback callback) { … }
void NetworkingPrivateLinux::GetGlobalPolicy(GetGlobalPolicyCallback callback) { … }
void NetworkingPrivateLinux ::GetCertificateLists(
GetCertificateListsCallback callback) { … }
void NetworkingPrivateLinux::EnableNetworkType(const std::string& type,
BoolCallback callback) { … }
void NetworkingPrivateLinux::DisableNetworkType(const std::string& type,
BoolCallback callback) { … }
void NetworkingPrivateLinux::RequestScan(const std::string& ,
BoolCallback callback) { … }
void NetworkingPrivateLinux::AddObserver(
NetworkingPrivateDelegateObserver* observer) { … }
void NetworkingPrivateLinux::RemoveObserver(
NetworkingPrivateDelegateObserver* observer) { … }
void NetworkingPrivateLinux::OnAccessPointsFound(
std::unique_ptr<NetworkMap> network_map,
NetworkListCallback success_callback,
FailureCallback failure_callback) { … }
void NetworkingPrivateLinux::OnAccessPointsFoundViaScan(
std::unique_ptr<NetworkMap> network_map) { … }
void NetworkingPrivateLinux::SendNetworkListChangedEvent(
const base::Value::List& network_list) { … }
bool NetworkingPrivateLinux::GetNetworkDevices(
std::vector<dbus::ObjectPath>* device_paths) { … }
NetworkingPrivateLinux::DeviceType NetworkingPrivateLinux::GetDeviceType(
const dbus::ObjectPath& device_path) { … }
void NetworkingPrivateLinux::GetAllWiFiAccessPoints(bool configured_only,
bool visible_only,
int limit,
NetworkMap* network_map) { … }
std::unique_ptr<dbus::Response> NetworkingPrivateLinux::GetAccessPointProperty(
dbus::ObjectProxy* access_point_proxy,
const std::string& property_name) { … }
bool NetworkingPrivateLinux::GetAccessPointInfo(
const dbus::ObjectPath& access_point_path,
base::Value::Dict* access_point_info) { … }
bool NetworkingPrivateLinux::AddAccessPointsFromDevice(
const dbus::ObjectPath& device_path,
NetworkMap* network_map) { … }
void NetworkingPrivateLinux::AddOrUpdateAccessPoint(
NetworkMap* network_map,
const std::string& network_guid,
base::Value::Dict* access_point) { … }
void NetworkingPrivateLinux::MapSecurityFlagsToString(uint32_t security_flags,
std::string* security) { … }
bool NetworkingPrivateLinux::GetConnectedAccessPoint(
const dbus::ObjectPath& device_path,
dbus::ObjectPath* access_point_path) { … }
bool NetworkingPrivateLinux::GetDeviceOfConnection(
dbus::ObjectPath connection_path,
dbus::ObjectPath* device_path) { … }
bool NetworkingPrivateLinux::GetAccessPointForConnection(
dbus::ObjectPath connection_path,
dbus::ObjectPath* access_point_path) { … }
bool NetworkingPrivateLinux::SetConnectionStateAndPostEvent(
const std::string& guid,
const std::string& ssid,
const std::string& connection_state) { … }
void NetworkingPrivateLinux::OnNetworksChangedEventOnUIThread(
const GuidList& network_guids) { … }
void NetworkingPrivateLinux::OnNetworkListChangedEventOnUIThread(
const GuidList& network_guids) { … }
void NetworkingPrivateLinux::PostOnNetworksChangedToUIThread(
std::unique_ptr<GuidList> guid_list) { … }
void NetworkingPrivateLinux::OnNetworksChangedEventTask(
std::unique_ptr<GuidList> guid_list) { … }
}