tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

CoreLocationLocationProvider.h (2156B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #include "mozilla/Attributes.h"
      8 #include "nsCOMPtr.h"
      9 #include "nsIGeolocationProvider.h"
     10 
     11 /*
     12 * The CoreLocationObjects class contains the CoreLocation objects
     13 * we'll need.
     14 *
     15 * Declaring them directly in CoreLocationLocationProvider
     16 * would require Objective-C++ syntax, which would contaminate all
     17 * files that include this header and require them to be Objective-C++
     18 * as well.
     19 *
     20 * The solution then is to forward-declare CoreLocationObjects here and
     21 * hold a pointer to it in CoreLocationLocationProvider, and only actually
     22 * define it in CoreLocationLocationProvider.mm, thus making it safe
     23 * for Geolocation.cpp, which is C++-only, to include this header.
     24 */
     25 class CoreLocationObjects;
     26 class MLSFallback;
     27 
     28 class CoreLocationLocationProvider : public nsIGeolocationProvider {
     29 public:
     30  NS_DECL_ISUPPORTS
     31  NS_DECL_NSIGEOLOCATIONPROVIDER
     32 
     33  CoreLocationLocationProvider();
     34  // MOZ_CAN_RUN_SCRIPT_BOUNDARY because we can't mark Objective-C methods as
     35  // MOZ_CAN_RUN_SCRIPT as far as I can tell, and this method is called from
     36  // Objective-C.
     37  MOZ_CAN_RUN_SCRIPT_BOUNDARY
     38  void NotifyError(uint16_t aErrorCode);
     39  void Update(nsIDOMGeoPosition* aSomewhere);
     40  void CreateMLSFallbackProvider();
     41  void CancelMLSFallbackProvider();
     42  bool IsEverUpdated() const { return mEverUpdated; }
     43 
     44 private:
     45  virtual ~CoreLocationLocationProvider() = default;
     46 
     47  CoreLocationObjects* mCLObjects;
     48  nsCOMPtr<nsIGeolocationUpdate> mCallback;
     49  RefPtr<MLSFallback> mMLSFallbackProvider;
     50 
     51  bool mEverUpdated = false;
     52 
     53  class MLSUpdate : public nsIGeolocationUpdate {
     54   public:
     55    NS_DECL_ISUPPORTS
     56    NS_DECL_NSIGEOLOCATIONUPDATE
     57 
     58    explicit MLSUpdate(CoreLocationLocationProvider& parentProvider);
     59 
     60   private:
     61    CoreLocationLocationProvider& mParentLocationProvider;
     62    virtual ~MLSUpdate() = default;
     63  };
     64 };