michael@0: /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */ michael@0: /* vim: set ts=2 et sw=2 tw=80: */ 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: * url, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_dom_workers_url_h__ michael@0: #define mozilla_dom_workers_url_h__ michael@0: michael@0: #include "Workers.h" michael@0: michael@0: #include "mozilla/ErrorResult.h" michael@0: #include "mozilla/dom/BindingDeclarations.h" michael@0: #include "mozilla/dom/URLSearchParams.h" michael@0: michael@0: namespace mozilla { michael@0: namespace dom { michael@0: struct objectURLOptions; michael@0: } michael@0: } michael@0: michael@0: BEGIN_WORKERS_NAMESPACE michael@0: michael@0: class URLProxy; michael@0: michael@0: class URL MOZ_FINAL : public mozilla::dom::URLSearchParamsObserver michael@0: { michael@0: typedef mozilla::dom::URLSearchParams URLSearchParams; 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(WorkerPrivate* aWorkerPrivate, URLProxy* aURLProxy); michael@0: ~URL(); michael@0: michael@0: nsISupports* michael@0: GetParentObject() const michael@0: { michael@0: // There's only one global on a worker, so we don't need to specify. michael@0: return nullptr; michael@0: } michael@0: michael@0: JSObject* michael@0: WrapObject(JSContext* aCx); michael@0: michael@0: // Methods for WebIDL michael@0: michael@0: static URL* michael@0: Constructor(const GlobalObject& aGlobal, const nsAString& aUrl, michael@0: URL& aBase, ErrorResult& aRv); michael@0: static URL* michael@0: Constructor(const GlobalObject& aGlobal, const nsAString& aUrl, michael@0: const nsAString& aBase, ErrorResult& aRv); michael@0: michael@0: static void michael@0: CreateObjectURL(const GlobalObject& aGlobal, michael@0: JSObject* aArg, const objectURLOptions& aOptions, michael@0: nsString& aResult, ErrorResult& aRv); michael@0: michael@0: static void michael@0: CreateObjectURL(const GlobalObject& aGlobal, michael@0: JSObject& aArg, const objectURLOptions& aOptions, michael@0: nsString& aResult, ErrorResult& aRv); michael@0: michael@0: static void michael@0: RevokeObjectURL(const GlobalObject& aGlobal, 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& aSearch) const; michael@0: michael@0: void SetSearch(const nsAString& aSearch); michael@0: michael@0: URLSearchParams* SearchParams(); michael@0: michael@0: void SetSearchParams(URLSearchParams& aSearchParams); michael@0: michael@0: void GetHash(nsString& aHost) const; michael@0: michael@0: void SetHash(const nsAString& aHash); michael@0: michael@0: void Stringify(nsString& aRetval) const michael@0: { michael@0: GetHref(aRetval); michael@0: } michael@0: michael@0: // IURLSearchParamsObserver michael@0: void URLSearchParamsUpdated() MOZ_OVERRIDE; michael@0: michael@0: private: michael@0: URLProxy* GetURLProxy() const michael@0: { michael@0: return mURLProxy; 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: WorkerPrivate* mWorkerPrivate; michael@0: nsRefPtr mURLProxy; michael@0: nsRefPtr mSearchParams; michael@0: }; michael@0: michael@0: END_WORKERS_NAMESPACE michael@0: michael@0: #endif /* mozilla_dom_workers_url_h__ */