tor-browser

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

PrivateAttribution.h (1584B)


      1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
      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 #ifndef mozilla_dom_PrivateAttribution_h
      8 #define mozilla_dom_PrivateAttribution_h
      9 
     10 #include "nsCOMPtr.h"
     11 #include "nsWrapperCache.h"
     12 
     13 class nsIGlobalObject;
     14 namespace mozilla {
     15 class ErrorResult;
     16 }
     17 
     18 namespace mozilla::dom {
     19 
     20 struct PrivateAttributionImpressionOptions;
     21 struct PrivateAttributionConversionOptions;
     22 
     23 class PrivateAttribution final : public nsWrapperCache {
     24 public:
     25  NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(PrivateAttribution)
     26  NS_DECL_CYCLE_COLLECTION_NATIVE_WRAPPERCACHE_CLASS(PrivateAttribution)
     27 
     28  explicit PrivateAttribution(nsIGlobalObject* aGlobal);
     29  static already_AddRefed<PrivateAttribution> Create(nsIGlobalObject& aGlobal);
     30 
     31  nsIGlobalObject* GetParentObject() const { return mOwner; }
     32  JSObject* WrapObject(JSContext*, JS::Handle<JSObject*> aGivenProto) override;
     33 
     34  void SaveImpression(const PrivateAttributionImpressionOptions&, ErrorResult&);
     35  void MeasureConversion(const PrivateAttributionConversionOptions&,
     36                         ErrorResult&);
     37 
     38 private:
     39  static bool ShouldRecord();
     40 
     41  [[nodiscard]] bool GetSourceHostIfNonPrivate(nsACString&, ErrorResult&);
     42 
     43  ~PrivateAttribution();
     44 
     45  nsCOMPtr<nsIGlobalObject> mOwner;
     46 };
     47 
     48 }  // namespace mozilla::dom
     49 
     50 #endif  // mozilla_dom_PrivateAttribution_h