Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | #ifndef URL_h___ |
michael@0 | 6 | #define URL_h___ |
michael@0 | 7 | |
michael@0 | 8 | #include "mozilla/dom/BindingDeclarations.h" |
michael@0 | 9 | #include "mozilla/dom/URLSearchParams.h" |
michael@0 | 10 | #include "nsCycleCollectionParticipant.h" |
michael@0 | 11 | #include "nsAutoPtr.h" |
michael@0 | 12 | #include "nsString.h" |
michael@0 | 13 | |
michael@0 | 14 | class nsIDOMBlob; |
michael@0 | 15 | class nsISupports; |
michael@0 | 16 | class nsIURI; |
michael@0 | 17 | |
michael@0 | 18 | namespace mozilla { |
michael@0 | 19 | |
michael@0 | 20 | class ErrorResult; |
michael@0 | 21 | class DOMMediaStream; |
michael@0 | 22 | |
michael@0 | 23 | namespace dom { |
michael@0 | 24 | |
michael@0 | 25 | class MediaSource; |
michael@0 | 26 | class GlobalObject; |
michael@0 | 27 | struct objectURLOptions; |
michael@0 | 28 | |
michael@0 | 29 | namespace workers { |
michael@0 | 30 | class URLProxy; |
michael@0 | 31 | } |
michael@0 | 32 | |
michael@0 | 33 | class URL MOZ_FINAL : public URLSearchParamsObserver |
michael@0 | 34 | { |
michael@0 | 35 | public: |
michael@0 | 36 | NS_DECL_CYCLE_COLLECTING_ISUPPORTS |
michael@0 | 37 | NS_DECL_CYCLE_COLLECTION_CLASS(URL) |
michael@0 | 38 | |
michael@0 | 39 | URL(nsIURI* aURI); |
michael@0 | 40 | |
michael@0 | 41 | // WebIDL methods |
michael@0 | 42 | JSObject* |
michael@0 | 43 | WrapObject(JSContext* aCx); |
michael@0 | 44 | |
michael@0 | 45 | static already_AddRefed<URL> |
michael@0 | 46 | Constructor(const GlobalObject& aGlobal, const nsAString& aUrl, |
michael@0 | 47 | URL& aBase, ErrorResult& aRv); |
michael@0 | 48 | static already_AddRefed<URL> |
michael@0 | 49 | Constructor(const GlobalObject& aGlobal, const nsAString& aUrl, |
michael@0 | 50 | const nsAString& aBase, ErrorResult& aRv); |
michael@0 | 51 | |
michael@0 | 52 | static void CreateObjectURL(const GlobalObject& aGlobal, |
michael@0 | 53 | nsIDOMBlob* aBlob, |
michael@0 | 54 | const objectURLOptions& aOptions, |
michael@0 | 55 | nsString& aResult, |
michael@0 | 56 | ErrorResult& aError); |
michael@0 | 57 | static void CreateObjectURL(const GlobalObject& aGlobal, |
michael@0 | 58 | DOMMediaStream& aStream, |
michael@0 | 59 | const objectURLOptions& aOptions, |
michael@0 | 60 | nsString& aResult, |
michael@0 | 61 | ErrorResult& aError); |
michael@0 | 62 | static void CreateObjectURL(const GlobalObject& aGlobal, |
michael@0 | 63 | MediaSource& aSource, |
michael@0 | 64 | const objectURLOptions& aOptions, |
michael@0 | 65 | nsString& aResult, |
michael@0 | 66 | ErrorResult& aError); |
michael@0 | 67 | static void RevokeObjectURL(const GlobalObject& aGlobal, |
michael@0 | 68 | const nsAString& aURL); |
michael@0 | 69 | |
michael@0 | 70 | void GetHref(nsString& aHref) const; |
michael@0 | 71 | |
michael@0 | 72 | void SetHref(const nsAString& aHref, ErrorResult& aRv); |
michael@0 | 73 | |
michael@0 | 74 | void GetOrigin(nsString& aOrigin) const; |
michael@0 | 75 | |
michael@0 | 76 | void GetProtocol(nsString& aProtocol) const; |
michael@0 | 77 | |
michael@0 | 78 | void SetProtocol(const nsAString& aProtocol); |
michael@0 | 79 | |
michael@0 | 80 | void GetUsername(nsString& aUsername) const; |
michael@0 | 81 | |
michael@0 | 82 | void SetUsername(const nsAString& aUsername); |
michael@0 | 83 | |
michael@0 | 84 | void GetPassword(nsString& aPassword) const; |
michael@0 | 85 | |
michael@0 | 86 | void SetPassword(const nsAString& aPassword); |
michael@0 | 87 | |
michael@0 | 88 | void GetHost(nsString& aHost) const; |
michael@0 | 89 | |
michael@0 | 90 | void SetHost(const nsAString& aHost); |
michael@0 | 91 | |
michael@0 | 92 | void GetHostname(nsString& aHostname) const; |
michael@0 | 93 | |
michael@0 | 94 | void SetHostname(const nsAString& aHostname); |
michael@0 | 95 | |
michael@0 | 96 | void GetPort(nsString& aPort) const; |
michael@0 | 97 | |
michael@0 | 98 | void SetPort(const nsAString& aPort); |
michael@0 | 99 | |
michael@0 | 100 | void GetPathname(nsString& aPathname) const; |
michael@0 | 101 | |
michael@0 | 102 | void SetPathname(const nsAString& aPathname); |
michael@0 | 103 | |
michael@0 | 104 | void GetSearch(nsString& aRetval) const; |
michael@0 | 105 | |
michael@0 | 106 | void SetSearch(const nsAString& aArg); |
michael@0 | 107 | |
michael@0 | 108 | URLSearchParams* SearchParams(); |
michael@0 | 109 | |
michael@0 | 110 | void SetSearchParams(URLSearchParams& aSearchParams); |
michael@0 | 111 | |
michael@0 | 112 | void GetHash(nsString& aRetval) const; |
michael@0 | 113 | |
michael@0 | 114 | void SetHash(const nsAString& aArg); |
michael@0 | 115 | |
michael@0 | 116 | void Stringify(nsString& aRetval) const |
michael@0 | 117 | { |
michael@0 | 118 | GetHref(aRetval); |
michael@0 | 119 | } |
michael@0 | 120 | |
michael@0 | 121 | // URLSearchParamsObserver |
michael@0 | 122 | void URLSearchParamsUpdated() MOZ_OVERRIDE; |
michael@0 | 123 | |
michael@0 | 124 | private: |
michael@0 | 125 | nsIURI* GetURI() const |
michael@0 | 126 | { |
michael@0 | 127 | return mURI; |
michael@0 | 128 | } |
michael@0 | 129 | |
michael@0 | 130 | void CreateSearchParamsIfNeeded(); |
michael@0 | 131 | |
michael@0 | 132 | void SetSearchInternal(const nsAString& aSearch); |
michael@0 | 133 | |
michael@0 | 134 | void UpdateURLSearchParams(); |
michael@0 | 135 | |
michael@0 | 136 | static void CreateObjectURLInternal(const GlobalObject& aGlobal, |
michael@0 | 137 | nsISupports* aObject, |
michael@0 | 138 | const nsACString& aScheme, |
michael@0 | 139 | const objectURLOptions& aOptions, |
michael@0 | 140 | nsString& aResult, |
michael@0 | 141 | ErrorResult& aError); |
michael@0 | 142 | |
michael@0 | 143 | nsCOMPtr<nsIURI> mURI; |
michael@0 | 144 | nsRefPtr<URLSearchParams> mSearchParams; |
michael@0 | 145 | |
michael@0 | 146 | friend class mozilla::dom::workers::URLProxy; |
michael@0 | 147 | }; |
michael@0 | 148 | |
michael@0 | 149 | bool IsChromeURI(nsIURI* aURI); |
michael@0 | 150 | |
michael@0 | 151 | } |
michael@0 | 152 | } |
michael@0 | 153 | |
michael@0 | 154 | #endif /* URL_h___ */ |