2013-02-05 15:17:17 -08:00
|
|
|
/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
|
|
|
|
/* vim: set ts=2 et sw=2 tw=80: */
|
|
|
|
/* 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
|
|
|
|
* url, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_workers_url_h__
|
|
|
|
#define mozilla_dom_workers_url_h__
|
|
|
|
|
2013-11-05 06:16:25 -08:00
|
|
|
#include "Workers.h"
|
2013-02-05 15:17:17 -08:00
|
|
|
|
2013-11-05 06:16:25 -08:00
|
|
|
#include "mozilla/ErrorResult.h"
|
|
|
|
#include "mozilla/dom/BindingDeclarations.h"
|
2013-12-12 11:30:27 -08:00
|
|
|
#include "mozilla/dom/URLSearchParams.h"
|
2013-11-05 06:16:25 -08:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
struct objectURLOptions;
|
|
|
|
}
|
|
|
|
}
|
2013-02-05 15:17:17 -08:00
|
|
|
|
|
|
|
BEGIN_WORKERS_NAMESPACE
|
|
|
|
|
2013-09-04 10:07:34 -07:00
|
|
|
class URLProxy;
|
|
|
|
|
2013-12-12 11:30:27 -08:00
|
|
|
class URL MOZ_FINAL : public mozilla::dom::URLSearchParamsObserver
|
2013-02-05 15:17:17 -08:00
|
|
|
{
|
2013-12-12 11:30:27 -08:00
|
|
|
typedef mozilla::dom::URLSearchParams URLSearchParams;
|
|
|
|
|
2013-09-04 10:07:34 -07:00
|
|
|
public:
|
2013-12-12 11:30:27 -08:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS(URL)
|
2013-09-04 10:07:34 -07:00
|
|
|
|
|
|
|
URL(WorkerPrivate* aWorkerPrivate, URLProxy* aURLProxy);
|
|
|
|
~URL();
|
|
|
|
|
2013-11-05 06:16:25 -08:00
|
|
|
nsISupports*
|
|
|
|
GetParentObject() const
|
|
|
|
{
|
|
|
|
// There's only one global on a worker, so we don't need to specify.
|
|
|
|
return nullptr;
|
|
|
|
}
|
2013-09-04 10:07:34 -07:00
|
|
|
|
2013-11-05 06:16:25 -08:00
|
|
|
JSObject*
|
2013-12-12 11:30:27 -08:00
|
|
|
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope);
|
2013-09-04 10:07:34 -07:00
|
|
|
|
|
|
|
// Methods for WebIDL
|
|
|
|
|
2013-09-04 10:07:21 -07:00
|
|
|
static URL*
|
|
|
|
Constructor(const GlobalObject& aGlobal, const nsAString& aUrl,
|
|
|
|
URL& aBase, ErrorResult& aRv);
|
|
|
|
static URL*
|
|
|
|
Constructor(const GlobalObject& aGlobal, const nsAString& aUrl,
|
|
|
|
const nsAString& aBase, ErrorResult& aRv);
|
|
|
|
|
2013-02-05 15:17:17 -08:00
|
|
|
static void
|
2013-08-22 22:17:08 -07:00
|
|
|
CreateObjectURL(const GlobalObject& aGlobal,
|
2013-08-22 22:17:09 -07:00
|
|
|
JSObject* aArg, const objectURLOptions& aOptions,
|
2013-02-05 15:17:17 -08:00
|
|
|
nsString& aResult, ErrorResult& aRv);
|
|
|
|
|
2013-02-15 00:04:11 -08:00
|
|
|
static void
|
2013-08-22 22:17:08 -07:00
|
|
|
CreateObjectURL(const GlobalObject& aGlobal,
|
2013-08-22 22:17:09 -07:00
|
|
|
JSObject& aArg, const objectURLOptions& aOptions,
|
2013-02-15 00:04:11 -08:00
|
|
|
nsString& aResult, ErrorResult& aRv);
|
|
|
|
|
2013-02-05 15:17:17 -08:00
|
|
|
static void
|
2013-08-22 22:17:08 -07:00
|
|
|
RevokeObjectURL(const GlobalObject& aGlobal, const nsAString& aUrl);
|
2013-09-04 10:07:21 -07:00
|
|
|
|
|
|
|
void GetHref(nsString& aHref) const;
|
|
|
|
|
|
|
|
void SetHref(const nsAString& aHref, ErrorResult& aRv);
|
|
|
|
|
|
|
|
void GetOrigin(nsString& aOrigin) const;
|
|
|
|
|
|
|
|
void GetProtocol(nsString& aProtocol) const;
|
|
|
|
|
|
|
|
void SetProtocol(const nsAString& aProtocol);
|
|
|
|
|
|
|
|
void GetUsername(nsString& aUsername) const;
|
|
|
|
|
|
|
|
void SetUsername(const nsAString& aUsername);
|
|
|
|
|
|
|
|
void GetPassword(nsString& aPassword) const;
|
|
|
|
|
|
|
|
void SetPassword(const nsAString& aPassword);
|
|
|
|
|
|
|
|
void GetHost(nsString& aHost) const;
|
|
|
|
|
|
|
|
void SetHost(const nsAString& aHost);
|
|
|
|
|
|
|
|
void GetHostname(nsString& aHostname) const;
|
|
|
|
|
|
|
|
void SetHostname(const nsAString& aHostname);
|
|
|
|
|
|
|
|
void GetPort(nsString& aPort) const;
|
|
|
|
|
|
|
|
void SetPort(const nsAString& aPort);
|
|
|
|
|
|
|
|
void GetPathname(nsString& aPathname) const;
|
|
|
|
|
|
|
|
void SetPathname(const nsAString& aPathname);
|
|
|
|
|
|
|
|
void GetSearch(nsString& aSearch) const;
|
|
|
|
|
|
|
|
void SetSearch(const nsAString& aSearch);
|
|
|
|
|
2014-03-19 08:36:46 -07:00
|
|
|
URLSearchParams* SearchParams();
|
2013-12-12 11:30:27 -08:00
|
|
|
|
2014-03-19 08:36:46 -07:00
|
|
|
void SetSearchParams(URLSearchParams& aSearchParams);
|
2013-12-12 11:30:27 -08:00
|
|
|
|
2013-09-04 10:07:21 -07:00
|
|
|
void GetHash(nsString& aHost) const;
|
|
|
|
|
|
|
|
void SetHash(const nsAString& aHash);
|
|
|
|
|
2014-01-13 14:46:04 -08:00
|
|
|
void Stringify(nsString& aRetval) const
|
|
|
|
{
|
|
|
|
GetHref(aRetval);
|
|
|
|
}
|
|
|
|
|
2013-12-12 11:30:27 -08:00
|
|
|
// IURLSearchParamsObserver
|
|
|
|
void URLSearchParamsUpdated() MOZ_OVERRIDE;
|
|
|
|
|
2013-09-04 10:07:21 -07:00
|
|
|
private:
|
2013-09-04 10:07:34 -07:00
|
|
|
URLProxy* GetURLProxy() const
|
2013-09-04 10:07:21 -07:00
|
|
|
{
|
2013-09-04 10:07:34 -07:00
|
|
|
return mURLProxy;
|
2013-09-04 10:07:21 -07:00
|
|
|
}
|
|
|
|
|
2013-12-12 11:30:27 -08:00
|
|
|
void CreateSearchParamsIfNeeded();
|
|
|
|
|
|
|
|
void SetSearchInternal(const nsAString& aSearch);
|
|
|
|
|
2014-02-03 08:48:38 -08:00
|
|
|
void UpdateURLSearchParams();
|
|
|
|
|
2013-09-04 10:07:34 -07:00
|
|
|
WorkerPrivate* mWorkerPrivate;
|
|
|
|
nsRefPtr<URLProxy> mURLProxy;
|
2013-12-12 11:30:27 -08:00
|
|
|
nsRefPtr<URLSearchParams> mSearchParams;
|
2013-02-05 15:17:17 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
END_WORKERS_NAMESPACE
|
|
|
|
|
|
|
|
#endif /* mozilla_dom_workers_url_h__ */
|