2015-05-03 22:32:37 +03: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 15:08:21 +04: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/. */
|
2016-06-29 08:43:44 +03:00
|
|
|
|
|
|
|
#ifndef mozilla_dom_URL_h
|
|
|
|
#define mozilla_dom_URL_h
|
2013-01-28 15:08:21 +04:00
|
|
|
|
2013-09-04 21:07:21 +04:00
|
|
|
#include "mozilla/dom/BindingDeclarations.h"
|
2013-12-12 23:30:27 +04:00
|
|
|
#include "mozilla/dom/URLSearchParams.h"
|
2013-09-04 21:07:21 +04:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2013-08-15 22:17:48 +04:00
|
|
|
#include "nsString.h"
|
2015-06-29 19:03:47 +03:00
|
|
|
#include "nsWrapperCache.h"
|
2013-01-28 15:08:21 +04:00
|
|
|
|
2013-08-15 22:17:48 +04:00
|
|
|
class nsISupports;
|
2013-09-04 21:07:21 +04:00
|
|
|
class nsIURI;
|
2013-01-28 15:08:21 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
2013-02-15 12:04:11 +04:00
|
|
|
|
2013-08-15 22:17:48 +04:00
|
|
|
class ErrorResult;
|
2013-02-15 12:04:11 +04:00
|
|
|
class DOMMediaStream;
|
|
|
|
|
2013-01-28 15:08:21 +04:00
|
|
|
namespace dom {
|
|
|
|
|
2015-05-12 15:09:51 +03:00
|
|
|
class Blob;
|
2013-06-21 07:15:15 +04:00
|
|
|
class MediaSource;
|
2013-08-15 22:17:48 +04:00
|
|
|
class GlobalObject;
|
2013-06-21 07:15:15 +04:00
|
|
|
|
2016-06-29 08:43:44 +03:00
|
|
|
class URL : public URLSearchParamsObserver
|
|
|
|
, public nsWrapperCache
|
2013-01-28 15:08:21 +04:00
|
|
|
{
|
|
|
|
public:
|
2013-12-12 23:30:27 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
2015-07-14 20:55:55 +03:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(URL)
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2016-06-29 08:43:44 +03:00
|
|
|
URL(nsISupports* aParent)
|
|
|
|
: mParent(aParent)
|
|
|
|
{}
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2013-01-28 15:08:21 +04:00
|
|
|
// WebIDL methods
|
2015-06-29 19:03:47 +03:00
|
|
|
nsISupports* GetParentObject() const
|
|
|
|
{
|
|
|
|
return mParent;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual JSObject*
|
|
|
|
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2013-09-04 21:07:21 +04:00
|
|
|
|
|
|
|
static already_AddRefed<URL>
|
2016-06-29 08:43:44 +03:00
|
|
|
Constructor(const GlobalObject& aGlobal, const nsAString& aURL,
|
2015-05-05 20:38:56 +03:00
|
|
|
const Optional<nsAString>& aBase, ErrorResult& aRv);
|
2016-06-29 08:43:44 +03:00
|
|
|
|
|
|
|
// Helper for Fetch API
|
2015-05-05 20:38:56 +03:00
|
|
|
static already_AddRefed<URL>
|
2016-06-29 08:43:44 +03:00
|
|
|
WorkerConstructor(const GlobalObject& aGlobal, const nsAString& aURL,
|
|
|
|
const nsAString& aBase, ErrorResult& aRv);
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
CreateObjectURL(const GlobalObject& aGlobal, Blob& aBlob,
|
|
|
|
nsAString& aResult, ErrorResult& aRv);
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2016-06-29 08:43:44 +03:00
|
|
|
static void
|
|
|
|
CreateObjectURL(const GlobalObject& aGlobal, DOMMediaStream& aStream,
|
2017-02-03 10:28:52 +03:00
|
|
|
nsAString& aResult, ErrorResult& aRv);
|
2013-01-28 15:08:21 +04:00
|
|
|
|
2016-06-29 08:43:44 +03:00
|
|
|
static void
|
|
|
|
CreateObjectURL(const GlobalObject& aGlobal, MediaSource& aSource,
|
2017-02-03 10:28:52 +03:00
|
|
|
nsAString& aResult, ErrorResult& aRv);
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2016-06-29 08:43:44 +03:00
|
|
|
static void
|
|
|
|
RevokeObjectURL(const GlobalObject& aGlobal, const nsAString& aURL,
|
|
|
|
ErrorResult& aRv);
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2016-07-25 13:41:52 +03:00
|
|
|
static bool
|
|
|
|
IsValidURL(const GlobalObject& aGlobal, const nsAString& aURL,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
|
2016-06-29 08:43:44 +03:00
|
|
|
virtual void
|
|
|
|
GetHref(nsAString& aHref, ErrorResult& aRv) const = 0;
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2016-06-29 08:43:44 +03:00
|
|
|
virtual void
|
|
|
|
SetHref(const nsAString& aHref, ErrorResult& aRv) = 0;
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2016-06-29 08:43:44 +03:00
|
|
|
virtual void
|
|
|
|
GetOrigin(nsAString& aOrigin, ErrorResult& aRv) const = 0;
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2016-06-29 08:43:44 +03:00
|
|
|
virtual void
|
|
|
|
GetProtocol(nsAString& aProtocol, ErrorResult& aRv) const = 0;
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2016-06-29 08:43:44 +03:00
|
|
|
virtual void
|
|
|
|
SetProtocol(const nsAString& aProtocol, ErrorResult& aRv) = 0;
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2016-06-29 08:43:44 +03:00
|
|
|
virtual void
|
|
|
|
GetUsername(nsAString& aUsername, ErrorResult& aRv) const = 0;
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2016-06-29 08:43:44 +03:00
|
|
|
virtual void
|
|
|
|
SetUsername(const nsAString& aUsername, ErrorResult& aRv) = 0;
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2016-06-29 08:43:44 +03:00
|
|
|
virtual void
|
|
|
|
GetPassword(nsAString& aPassword, ErrorResult& aRv) const = 0;
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2016-06-29 08:43:44 +03:00
|
|
|
virtual void
|
|
|
|
SetPassword(const nsAString& aPassword, ErrorResult& aRv) = 0;
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2016-06-29 08:43:44 +03:00
|
|
|
virtual void
|
|
|
|
GetHost(nsAString& aHost, ErrorResult& aRv) const = 0;
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2016-06-29 08:43:44 +03:00
|
|
|
virtual void
|
|
|
|
SetHost(const nsAString& aHost, ErrorResult& aRv) = 0;
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2016-06-29 08:43:44 +03:00
|
|
|
virtual void
|
|
|
|
GetHostname(nsAString& aHostname, ErrorResult& aRv) const = 0;
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2016-06-29 08:43:44 +03:00
|
|
|
virtual void
|
|
|
|
SetHostname(const nsAString& aHostname, ErrorResult& aRv) = 0;
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2016-06-29 08:43:44 +03:00
|
|
|
virtual void
|
|
|
|
GetPort(nsAString& aPort, ErrorResult& aRv) const = 0;
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2016-06-29 08:43:44 +03:00
|
|
|
virtual void
|
|
|
|
SetPort(const nsAString& aPort, ErrorResult& aRv) = 0;
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2016-06-29 08:43:44 +03:00
|
|
|
virtual void
|
|
|
|
GetPathname(nsAString& aPathname, ErrorResult& aRv) const = 0;
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2016-06-29 08:43:44 +03:00
|
|
|
virtual void
|
|
|
|
SetPathname(const nsAString& aPathname, ErrorResult& aRv) = 0;
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
GetSearch(nsAString& aSearch, ErrorResult& aRv) const = 0;
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
SetSearch(const nsAString& aSearch, ErrorResult& aRv);
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2014-03-19 19:36:46 +04:00
|
|
|
URLSearchParams* SearchParams();
|
2013-12-12 23:30:27 +04:00
|
|
|
|
2016-06-29 08:43:44 +03:00
|
|
|
virtual void
|
|
|
|
GetHash(nsAString& aHost, ErrorResult& aRv) const = 0;
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2016-06-29 08:43:44 +03:00
|
|
|
virtual void
|
|
|
|
SetHash(const nsAString& aHash, ErrorResult& aRv) = 0;
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2016-06-29 08:43:44 +03:00
|
|
|
void Stringify(nsAString& aRetval, ErrorResult& aRv) const
|
2014-01-14 02:46:04 +04:00
|
|
|
{
|
2016-06-29 08:43:44 +03:00
|
|
|
GetHref(aRetval, aRv);
|
2014-01-14 02:46:04 +04:00
|
|
|
}
|
|
|
|
|
2017-02-09 15:18:40 +03:00
|
|
|
void
|
|
|
|
ToJSON(nsAString& aResult, ErrorResult& aRv) const
|
|
|
|
{
|
|
|
|
GetHref(aResult, aRv);
|
|
|
|
}
|
|
|
|
|
2013-12-12 23:30:27 +04:00
|
|
|
// URLSearchParamsObserver
|
2016-06-29 08:43:44 +03:00
|
|
|
void
|
|
|
|
URLSearchParamsUpdated(URLSearchParams* aSearchParams) override;
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2016-06-29 08:43:44 +03:00
|
|
|
protected:
|
|
|
|
virtual ~URL()
|
|
|
|
{}
|
2013-12-12 23:30:27 +04:00
|
|
|
|
2016-06-29 08:43:44 +03:00
|
|
|
virtual void
|
|
|
|
UpdateURLSearchParams() = 0;
|
2013-12-12 23:30:27 +04:00
|
|
|
|
2016-06-29 08:43:44 +03:00
|
|
|
virtual void
|
|
|
|
SetSearchInternal(const nsAString& aSearch, ErrorResult& aRv) = 0;
|
2014-02-03 20:48:38 +04:00
|
|
|
|
2016-06-29 08:43:44 +03:00
|
|
|
void CreateSearchParamsIfNeeded();
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2015-06-29 19:03:47 +03:00
|
|
|
nsCOMPtr<nsISupports> mParent;
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<URLSearchParams> mSearchParams;
|
2013-01-28 15:08:21 +04:00
|
|
|
};
|
|
|
|
|
2013-11-20 20:29:03 +04:00
|
|
|
bool IsChromeURI(nsIURI* aURI);
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2013-01-28 15:08:21 +04:00
|
|
|
|
2016-06-29 08:43:44 +03:00
|
|
|
#endif /* mozilla_dom_URL_h */
|