tor-browser

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

PlacesVisitRemoved.h (2520B)


      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 file,
      5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #ifndef mozilla_dom_PlacesVisitRemoved_h
      8 #define mozilla_dom_PlacesVisitRemoved_h
      9 
     10 #include "mozilla/dom/PlacesEvent.h"
     11 
     12 namespace mozilla {
     13 namespace dom {
     14 
     15 class PlacesVisitRemoved final : public PlacesEvent {
     16 public:
     17  explicit PlacesVisitRemoved() : PlacesEvent(PlacesEventType::Page_removed) {}
     18 
     19  static already_AddRefed<PlacesVisitRemoved> Constructor(
     20      const GlobalObject& aGlobal, const PlacesVisitRemovedInit& aInitDict) {
     21    MOZ_ASSERT(
     22        aInitDict.mReason == PlacesVisitRemoved_Binding::REASON_DELETED ||
     23            aInitDict.mReason == PlacesVisitRemoved_Binding::REASON_EXPIRED,
     24        "The reason should be REASON_DELETED or REASON_EXPIRED");
     25    MOZ_ASSERT(
     26        !(aInitDict.mIsRemovedFromStore && aInitDict.mIsPartialVisistsRemoval),
     27        "isRemovedFromStore and isPartialVisistsRemoval are inconsistent");
     28 
     29    RefPtr<PlacesVisitRemoved> event = new PlacesVisitRemoved();
     30    event->mUrl = aInitDict.mUrl;
     31    event->mPageGuid = aInitDict.mPageGuid;
     32    event->mReason = aInitDict.mReason;
     33    event->mTransitionType = aInitDict.mTransitionType;
     34    event->mIsRemovedFromStore = aInitDict.mIsRemovedFromStore;
     35    event->mIsPartialVisistsRemoval = aInitDict.mIsPartialVisistsRemoval;
     36    return event.forget();
     37  }
     38 
     39  JSObject* WrapObject(JSContext* aCx,
     40                       JS::Handle<JSObject*> aGivenProto) override {
     41    return PlacesVisitRemoved_Binding::Wrap(aCx, this, aGivenProto);
     42  }
     43 
     44  const PlacesVisitRemoved* AsPlacesVisitRemoved() const override {
     45    return this;
     46  }
     47 
     48  void GetUrl(nsString& aUrl) const { aUrl = mUrl; }
     49  void GetPageGuid(nsCString& aPageGuid) const { aPageGuid = mPageGuid; }
     50  uint16_t Reason() const { return mReason; }
     51  uint32_t TransitionType() const { return mTransitionType; }
     52  bool IsRemovedFromStore() const { return mIsRemovedFromStore; }
     53  bool IsPartialVisistsRemoval() const { return mIsPartialVisistsRemoval; }
     54 
     55  nsString mUrl;
     56  nsCString mPageGuid;
     57  uint16_t mReason;
     58  uint32_t mTransitionType;
     59  bool mIsRemovedFromStore;
     60  bool mIsPartialVisistsRemoval;
     61 
     62 private:
     63  ~PlacesVisitRemoved() = default;
     64 };
     65 
     66 }  // namespace dom
     67 }  // namespace mozilla
     68 
     69 #endif  // mozilla_dom_PlacesVisitRemoved_h