tor-browser

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

StorageEvent.h (2512B)


      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 #ifndef mozilla_dom_StorageEvent_h
      8 #define mozilla_dom_StorageEvent_h
      9 
     10 #include "js/RootingAPI.h"
     11 #include "mozilla/AlreadyAddRefed.h"
     12 #include "mozilla/Assertions.h"
     13 #include "mozilla/RefPtr.h"
     14 #include "mozilla/dom/Event.h"
     15 #include "nsCOMPtr.h"
     16 #include "nsCycleCollectionParticipant.h"
     17 #include "nsIPrincipal.h"
     18 #include "nsISupports.h"
     19 #include "nsStringFwd.h"
     20 
     21 class nsIPrincipal;
     22 
     23 namespace mozilla::dom {
     24 
     25 class Storage;
     26 struct StorageEventInit;
     27 
     28 class StorageEvent : public Event {
     29 public:
     30  NS_DECL_ISUPPORTS_INHERITED
     31  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(StorageEvent, Event)
     32 
     33  explicit StorageEvent(EventTarget* aOwner);
     34 
     35 protected:
     36  virtual ~StorageEvent();
     37 
     38  nsString mKey;
     39  nsString mOldValue;
     40  nsString mNewValue;
     41  nsString mUrl;
     42  RefPtr<Storage> mStorageArea;
     43  nsCOMPtr<nsIPrincipal> mPrincipal;
     44 
     45 public:
     46  virtual StorageEvent* AsStorageEvent();
     47 
     48  virtual JSObject* WrapObjectInternal(
     49      JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
     50 
     51  static already_AddRefed<StorageEvent> Constructor(
     52      EventTarget* aOwner, const nsAString& aType,
     53      const StorageEventInit& aEventInitDict);
     54 
     55  static already_AddRefed<StorageEvent> Constructor(
     56      const GlobalObject& aGlobal, const nsAString& aType,
     57      const StorageEventInit& aEventInitDict);
     58 
     59  void InitStorageEvent(const nsAString& aType, bool aCanBubble,
     60                        bool aCancelable, const nsAString& aKey,
     61                        const nsAString& aOldValue, const nsAString& aNewValue,
     62                        const nsAString& aURL, Storage* aStorageArea);
     63 
     64  void GetKey(nsString& aRetVal) const { aRetVal = mKey; }
     65 
     66  void GetOldValue(nsString& aRetVal) const { aRetVal = mOldValue; }
     67 
     68  void GetNewValue(nsString& aRetVal) const { aRetVal = mNewValue; }
     69 
     70  void GetUrl(nsString& aRetVal) const { aRetVal = mUrl; }
     71 
     72  Storage* GetStorageArea() const { return mStorageArea; }
     73 
     74  // Non WebIDL methods
     75  void SetPrincipal(nsIPrincipal* aPrincipal) {
     76    MOZ_ASSERT(!mPrincipal);
     77    mPrincipal = aPrincipal;
     78  }
     79 
     80  nsIPrincipal* GetPrincipal() const { return mPrincipal; }
     81 };
     82 
     83 }  // namespace mozilla::dom
     84 
     85 #endif  // mozilla_dom_StorageEvent_h