1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/base/URL.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,154 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 +#ifndef URL_h___ 1.9 +#define URL_h___ 1.10 + 1.11 +#include "mozilla/dom/BindingDeclarations.h" 1.12 +#include "mozilla/dom/URLSearchParams.h" 1.13 +#include "nsCycleCollectionParticipant.h" 1.14 +#include "nsAutoPtr.h" 1.15 +#include "nsString.h" 1.16 + 1.17 +class nsIDOMBlob; 1.18 +class nsISupports; 1.19 +class nsIURI; 1.20 + 1.21 +namespace mozilla { 1.22 + 1.23 +class ErrorResult; 1.24 +class DOMMediaStream; 1.25 + 1.26 +namespace dom { 1.27 + 1.28 +class MediaSource; 1.29 +class GlobalObject; 1.30 +struct objectURLOptions; 1.31 + 1.32 +namespace workers { 1.33 +class URLProxy; 1.34 +} 1.35 + 1.36 +class URL MOZ_FINAL : public URLSearchParamsObserver 1.37 +{ 1.38 +public: 1.39 + NS_DECL_CYCLE_COLLECTING_ISUPPORTS 1.40 + NS_DECL_CYCLE_COLLECTION_CLASS(URL) 1.41 + 1.42 + URL(nsIURI* aURI); 1.43 + 1.44 + // WebIDL methods 1.45 + JSObject* 1.46 + WrapObject(JSContext* aCx); 1.47 + 1.48 + static already_AddRefed<URL> 1.49 + Constructor(const GlobalObject& aGlobal, const nsAString& aUrl, 1.50 + URL& aBase, ErrorResult& aRv); 1.51 + static already_AddRefed<URL> 1.52 + Constructor(const GlobalObject& aGlobal, const nsAString& aUrl, 1.53 + const nsAString& aBase, ErrorResult& aRv); 1.54 + 1.55 + static void CreateObjectURL(const GlobalObject& aGlobal, 1.56 + nsIDOMBlob* aBlob, 1.57 + const objectURLOptions& aOptions, 1.58 + nsString& aResult, 1.59 + ErrorResult& aError); 1.60 + static void CreateObjectURL(const GlobalObject& aGlobal, 1.61 + DOMMediaStream& aStream, 1.62 + const objectURLOptions& aOptions, 1.63 + nsString& aResult, 1.64 + ErrorResult& aError); 1.65 + static void CreateObjectURL(const GlobalObject& aGlobal, 1.66 + MediaSource& aSource, 1.67 + const objectURLOptions& aOptions, 1.68 + nsString& aResult, 1.69 + ErrorResult& aError); 1.70 + static void RevokeObjectURL(const GlobalObject& aGlobal, 1.71 + const nsAString& aURL); 1.72 + 1.73 + void GetHref(nsString& aHref) const; 1.74 + 1.75 + void SetHref(const nsAString& aHref, ErrorResult& aRv); 1.76 + 1.77 + void GetOrigin(nsString& aOrigin) const; 1.78 + 1.79 + void GetProtocol(nsString& aProtocol) const; 1.80 + 1.81 + void SetProtocol(const nsAString& aProtocol); 1.82 + 1.83 + void GetUsername(nsString& aUsername) const; 1.84 + 1.85 + void SetUsername(const nsAString& aUsername); 1.86 + 1.87 + void GetPassword(nsString& aPassword) const; 1.88 + 1.89 + void SetPassword(const nsAString& aPassword); 1.90 + 1.91 + void GetHost(nsString& aHost) const; 1.92 + 1.93 + void SetHost(const nsAString& aHost); 1.94 + 1.95 + void GetHostname(nsString& aHostname) const; 1.96 + 1.97 + void SetHostname(const nsAString& aHostname); 1.98 + 1.99 + void GetPort(nsString& aPort) const; 1.100 + 1.101 + void SetPort(const nsAString& aPort); 1.102 + 1.103 + void GetPathname(nsString& aPathname) const; 1.104 + 1.105 + void SetPathname(const nsAString& aPathname); 1.106 + 1.107 + void GetSearch(nsString& aRetval) const; 1.108 + 1.109 + void SetSearch(const nsAString& aArg); 1.110 + 1.111 + URLSearchParams* SearchParams(); 1.112 + 1.113 + void SetSearchParams(URLSearchParams& aSearchParams); 1.114 + 1.115 + void GetHash(nsString& aRetval) const; 1.116 + 1.117 + void SetHash(const nsAString& aArg); 1.118 + 1.119 + void Stringify(nsString& aRetval) const 1.120 + { 1.121 + GetHref(aRetval); 1.122 + } 1.123 + 1.124 + // URLSearchParamsObserver 1.125 + void URLSearchParamsUpdated() MOZ_OVERRIDE; 1.126 + 1.127 +private: 1.128 + nsIURI* GetURI() const 1.129 + { 1.130 + return mURI; 1.131 + } 1.132 + 1.133 + void CreateSearchParamsIfNeeded(); 1.134 + 1.135 + void SetSearchInternal(const nsAString& aSearch); 1.136 + 1.137 + void UpdateURLSearchParams(); 1.138 + 1.139 + static void CreateObjectURLInternal(const GlobalObject& aGlobal, 1.140 + nsISupports* aObject, 1.141 + const nsACString& aScheme, 1.142 + const objectURLOptions& aOptions, 1.143 + nsString& aResult, 1.144 + ErrorResult& aError); 1.145 + 1.146 + nsCOMPtr<nsIURI> mURI; 1.147 + nsRefPtr<URLSearchParams> mSearchParams; 1.148 + 1.149 + friend class mozilla::dom::workers::URLProxy; 1.150 +}; 1.151 + 1.152 +bool IsChromeURI(nsIURI* aURI); 1.153 + 1.154 +} 1.155 +} 1.156 + 1.157 +#endif /* URL_h___ */