1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef mozilla_dom_URLSearchParams_h
7 #define mozilla_dom_URLSearchParams_h
9 #include "mozilla/dom/BindingDeclarations.h"
10 #include "mozilla/ErrorResult.h"
11 #include "nsCycleCollectionParticipant.h"
12 #include "nsWrapperCache.h"
13 #include "nsISupports.h"
14 #include "nsIUnicodeDecoder.h"
19 class URLSearchParams
;
21 class URLSearchParamsObserver
: public nsISupports
24 virtual ~URLSearchParamsObserver() {}
26 virtual void URLSearchParamsUpdated(URLSearchParams
* aFromThis
) = 0;
29 class URLSearchParams MOZ_FINAL
: public nsISupports
,
35 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
36 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(URLSearchParams
)
41 nsISupports
* GetParentObject() const
47 WrapObject(JSContext
* aCx
) MOZ_OVERRIDE
;
49 static already_AddRefed
<URLSearchParams
>
50 Constructor(const GlobalObject
& aGlobal
, const nsAString
& aInit
,
53 static already_AddRefed
<URLSearchParams
>
54 Constructor(const GlobalObject
& aGlobal
, URLSearchParams
& aInit
,
57 void ParseInput(const nsACString
& aInput
,
58 URLSearchParamsObserver
* aObserver
);
60 void AddObserver(URLSearchParamsObserver
* aObserver
);
61 void RemoveObserver(URLSearchParamsObserver
* aObserver
);
62 void RemoveObservers();
64 void Serialize(nsAString
& aValue
) const;
66 void Get(const nsAString
& aName
, nsString
& aRetval
);
68 void GetAll(const nsAString
& aName
, nsTArray
<nsString
>& aRetval
);
70 void Set(const nsAString
& aName
, const nsAString
& aValue
);
72 void Append(const nsAString
& aName
, const nsAString
& aValue
);
74 bool Has(const nsAString
& aName
);
76 void Delete(const nsAString
& aName
);
78 void Stringify(nsString
& aRetval
) const
84 void AppendInternal(const nsAString
& aName
, const nsAString
& aValue
);
88 void DecodeString(const nsACString
& aInput
, nsAString
& aOutput
);
89 void ConvertString(const nsACString
& aInput
, nsAString
& aOutput
);
91 void NotifyObservers(URLSearchParamsObserver
* aExceptObserver
);
99 nsTArray
<Param
> mSearchParams
;
101 nsTArray
<nsRefPtr
<URLSearchParamsObserver
>> mObservers
;
102 nsCOMPtr
<nsIUnicodeDecoder
> mDecoder
;
106 } // namespace mozilla
108 #endif /* mozilla_dom_URLSearchParams_h */