#ifndef SERVICES_DEVICE_GEOLOCATION_GEOLOCATION_IMPL_H_
#define SERVICES_DEVICE_GEOLOCATION_GEOLOCATION_IMPL_H_
#include "base/memory/raw_ptr.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "services/device/geolocation/geolocation_provider_impl.h"
#include "services/device/public/mojom/geolocation.mojom.h"
#include "services/device/public/mojom/geolocation_client_id.mojom.h"
#include "services/device/public/mojom/geolocation_context.mojom.h"
#include "url/gurl.h"
namespace device {
class GeolocationProvider;
class GeolocationContext;
class GeolocationImpl : public mojom::Geolocation {
public:
GeolocationImpl(mojo::PendingReceiver<mojom::Geolocation> receiver,
const GURL& requesting_url,
mojom::GeolocationClientId client_id,
GeolocationContext* context,
bool has_precise_permission);
GeolocationImpl(const GeolocationImpl&) = delete;
GeolocationImpl& operator=(const GeolocationImpl&) = delete;
~GeolocationImpl() override;
void StartListeningForUpdates();
void PauseUpdates();
void ResumeUpdates();
void SetOverride(const mojom::GeopositionResult& result);
void ClearOverride();
void OnPermissionUpdated(mojom::GeolocationPermissionLevel permission_level);
const GURL& url() { return url_; }
private:
void SetHighAccuracyHint(bool high_accuracy) override;
void QueryNextPosition(QueryNextPositionCallback callback) override;
void OnConnectionError();
void OnLocationUpdate(const mojom::GeopositionResult& result);
void ReportCurrentPosition();
mojo::Receiver<mojom::Geolocation> receiver_;
const GURL url_;
const mojom::GeolocationClientId client_id_;
raw_ptr<GeolocationContext> context_;
base::CallbackListSubscription geolocation_subscription_;
QueryNextPositionCallback position_callback_;
mojom::GeopositionResultPtr position_override_;
mojom::GeopositionResultPtr current_result_;
bool high_accuracy_hint_;
std::optional<bool> effective_high_accuracy_;
bool has_precise_permission_;
};
}
#endif