geolocation_context.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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
  3. // found in the LICENSE file.
  4. #ifndef SERVICES_DEVICE_GEOLOCATION_GEOLOCATION_CONTEXT_H_
  5. #define SERVICES_DEVICE_GEOLOCATION_GEOLOCATION_CONTEXT_H_
  6. #include <memory>
  7. #include <vector>
  8. #include "mojo/public/cpp/bindings/pending_receiver.h"
  9. #include "services/device/public/mojom/geolocation.mojom.h"
  10. #include "services/device/public/mojom/geolocation_context.mojom.h"
  11. #include "services/device/public/mojom/geoposition.mojom.h"
  12. namespace device {
  13. class GeolocationImpl;
  14. // Provides information to a set of GeolocationImpl instances that are
  15. // associated with a given context. Notably, allows pausing and resuming
  16. // geolocation on these instances.
  17. class GeolocationContext : public mojom::GeolocationContext {
  18. public:
  19. GeolocationContext();
  20. GeolocationContext(const GeolocationContext&) = delete;
  21. GeolocationContext& operator=(const GeolocationContext&) = delete;
  22. ~GeolocationContext() override;
  23. // Creates GeolocationContext that is strongly bound to |receiver|.
  24. static void Create(mojo::PendingReceiver<mojom::GeolocationContext> receiver);
  25. // mojom::GeolocationContext implementation:
  26. void BindGeolocation(mojo::PendingReceiver<mojom::Geolocation> receiver,
  27. const GURL& requesting_origin) override;
  28. void SetOverride(mojom::GeopositionPtr geoposition) override;
  29. void ClearOverride() override;
  30. // Called when a GeolocationImpl has a connection error. After this call, it
  31. // is no longer safe to access |impl|.
  32. void OnConnectionError(GeolocationImpl* impl);
  33. private:
  34. std::vector<std::unique_ptr<GeolocationImpl>> impls_;
  35. mojom::GeopositionPtr geoposition_override_;
  36. };
  37. } // namespace device
  38. #endif // SERVICES_DEVICE_GEOLOCATION_GEOLOCATION_CONTEXT_H_