#ifndef CHROMEOS_ASH_COMPONENTS_NETWORK_GEOLOCATION_HANDLER_IMPL_H_
#define CHROMEOS_ASH_COMPONENTS_NETWORK_GEOLOCATION_HANDLER_IMPL_H_
#include <stdint.h>
#include <optional>
#include "base/memory/weak_ptr.h"
#include "base/time/time.h"
#include "base/values.h"
#include "chromeos/ash/components/dbus/shill/shill_property_changed_observer.h"
#include "chromeos/ash/components/network/geolocation_handler.h"
#include "chromeos/ash/components/network/network_handler.h"
#include "chromeos/ash/components/network/network_util.h"
namespace ash {
class COMPONENT_EXPORT(CHROMEOS_NETWORK) GeolocationHandlerImpl
: public GeolocationHandler,
public ShillPropertyChangedObserver {
public:
GeolocationHandlerImpl(const GeolocationHandlerImpl&) = delete;
GeolocationHandlerImpl& operator=(const GeolocationHandlerImpl&) = delete;
~GeolocationHandlerImpl() override;
bool GetNetworkInformation(WifiAccessPointVector* access_points,
CellTowerVector* cell_towers) override;
bool GetWifiAccessPoints(WifiAccessPointVector* access_points,
int64_t* age_ms) override;
bool wifi_enabled() const override;
void OnPropertyChanged(const std::string& key,
const base::Value& value) override;
private:
friend class NetworkHandler;
friend class GeolocationHandlerImplTest;
friend class SystemLocationProviderWirelessTest;
GeolocationHandlerImpl();
void Init();
void ManagerPropertiesCallback(std::optional<base::Value::Dict> properties);
void HandlePropertyChanged(const std::string& key, const base::Value& value);
void RequestGeolocationObjects();
void GeolocationCallback(std::optional<base::Value::Dict> properties);
bool cellular_enabled_ = false;
bool wifi_enabled_ = false;
void AddCellTowerFromDict(const base::Value::Dict& entry);
void AddAccessPointFromDict(const base::Value::Dict& entry);
WifiAccessPointVector wifi_access_points_;
CellTowerVector cell_towers_;
base::Time geolocation_received_time_;
base::WeakPtrFactory<GeolocationHandlerImpl> weak_ptr_factory_{this};
};
}
#endif