/work/obj-fuzz/dist/include/mozilla/dom/URL.h
Line | Count | Source (jump to first uncovered line) |
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_URL_h |
8 | | #define mozilla_dom_URL_h |
9 | | |
10 | | #include "mozilla/dom/BindingDeclarations.h" |
11 | | #include "mozilla/dom/URLSearchParams.h" |
12 | | #include "nsCycleCollectionParticipant.h" |
13 | | #include "nsString.h" |
14 | | #include "nsWrapperCache.h" |
15 | | |
16 | | class nsISupports; |
17 | | class nsIURI; |
18 | | |
19 | | namespace mozilla { |
20 | | |
21 | | class ErrorResult; |
22 | | |
23 | | namespace dom { |
24 | | |
25 | | class Blob; |
26 | | class MediaSource; |
27 | | class GlobalObject; |
28 | | |
29 | | class URL : public URLSearchParamsObserver |
30 | | , public nsWrapperCache |
31 | | { |
32 | | public: |
33 | | NS_DECL_CYCLE_COLLECTING_ISUPPORTS |
34 | | NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(URL) |
35 | | |
36 | | URL(nsISupports* aParent) |
37 | | : mParent(aParent) |
38 | 0 | {} |
39 | | |
40 | | // WebIDL methods |
41 | | nsISupports* GetParentObject() const |
42 | 0 | { |
43 | 0 | return mParent; |
44 | 0 | } |
45 | | |
46 | | virtual JSObject* |
47 | | WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override; |
48 | | |
49 | | static already_AddRefed<URL> |
50 | | Constructor(const GlobalObject& aGlobal, const nsAString& aURL, |
51 | | const Optional<nsAString>& aBase, ErrorResult& aRv); |
52 | | |
53 | | // Helper for Fetch API |
54 | | static already_AddRefed<URL> |
55 | | WorkerConstructor(const GlobalObject& aGlobal, const nsAString& aURL, |
56 | | const nsAString& aBase, ErrorResult& aRv); |
57 | | |
58 | | |
59 | | static void |
60 | | CreateObjectURL(const GlobalObject& aGlobal, Blob& aBlob, |
61 | | nsAString& aResult, ErrorResult& aRv); |
62 | | |
63 | | static void |
64 | | CreateObjectURL(const GlobalObject& aGlobal, MediaSource& aSource, |
65 | | nsAString& aResult, ErrorResult& aRv); |
66 | | |
67 | | static void |
68 | | RevokeObjectURL(const GlobalObject& aGlobal, const nsAString& aURL, |
69 | | ErrorResult& aRv); |
70 | | |
71 | | static bool |
72 | | IsValidURL(const GlobalObject& aGlobal, const nsAString& aURL, |
73 | | ErrorResult& aRv); |
74 | | |
75 | | void |
76 | | GetHref(nsAString& aHref) const; |
77 | | |
78 | | virtual void |
79 | | SetHref(const nsAString& aHref, ErrorResult& aRv) = 0; |
80 | | |
81 | | virtual void |
82 | | GetOrigin(nsAString& aOrigin, ErrorResult& aRv) const = 0; |
83 | | |
84 | | void |
85 | | GetProtocol(nsAString& aProtocol) const; |
86 | | |
87 | | virtual void |
88 | | SetProtocol(const nsAString& aProtocol, ErrorResult& aRv) = 0; |
89 | | |
90 | | void |
91 | | GetUsername(nsAString& aUsername) const; |
92 | | |
93 | | void |
94 | | SetUsername(const nsAString& aUsername); |
95 | | |
96 | | void |
97 | | GetPassword(nsAString& aPassword) const; |
98 | | |
99 | | void |
100 | | SetPassword(const nsAString& aPassword); |
101 | | |
102 | | void |
103 | | GetHost(nsAString& aHost) const; |
104 | | |
105 | | void |
106 | | SetHost(const nsAString& aHost); |
107 | | |
108 | | void |
109 | | GetHostname(nsAString& aHostname) const; |
110 | | |
111 | | void |
112 | | SetHostname(const nsAString& aHostname); |
113 | | |
114 | | void |
115 | | GetPort(nsAString& aPort) const; |
116 | | |
117 | | void |
118 | | SetPort(const nsAString& aPort); |
119 | | |
120 | | void |
121 | | GetPathname(nsAString& aPathname) const; |
122 | | |
123 | | void |
124 | | SetPathname(const nsAString& aPathname); |
125 | | |
126 | | void |
127 | | GetSearch(nsAString& aSearch) const; |
128 | | |
129 | | virtual void |
130 | | SetSearch(const nsAString& aSearch); |
131 | | |
132 | | URLSearchParams* SearchParams(); |
133 | | |
134 | | void |
135 | | GetHash(nsAString& aHost) const; |
136 | | |
137 | | void |
138 | | SetHash(const nsAString& aHash); |
139 | | |
140 | | void Stringify(nsAString& aRetval) const |
141 | 0 | { |
142 | 0 | GetHref(aRetval); |
143 | 0 | } |
144 | | |
145 | | void |
146 | | ToJSON(nsAString& aResult) const |
147 | 0 | { |
148 | 0 | GetHref(aResult); |
149 | 0 | } |
150 | | |
151 | | // URLSearchParamsObserver |
152 | | void |
153 | | URLSearchParamsUpdated(URLSearchParams* aSearchParams) override; |
154 | | |
155 | | protected: |
156 | 0 | virtual ~URL() = default; |
157 | | |
158 | | void |
159 | | SetURI(already_AddRefed<nsIURI> aURI); |
160 | | |
161 | | nsIURI* |
162 | | GetURI() const; |
163 | | |
164 | | void |
165 | | UpdateURLSearchParams(); |
166 | | |
167 | | private: |
168 | | void |
169 | | SetSearchInternal(const nsAString& aSearch); |
170 | | |
171 | | void CreateSearchParamsIfNeeded(); |
172 | | |
173 | | nsCOMPtr<nsISupports> mParent; |
174 | | RefPtr<URLSearchParams> mSearchParams; |
175 | | nsCOMPtr<nsIURI> mURI; |
176 | | }; |
177 | | |
178 | | bool IsChromeURI(nsIURI* aURI); |
179 | | |
180 | | } // namespace dom |
181 | | } // namespace mozilla |
182 | | |
183 | | #endif /* mozilla_dom_URL_h */ |