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/. */
8 #include "mozilla/dom/BindingDeclarations.h"
9 #include "mozilla/dom/URLSearchParams.h"
10 #include "nsCycleCollectionParticipant.h"
11 #include "nsAutoPtr.h"
27 struct objectURLOptions
;
33 class URL MOZ_FINAL
: public URLSearchParamsObserver
36 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
37 NS_DECL_CYCLE_COLLECTION_CLASS(URL
)
43 WrapObject(JSContext
* aCx
);
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
);
52 static void CreateObjectURL(const GlobalObject
& aGlobal
,
54 const objectURLOptions
& aOptions
,
57 static void CreateObjectURL(const GlobalObject
& aGlobal
,
58 DOMMediaStream
& aStream
,
59 const objectURLOptions
& aOptions
,
62 static void CreateObjectURL(const GlobalObject
& aGlobal
,
64 const objectURLOptions
& aOptions
,
67 static void RevokeObjectURL(const GlobalObject
& aGlobal
,
68 const nsAString
& aURL
);
70 void GetHref(nsString
& aHref
) const;
72 void SetHref(const nsAString
& aHref
, ErrorResult
& aRv
);
74 void GetOrigin(nsString
& aOrigin
) const;
76 void GetProtocol(nsString
& aProtocol
) const;
78 void SetProtocol(const nsAString
& aProtocol
);
80 void GetUsername(nsString
& aUsername
) const;
82 void SetUsername(const nsAString
& aUsername
);
84 void GetPassword(nsString
& aPassword
) const;
86 void SetPassword(const nsAString
& aPassword
);
88 void GetHost(nsString
& aHost
) const;
90 void SetHost(const nsAString
& aHost
);
92 void GetHostname(nsString
& aHostname
) const;
94 void SetHostname(const nsAString
& aHostname
);
96 void GetPort(nsString
& aPort
) const;
98 void SetPort(const nsAString
& aPort
);
100 void GetPathname(nsString
& aPathname
) const;
102 void SetPathname(const nsAString
& aPathname
);
104 void GetSearch(nsString
& aRetval
) const;
106 void SetSearch(const nsAString
& aArg
);
108 URLSearchParams
* SearchParams();
110 void SetSearchParams(URLSearchParams
& aSearchParams
);
112 void GetHash(nsString
& aRetval
) const;
114 void SetHash(const nsAString
& aArg
);
116 void Stringify(nsString
& aRetval
) const
121 // URLSearchParamsObserver
122 void URLSearchParamsUpdated() MOZ_OVERRIDE
;
125 nsIURI
* GetURI() const
130 void CreateSearchParamsIfNeeded();
132 void SetSearchInternal(const nsAString
& aSearch
);
134 void UpdateURLSearchParams();
136 static void CreateObjectURLInternal(const GlobalObject
& aGlobal
,
137 nsISupports
* aObject
,
138 const nsACString
& aScheme
,
139 const objectURLOptions
& aOptions
,
141 ErrorResult
& aError
);
143 nsCOMPtr
<nsIURI
> mURI
;
144 nsRefPtr
<URLSearchParams
> mSearchParams
;
146 friend class mozilla::dom::workers::URLProxy
;
149 bool IsChromeURI(nsIURI
* aURI
);
154 #endif /* URL_h___ */