2015-05-03 19:32:37 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2013-01-28 11:08:21 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#ifndef URL_h___
|
|
|
|
#define URL_h___
|
|
|
|
|
2013-09-04 17:07:21 +00:00
|
|
|
#include "mozilla/dom/BindingDeclarations.h"
|
2013-12-12 19:30:27 +00:00
|
|
|
#include "mozilla/dom/URLSearchParams.h"
|
2013-09-04 17:07:21 +00:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2013-08-15 18:17:48 +00:00
|
|
|
#include "nsString.h"
|
2015-06-29 16:03:47 +00:00
|
|
|
#include "nsWrapperCache.h"
|
2013-01-28 11:08:21 +00:00
|
|
|
|
2013-08-15 18:17:48 +00:00
|
|
|
class nsISupports;
|
2013-09-04 17:07:21 +00:00
|
|
|
class nsIURI;
|
2013-01-28 11:08:21 +00:00
|
|
|
|
|
|
|
namespace mozilla {
|
2013-02-15 08:04:11 +00:00
|
|
|
|
2013-08-15 18:17:48 +00:00
|
|
|
class ErrorResult;
|
2013-02-15 08:04:11 +00:00
|
|
|
class DOMMediaStream;
|
|
|
|
|
2013-01-28 11:08:21 +00:00
|
|
|
namespace dom {
|
|
|
|
|
2015-05-12 12:09:51 +00:00
|
|
|
class Blob;
|
2013-06-21 03:15:15 +00:00
|
|
|
class MediaSource;
|
2013-08-15 18:17:48 +00:00
|
|
|
class GlobalObject;
|
|
|
|
struct objectURLOptions;
|
2013-06-21 03:15:15 +00:00
|
|
|
|
2013-09-04 17:07:34 +00:00
|
|
|
namespace workers {
|
|
|
|
class URLProxy;
|
2015-07-13 15:25:42 +00:00
|
|
|
} // namespace workers
|
2013-09-04 17:07:34 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
class URL final : public URLSearchParamsObserver
|
2015-06-29 16:03:47 +00:00
|
|
|
, public nsWrapperCache
|
2013-01-28 11:08:21 +00:00
|
|
|
{
|
2014-06-23 19:56:07 +00:00
|
|
|
~URL() {}
|
|
|
|
|
2013-01-28 11:08:21 +00:00
|
|
|
public:
|
2013-12-12 19:30:27 +00:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
2015-07-14 17:55:55 +00:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(URL)
|
2013-09-04 17:07:21 +00:00
|
|
|
|
2015-06-29 16:03:47 +00:00
|
|
|
URL(nsISupports* aParent, already_AddRefed<nsIURI> aURI);
|
2013-09-04 17:07:21 +00:00
|
|
|
|
2013-01-28 11:08:21 +00:00
|
|
|
// WebIDL methods
|
2015-06-29 16:03:47 +00:00
|
|
|
nsISupports* GetParentObject() const
|
|
|
|
{
|
|
|
|
return mParent;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual JSObject*
|
|
|
|
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2013-09-04 17:07:21 +00:00
|
|
|
|
|
|
|
static already_AddRefed<URL>
|
|
|
|
Constructor(const GlobalObject& aGlobal, const nsAString& aUrl,
|
|
|
|
URL& aBase, ErrorResult& aRv);
|
|
|
|
static already_AddRefed<URL>
|
2015-05-05 17:38:56 +00:00
|
|
|
Constructor(const GlobalObject& aGlobal, const nsAString& aUrl,
|
|
|
|
const Optional<nsAString>& aBase, ErrorResult& aRv);
|
|
|
|
// Versions of Constructor that we can share with workers and other code.
|
|
|
|
static already_AddRefed<URL>
|
2013-09-04 17:07:21 +00:00
|
|
|
Constructor(const GlobalObject& aGlobal, const nsAString& aUrl,
|
|
|
|
const nsAString& aBase, ErrorResult& aRv);
|
2015-05-05 17:38:56 +00:00
|
|
|
static already_AddRefed<URL>
|
2015-06-29 16:03:47 +00:00
|
|
|
Constructor(nsISupports* aParent, const nsAString& aUrl,
|
|
|
|
const nsAString& aBase, ErrorResult& aRv);
|
2015-05-05 17:38:56 +00:00
|
|
|
static already_AddRefed<URL>
|
2015-06-29 16:03:47 +00:00
|
|
|
Constructor(nsISupports* aParent, const nsAString& aUrl,
|
|
|
|
nsIURI* aBase, ErrorResult& aRv);
|
2013-09-04 17:07:21 +00:00
|
|
|
|
2013-08-23 05:17:08 +00:00
|
|
|
static void CreateObjectURL(const GlobalObject& aGlobal,
|
2015-05-12 12:09:51 +00:00
|
|
|
Blob& aBlob,
|
2013-01-28 11:08:21 +00:00
|
|
|
const objectURLOptions& aOptions,
|
2015-02-27 19:10:20 +00:00
|
|
|
nsAString& aResult,
|
2013-01-28 11:08:21 +00:00
|
|
|
ErrorResult& aError);
|
2012-12-03 16:07:49 +00:00
|
|
|
static void CreateObjectURL(const GlobalObject& aGlobal,
|
2013-02-15 08:04:11 +00:00
|
|
|
DOMMediaStream& aStream,
|
2013-09-04 17:07:21 +00:00
|
|
|
const objectURLOptions& aOptions,
|
2015-02-27 19:10:20 +00:00
|
|
|
nsAString& aResult,
|
2013-09-04 17:07:21 +00:00
|
|
|
ErrorResult& aError);
|
2013-06-21 03:15:15 +00:00
|
|
|
static void CreateObjectURL(const GlobalObject& aGlobal,
|
|
|
|
MediaSource& aSource,
|
|
|
|
const objectURLOptions& aOptions,
|
2015-02-27 19:10:20 +00:00
|
|
|
nsAString& aResult,
|
2013-09-04 17:07:21 +00:00
|
|
|
ErrorResult& aError);
|
2012-12-03 16:07:49 +00:00
|
|
|
static void RevokeObjectURL(const GlobalObject& aGlobal,
|
2015-05-07 07:05:43 +00:00
|
|
|
const nsAString& aURL,
|
|
|
|
ErrorResult& aRv);
|
2013-01-28 11:08:21 +00:00
|
|
|
|
2015-11-23 20:05:26 +00:00
|
|
|
void GetHref(nsAString& aHref) const;
|
2013-09-04 17:07:21 +00:00
|
|
|
|
|
|
|
void SetHref(const nsAString& aHref, ErrorResult& aRv);
|
|
|
|
|
2015-11-23 20:05:26 +00:00
|
|
|
void GetOrigin(nsAString& aOrigin) const;
|
2013-09-04 17:07:21 +00:00
|
|
|
|
2015-11-23 20:05:26 +00:00
|
|
|
void GetProtocol(nsAString& aProtocol) const;
|
2013-09-04 17:07:21 +00:00
|
|
|
|
2015-11-23 20:05:26 +00:00
|
|
|
void SetProtocol(const nsAString& aProtocol);
|
2013-09-04 17:07:21 +00:00
|
|
|
|
2015-11-23 20:05:26 +00:00
|
|
|
void GetUsername(nsAString& aUsername) const;
|
2013-09-04 17:07:21 +00:00
|
|
|
|
2015-11-23 20:05:26 +00:00
|
|
|
void SetUsername(const nsAString& aUsername);
|
2013-09-04 17:07:21 +00:00
|
|
|
|
2015-11-23 20:05:26 +00:00
|
|
|
void GetPassword(nsAString& aPassword) const;
|
2013-09-04 17:07:21 +00:00
|
|
|
|
2015-11-23 20:05:26 +00:00
|
|
|
void SetPassword(const nsAString& aPassword);
|
2013-09-04 17:07:21 +00:00
|
|
|
|
2015-11-23 20:05:26 +00:00
|
|
|
void GetHost(nsAString& aHost) const;
|
2013-09-04 17:07:21 +00:00
|
|
|
|
2015-11-23 20:05:26 +00:00
|
|
|
void SetHost(const nsAString& aHost);
|
2013-09-04 17:07:21 +00:00
|
|
|
|
2015-11-23 20:05:26 +00:00
|
|
|
void GetHostname(nsAString& aHostname) const;
|
2013-09-04 17:07:21 +00:00
|
|
|
|
2015-11-23 20:05:26 +00:00
|
|
|
void SetHostname(const nsAString& aHostname);
|
2013-09-04 17:07:21 +00:00
|
|
|
|
2015-11-23 20:05:26 +00:00
|
|
|
void GetPort(nsAString& aPort) const;
|
2013-09-04 17:07:21 +00:00
|
|
|
|
2015-11-23 20:05:26 +00:00
|
|
|
void SetPort(const nsAString& aPort);
|
2013-09-04 17:07:21 +00:00
|
|
|
|
2015-11-23 20:05:26 +00:00
|
|
|
void GetPathname(nsAString& aPathname) const;
|
2013-09-04 17:07:21 +00:00
|
|
|
|
2015-11-23 20:05:26 +00:00
|
|
|
void SetPathname(const nsAString& aPathname);
|
2013-09-04 17:07:21 +00:00
|
|
|
|
2015-11-23 20:05:26 +00:00
|
|
|
void GetSearch(nsAString& aRetval) const;
|
2013-09-04 17:07:21 +00:00
|
|
|
|
2015-11-23 20:05:26 +00:00
|
|
|
void SetSearch(const nsAString& aArg);
|
2013-09-04 17:07:21 +00:00
|
|
|
|
2014-03-19 15:36:46 +00:00
|
|
|
URLSearchParams* SearchParams();
|
2013-12-12 19:30:27 +00:00
|
|
|
|
2015-11-23 20:05:26 +00:00
|
|
|
void GetHash(nsAString& aRetval) const;
|
2013-09-04 17:07:21 +00:00
|
|
|
|
2015-11-23 20:05:26 +00:00
|
|
|
void SetHash(const nsAString& aArg);
|
2013-09-04 17:07:21 +00:00
|
|
|
|
2015-11-23 20:05:26 +00:00
|
|
|
void Stringify(nsAString& aRetval) const
|
2014-01-13 22:46:04 +00:00
|
|
|
{
|
2015-11-23 20:05:26 +00:00
|
|
|
GetHref(aRetval);
|
2014-01-13 22:46:04 +00:00
|
|
|
}
|
|
|
|
|
2013-12-12 19:30:27 +00:00
|
|
|
// URLSearchParamsObserver
|
2015-03-21 16:28:04 +00:00
|
|
|
void URLSearchParamsUpdated(URLSearchParams* aSearchParams) override;
|
2013-12-12 19:30:27 +00:00
|
|
|
|
2013-01-28 11:08:21 +00:00
|
|
|
private:
|
2013-09-04 17:07:21 +00:00
|
|
|
nsIURI* GetURI() const
|
|
|
|
{
|
|
|
|
return mURI;
|
|
|
|
}
|
|
|
|
|
2013-12-12 19:30:27 +00:00
|
|
|
void CreateSearchParamsIfNeeded();
|
|
|
|
|
|
|
|
void SetSearchInternal(const nsAString& aSearch);
|
|
|
|
|
2014-02-03 16:48:38 +00:00
|
|
|
void UpdateURLSearchParams();
|
|
|
|
|
2013-10-10 06:56:01 +00:00
|
|
|
static void CreateObjectURLInternal(const GlobalObject& aGlobal,
|
|
|
|
nsISupports* aObject,
|
2013-01-28 11:08:21 +00:00
|
|
|
const nsACString& aScheme,
|
2013-09-04 17:07:21 +00:00
|
|
|
const objectURLOptions& aOptions,
|
2015-02-27 19:10:20 +00:00
|
|
|
nsAString& aResult,
|
2013-09-04 17:07:21 +00:00
|
|
|
ErrorResult& aError);
|
|
|
|
|
2015-06-29 16:03:47 +00:00
|
|
|
nsCOMPtr<nsISupports> mParent;
|
2013-09-04 17:07:21 +00:00
|
|
|
nsCOMPtr<nsIURI> mURI;
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<URLSearchParams> mSearchParams;
|
2013-09-04 17:07:34 +00:00
|
|
|
|
|
|
|
friend class mozilla::dom::workers::URLProxy;
|
2013-01-28 11:08:21 +00:00
|
|
|
};
|
|
|
|
|
2013-11-20 16:29:03 +00:00
|
|
|
bool IsChromeURI(nsIURI* aURI);
|
|
|
|
|
2015-07-13 15:25:42 +00:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2013-01-28 11:08:21 +00:00
|
|
|
|
|
|
|
#endif /* URL_h___ */
|