tor-browser

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

PlacesBookmarkAddition.h (3201B)


      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_PlacesBookmarkAddition_h
      8 #define mozilla_dom_PlacesBookmarkAddition_h
      9 
     10 #include "mozilla/dom/PlacesBookmark.h"
     11 
     12 namespace mozilla {
     13 namespace dom {
     14 
     15 class PlacesBookmarkAddition final : public PlacesBookmark {
     16 public:
     17  explicit PlacesBookmarkAddition()
     18      : PlacesBookmark(PlacesEventType::Bookmark_added) {}
     19 
     20  static already_AddRefed<PlacesBookmarkAddition> Constructor(
     21      const GlobalObject& aGlobal,
     22      const PlacesBookmarkAdditionInit& aInitDict) {
     23    RefPtr<PlacesBookmarkAddition> event = new PlacesBookmarkAddition();
     24    event->mItemType = aInitDict.mItemType;
     25    event->mId = aInitDict.mId;
     26    event->mParentId = aInitDict.mParentId;
     27    event->mIndex = aInitDict.mIndex;
     28    event->mUrl = aInitDict.mUrl;
     29    event->mTitle = aInitDict.mTitle;
     30    event->mTags = aInitDict.mTags;
     31    event->mDateAdded = aInitDict.mDateAdded;
     32    event->mGuid = aInitDict.mGuid;
     33    event->mParentGuid = aInitDict.mParentGuid;
     34    event->mSource = aInitDict.mSource;
     35    event->mIsTagging = aInitDict.mIsTagging;
     36    event->mFrecency = aInitDict.mFrecency;
     37    event->mHidden = aInitDict.mHidden;
     38    event->mVisitCount = aInitDict.mVisitCount;
     39 
     40    if (!aInitDict.mLastVisitDate.IsNull()) {
     41      event->mLastVisitDate.SetValue(aInitDict.mLastVisitDate.Value());
     42    } else {
     43      event->mLastVisitDate.SetNull();
     44    }
     45 
     46    event->mTargetFolderItemId = aInitDict.mTargetFolderItemId;
     47    event->mTargetFolderGuid = aInitDict.mTargetFolderGuid;
     48    event->mTargetFolderTitle = aInitDict.mTargetFolderTitle;
     49 
     50    return event.forget();
     51  }
     52 
     53  JSObject* WrapObject(JSContext* aCx,
     54                       JS::Handle<JSObject*> aGivenProto) override {
     55    return PlacesBookmarkAddition_Binding::Wrap(aCx, this, aGivenProto);
     56  }
     57 
     58  const PlacesBookmarkAddition* AsPlacesBookmarkAddition() const override {
     59    return this;
     60  }
     61 
     62  int32_t Index() { return mIndex; }
     63  void GetTitle(nsString& aTitle) { aTitle = mTitle; }
     64  void GetTags(nsString& aTags) { aTags = mTags; }
     65  uint64_t DateAdded() { return mDateAdded; }
     66  uint64_t Frecency() { return mFrecency; }
     67  bool Hidden() { return mHidden; }
     68  uint32_t VisitCount() { return mVisitCount; }
     69  Nullable<uint64_t> GetLastVisitDate() { return mLastVisitDate; }
     70  uint64_t TargetFolderItemId() { return mTargetFolderItemId; }
     71  void GetTargetFolderGuid(nsCString& aGuid) { aGuid = mTargetFolderGuid; }
     72  void GetTargetFolderTitle(nsString& aTitle) { aTitle = mTargetFolderTitle; }
     73 
     74  int32_t mIndex;
     75  nsString mTitle;
     76  nsString mTags;
     77  uint64_t mDateAdded;
     78  int64_t mFrecency;
     79  bool mHidden;
     80  uint32_t mVisitCount;
     81  Nullable<uint64_t> mLastVisitDate;
     82  int64_t mTargetFolderItemId;
     83  nsCString mTargetFolderGuid;
     84  nsString mTargetFolderTitle;
     85 
     86 private:
     87  ~PlacesBookmarkAddition() = default;
     88 };
     89 
     90 }  // namespace dom
     91 }  // namespace mozilla
     92 
     93 #endif  // mozilla_dom_PlacesBookmarkAddition_h