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"
29 struct objectURLOptions
;
35 class URL MOZ_FINAL
: public URLSearchParamsObserver
40 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
41 NS_DECL_CYCLE_COLLECTION_CLASS(URL
)
43 explicit URL(nsIURI
* aURI
);
47 WrapObject(JSContext
* aCx
);
49 static already_AddRefed
<URL
>
50 Constructor(const GlobalObject
& aGlobal
, const nsAString
& aUrl
,
51 URL
& aBase
, ErrorResult
& aRv
);
52 static already_AddRefed
<URL
>
53 Constructor(const GlobalObject
& aGlobal
, const nsAString
& aUrl
,
54 const nsAString
& aBase
, ErrorResult
& aRv
);
56 static void CreateObjectURL(const GlobalObject
& aGlobal
,
58 const objectURLOptions
& aOptions
,
61 static void CreateObjectURL(const GlobalObject
& aGlobal
,
62 DOMMediaStream
& aStream
,
63 const objectURLOptions
& aOptions
,
66 static void CreateObjectURL(const GlobalObject
& aGlobal
,
68 const objectURLOptions
& aOptions
,
71 static void RevokeObjectURL(const GlobalObject
& aGlobal
,
72 const nsAString
& aURL
);
74 void GetHref(nsString
& aHref
, ErrorResult
& aRv
) const;
76 void SetHref(const nsAString
& aHref
, ErrorResult
& aRv
);
78 void GetOrigin(nsString
& aOrigin
, ErrorResult
& aRv
) const;
80 void GetProtocol(nsString
& aProtocol
, ErrorResult
& aRv
) const;
82 void SetProtocol(const nsAString
& aProtocol
, ErrorResult
& aRv
);
84 void GetUsername(nsString
& aUsername
, ErrorResult
& aRv
) const;
86 void SetUsername(const nsAString
& aUsername
, ErrorResult
& aRv
);
88 void GetPassword(nsString
& aPassword
, ErrorResult
& aRv
) const;
90 void SetPassword(const nsAString
& aPassword
, ErrorResult
& aRv
);
92 void GetHost(nsString
& aHost
, ErrorResult
& aRv
) const;
94 void SetHost(const nsAString
& aHost
, ErrorResult
& aRv
);
96 void GetHostname(nsString
& aHostname
, ErrorResult
& aRv
) const;
98 void SetHostname(const nsAString
& aHostname
, ErrorResult
& aRv
);
100 void GetPort(nsString
& aPort
, ErrorResult
& aRv
) const;
102 void SetPort(const nsAString
& aPort
, ErrorResult
& aRv
);
104 void GetPathname(nsString
& aPathname
, ErrorResult
& aRv
) const;
106 void SetPathname(const nsAString
& aPathname
, ErrorResult
& aRv
);
108 void GetSearch(nsString
& aRetval
, ErrorResult
& aRv
) const;
110 void SetSearch(const nsAString
& aArg
, ErrorResult
& aRv
);
112 URLSearchParams
* SearchParams();
114 void SetSearchParams(URLSearchParams
& aSearchParams
);
116 void GetHash(nsString
& aRetval
, ErrorResult
& aRv
) const;
118 void SetHash(const nsAString
& aArg
, ErrorResult
& aRv
);
120 void Stringify(nsString
& aRetval
, ErrorResult
& aRv
) const
122 GetHref(aRetval
, aRv
);
125 // URLSearchParamsObserver
126 void URLSearchParamsUpdated(URLSearchParams
* aSearchParams
) MOZ_OVERRIDE
;
129 nsIURI
* GetURI() const
134 void CreateSearchParamsIfNeeded();
136 void SetSearchInternal(const nsAString
& aSearch
);
138 void UpdateURLSearchParams();
140 static void CreateObjectURLInternal(const GlobalObject
& aGlobal
,
141 nsISupports
* aObject
,
142 const nsACString
& aScheme
,
143 const objectURLOptions
& aOptions
,
145 ErrorResult
& aError
);
147 nsCOMPtr
<nsIURI
> mURI
;
148 nsRefPtr
<URLSearchParams
> mSearchParams
;
150 friend class mozilla::dom::workers::URLProxy
;
153 bool IsChromeURI(nsIURI
* aURI
);
158 #endif /* URL_h___ */