dom/base/URL.h

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:195b69348438
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/. */
5 #ifndef URL_h___
6 #define URL_h___
7
8 #include "mozilla/dom/BindingDeclarations.h"
9 #include "mozilla/dom/URLSearchParams.h"
10 #include "nsCycleCollectionParticipant.h"
11 #include "nsAutoPtr.h"
12 #include "nsString.h"
13
14 class nsIDOMBlob;
15 class nsISupports;
16 class nsIURI;
17
18 namespace mozilla {
19
20 class ErrorResult;
21 class DOMMediaStream;
22
23 namespace dom {
24
25 class MediaSource;
26 class GlobalObject;
27 struct objectURLOptions;
28
29 namespace workers {
30 class URLProxy;
31 }
32
33 class URL MOZ_FINAL : public URLSearchParamsObserver
34 {
35 public:
36 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
37 NS_DECL_CYCLE_COLLECTION_CLASS(URL)
38
39 URL(nsIURI* aURI);
40
41 // WebIDL methods
42 JSObject*
43 WrapObject(JSContext* aCx);
44
45 static already_AddRefed<URL>
46 Constructor(const GlobalObject& aGlobal, const nsAString& aUrl,
47 URL& aBase, ErrorResult& aRv);
48 static already_AddRefed<URL>
49 Constructor(const GlobalObject& aGlobal, const nsAString& aUrl,
50 const nsAString& aBase, ErrorResult& aRv);
51
52 static void CreateObjectURL(const GlobalObject& aGlobal,
53 nsIDOMBlob* aBlob,
54 const objectURLOptions& aOptions,
55 nsString& aResult,
56 ErrorResult& aError);
57 static void CreateObjectURL(const GlobalObject& aGlobal,
58 DOMMediaStream& aStream,
59 const objectURLOptions& aOptions,
60 nsString& aResult,
61 ErrorResult& aError);
62 static void CreateObjectURL(const GlobalObject& aGlobal,
63 MediaSource& aSource,
64 const objectURLOptions& aOptions,
65 nsString& aResult,
66 ErrorResult& aError);
67 static void RevokeObjectURL(const GlobalObject& aGlobal,
68 const nsAString& aURL);
69
70 void GetHref(nsString& aHref) const;
71
72 void SetHref(const nsAString& aHref, ErrorResult& aRv);
73
74 void GetOrigin(nsString& aOrigin) const;
75
76 void GetProtocol(nsString& aProtocol) const;
77
78 void SetProtocol(const nsAString& aProtocol);
79
80 void GetUsername(nsString& aUsername) const;
81
82 void SetUsername(const nsAString& aUsername);
83
84 void GetPassword(nsString& aPassword) const;
85
86 void SetPassword(const nsAString& aPassword);
87
88 void GetHost(nsString& aHost) const;
89
90 void SetHost(const nsAString& aHost);
91
92 void GetHostname(nsString& aHostname) const;
93
94 void SetHostname(const nsAString& aHostname);
95
96 void GetPort(nsString& aPort) const;
97
98 void SetPort(const nsAString& aPort);
99
100 void GetPathname(nsString& aPathname) const;
101
102 void SetPathname(const nsAString& aPathname);
103
104 void GetSearch(nsString& aRetval) const;
105
106 void SetSearch(const nsAString& aArg);
107
108 URLSearchParams* SearchParams();
109
110 void SetSearchParams(URLSearchParams& aSearchParams);
111
112 void GetHash(nsString& aRetval) const;
113
114 void SetHash(const nsAString& aArg);
115
116 void Stringify(nsString& aRetval) const
117 {
118 GetHref(aRetval);
119 }
120
121 // URLSearchParamsObserver
122 void URLSearchParamsUpdated() MOZ_OVERRIDE;
123
124 private:
125 nsIURI* GetURI() const
126 {
127 return mURI;
128 }
129
130 void CreateSearchParamsIfNeeded();
131
132 void SetSearchInternal(const nsAString& aSearch);
133
134 void UpdateURLSearchParams();
135
136 static void CreateObjectURLInternal(const GlobalObject& aGlobal,
137 nsISupports* aObject,
138 const nsACString& aScheme,
139 const objectURLOptions& aOptions,
140 nsString& aResult,
141 ErrorResult& aError);
142
143 nsCOMPtr<nsIURI> mURI;
144 nsRefPtr<URLSearchParams> mSearchParams;
145
146 friend class mozilla::dom::workers::URLProxy;
147 };
148
149 bool IsChromeURI(nsIURI* aURI);
150
151 }
152 }
153
154 #endif /* URL_h___ */

mercurial