michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: #ifndef URL_h___ michael@0: #define URL_h___ michael@0: michael@0: #include "mozilla/dom/BindingDeclarations.h" michael@0: #include "mozilla/dom/URLSearchParams.h" michael@0: #include "nsCycleCollectionParticipant.h" michael@0: #include "nsAutoPtr.h" michael@0: #include "nsString.h" michael@0: michael@0: class nsIDOMBlob; michael@0: class nsISupports; michael@0: class nsIURI; michael@0: michael@0: namespace mozilla { michael@0: michael@0: class ErrorResult; michael@0: class DOMMediaStream; michael@0: michael@0: namespace dom { michael@0: michael@0: class MediaSource; michael@0: class GlobalObject; michael@0: struct objectURLOptions; michael@0: michael@0: namespace workers { michael@0: class URLProxy; michael@0: } michael@0: michael@0: class URL MOZ_FINAL : public URLSearchParamsObserver michael@0: { michael@0: public: michael@0: NS_DECL_CYCLE_COLLECTING_ISUPPORTS michael@0: NS_DECL_CYCLE_COLLECTION_CLASS(URL) michael@0: michael@0: URL(nsIURI* aURI); michael@0: michael@0: // WebIDL methods michael@0: JSObject* michael@0: WrapObject(JSContext* aCx); michael@0: michael@0: static already_AddRefed michael@0: Constructor(const GlobalObject& aGlobal, const nsAString& aUrl, michael@0: URL& aBase, ErrorResult& aRv); michael@0: static already_AddRefed michael@0: Constructor(const GlobalObject& aGlobal, const nsAString& aUrl, michael@0: const nsAString& aBase, ErrorResult& aRv); michael@0: michael@0: static void CreateObjectURL(const GlobalObject& aGlobal, michael@0: nsIDOMBlob* aBlob, michael@0: const objectURLOptions& aOptions, michael@0: nsString& aResult, michael@0: ErrorResult& aError); michael@0: static void CreateObjectURL(const GlobalObject& aGlobal, michael@0: DOMMediaStream& aStream, michael@0: const objectURLOptions& aOptions, michael@0: nsString& aResult, michael@0: ErrorResult& aError); michael@0: static void CreateObjectURL(const GlobalObject& aGlobal, michael@0: MediaSource& aSource, michael@0: const objectURLOptions& aOptions, michael@0: nsString& aResult, michael@0: ErrorResult& aError); michael@0: static void RevokeObjectURL(const GlobalObject& aGlobal, michael@0: const nsAString& aURL); michael@0: michael@0: void GetHref(nsString& aHref) const; michael@0: michael@0: void SetHref(const nsAString& aHref, ErrorResult& aRv); michael@0: michael@0: void GetOrigin(nsString& aOrigin) const; michael@0: michael@0: void GetProtocol(nsString& aProtocol) const; michael@0: michael@0: void SetProtocol(const nsAString& aProtocol); michael@0: michael@0: void GetUsername(nsString& aUsername) const; michael@0: michael@0: void SetUsername(const nsAString& aUsername); michael@0: michael@0: void GetPassword(nsString& aPassword) const; michael@0: michael@0: void SetPassword(const nsAString& aPassword); michael@0: michael@0: void GetHost(nsString& aHost) const; michael@0: michael@0: void SetHost(const nsAString& aHost); michael@0: michael@0: void GetHostname(nsString& aHostname) const; michael@0: michael@0: void SetHostname(const nsAString& aHostname); michael@0: michael@0: void GetPort(nsString& aPort) const; michael@0: michael@0: void SetPort(const nsAString& aPort); michael@0: michael@0: void GetPathname(nsString& aPathname) const; michael@0: michael@0: void SetPathname(const nsAString& aPathname); michael@0: michael@0: void GetSearch(nsString& aRetval) const; michael@0: michael@0: void SetSearch(const nsAString& aArg); michael@0: michael@0: URLSearchParams* SearchParams(); michael@0: michael@0: void SetSearchParams(URLSearchParams& aSearchParams); michael@0: michael@0: void GetHash(nsString& aRetval) const; michael@0: michael@0: void SetHash(const nsAString& aArg); michael@0: michael@0: void Stringify(nsString& aRetval) const michael@0: { michael@0: GetHref(aRetval); michael@0: } michael@0: michael@0: // URLSearchParamsObserver michael@0: void URLSearchParamsUpdated() MOZ_OVERRIDE; michael@0: michael@0: private: michael@0: nsIURI* GetURI() const michael@0: { michael@0: return mURI; michael@0: } michael@0: michael@0: void CreateSearchParamsIfNeeded(); michael@0: michael@0: void SetSearchInternal(const nsAString& aSearch); michael@0: michael@0: void UpdateURLSearchParams(); michael@0: michael@0: static void CreateObjectURLInternal(const GlobalObject& aGlobal, michael@0: nsISupports* aObject, michael@0: const nsACString& aScheme, michael@0: const objectURLOptions& aOptions, michael@0: nsString& aResult, michael@0: ErrorResult& aError); michael@0: michael@0: nsCOMPtr mURI; michael@0: nsRefPtr mSearchParams; michael@0: michael@0: friend class mozilla::dom::workers::URLProxy; michael@0: }; michael@0: michael@0: bool IsChromeURI(nsIURI* aURI); michael@0: michael@0: } michael@0: } michael@0: michael@0: #endif /* URL_h___ */