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