2011-08-02 21:22:40 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=2 sw=2 et tw=80: */
|
2012-05-21 04:12:37 -07: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/. */
|
2011-08-02 21:22:40 -07:00
|
|
|
|
|
|
|
#ifndef nsLocation_h__
|
|
|
|
#define nsLocation_h__
|
|
|
|
|
|
|
|
#include "nsIDOMLocation.h"
|
|
|
|
#include "nsString.h"
|
2013-08-15 11:17:48 -07:00
|
|
|
#include "nsIWeakReferenceUtils.h"
|
2012-11-06 14:29:09 -08:00
|
|
|
#include "nsWrapperCache.h"
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2013-08-27 19:59:14 -07:00
|
|
|
#include "js/TypeDecls.h"
|
2014-07-11 16:31:46 -07:00
|
|
|
#include "mozilla/ErrorResult.h"
|
|
|
|
#include "nsPIDOMWindow.h"
|
2011-08-02 21:22:40 -07:00
|
|
|
|
|
|
|
class nsIURI;
|
|
|
|
class nsIDocShell;
|
|
|
|
class nsIDocShellLoadInfo;
|
|
|
|
|
|
|
|
//*****************************************************************************
|
|
|
|
// nsLocation: Script "location" object
|
|
|
|
//*****************************************************************************
|
|
|
|
|
2014-07-11 16:31:46 -07:00
|
|
|
class nsLocation MOZ_FINAL : public nsIDOMLocation
|
|
|
|
, public nsWrapperCache
|
2011-08-02 21:22:40 -07:00
|
|
|
{
|
2014-07-11 16:31:46 -07:00
|
|
|
typedef mozilla::ErrorResult ErrorResult;
|
|
|
|
|
2011-08-02 21:22:40 -07:00
|
|
|
public:
|
2014-07-11 16:31:46 -07:00
|
|
|
nsLocation(nsPIDOMWindow* aWindow, nsIDocShell *aDocShell);
|
2011-08-02 21:22:40 -07:00
|
|
|
|
2012-11-06 14:29:09 -08:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsLocation)
|
2011-08-02 21:22:40 -07:00
|
|
|
|
|
|
|
void SetDocShell(nsIDocShell *aDocShell);
|
|
|
|
nsIDocShell *GetDocShell();
|
|
|
|
|
|
|
|
// nsIDOMLocation
|
|
|
|
NS_DECL_NSIDOMLOCATION
|
|
|
|
|
2014-07-11 16:31:46 -07:00
|
|
|
// WebIDL API:
|
|
|
|
void Assign(const nsAString& aUrl, ErrorResult& aError)
|
|
|
|
{
|
|
|
|
aError = Assign(aUrl);
|
|
|
|
}
|
|
|
|
void Replace(const nsAString& aUrl, ErrorResult& aError)
|
|
|
|
{
|
|
|
|
aError = Replace(aUrl);
|
|
|
|
}
|
|
|
|
void Reload(bool aForceget, ErrorResult& aError)
|
|
|
|
{
|
|
|
|
aError = Reload(aForceget);
|
|
|
|
}
|
|
|
|
void GetHref(nsAString& aHref, ErrorResult& aError)
|
|
|
|
{
|
|
|
|
aError = GetHref(aHref);
|
|
|
|
}
|
|
|
|
void SetHref(const nsAString& aHref, ErrorResult& aError)
|
|
|
|
{
|
|
|
|
aError = SetHref(aHref);
|
|
|
|
}
|
|
|
|
void GetOrigin(nsAString& aOrigin, ErrorResult& aError)
|
|
|
|
{
|
|
|
|
aError = GetOrigin(aOrigin);
|
|
|
|
}
|
|
|
|
void GetProtocol(nsAString& aProtocol, ErrorResult& aError)
|
|
|
|
{
|
|
|
|
aError = GetProtocol(aProtocol);
|
|
|
|
}
|
|
|
|
void SetProtocol(const nsAString& aProtocol, ErrorResult& aError)
|
|
|
|
{
|
|
|
|
aError = SetProtocol(aProtocol);
|
|
|
|
}
|
|
|
|
void GetUsername(nsAString& aUsername, ErrorResult& aError);
|
|
|
|
void SetUsername(const nsAString& aUsername, ErrorResult& aError);
|
|
|
|
void GetPassword(nsAString& aPassword, ErrorResult& aError);
|
|
|
|
void SetPassword(const nsAString& aPassword, ErrorResult& aError);
|
|
|
|
void GetHost(nsAString& aHost, ErrorResult& aError)
|
|
|
|
{
|
|
|
|
aError = GetHost(aHost);
|
|
|
|
}
|
|
|
|
void SetHost(const nsAString& aHost, ErrorResult& aError)
|
|
|
|
{
|
|
|
|
aError = SetHost(aHost);
|
|
|
|
}
|
|
|
|
void GetHostname(nsAString& aHostname, ErrorResult& aError)
|
|
|
|
{
|
|
|
|
aError = GetHostname(aHostname);
|
|
|
|
}
|
|
|
|
void SetHostname(const nsAString& aHostname, ErrorResult& aError)
|
|
|
|
{
|
|
|
|
aError = SetHostname(aHostname);
|
|
|
|
}
|
|
|
|
void GetPort(nsAString& aPort, ErrorResult& aError)
|
|
|
|
{
|
|
|
|
aError = GetPort(aPort);
|
|
|
|
}
|
|
|
|
void SetPort(const nsAString& aPort, ErrorResult& aError)
|
|
|
|
{
|
|
|
|
aError = SetPort(aPort);
|
|
|
|
}
|
|
|
|
void GetPathname(nsAString& aPathname, ErrorResult& aError)
|
|
|
|
{
|
|
|
|
aError = GetPathname(aPathname);
|
|
|
|
}
|
|
|
|
void SetPathname(const nsAString& aPathname, ErrorResult& aError)
|
|
|
|
{
|
|
|
|
aError = SetPathname(aPathname);
|
|
|
|
}
|
|
|
|
void GetSearch(nsAString& aSeach, ErrorResult& aError)
|
|
|
|
{
|
|
|
|
aError = GetSearch(aSeach);
|
|
|
|
}
|
|
|
|
void SetSearch(const nsAString& aSeach, ErrorResult& aError)
|
|
|
|
{
|
|
|
|
aError = SetSearch(aSeach);
|
|
|
|
}
|
|
|
|
void GetHash(nsAString& aHash, ErrorResult& aError)
|
|
|
|
{
|
|
|
|
aError = GetHash(aHash);
|
|
|
|
}
|
|
|
|
void SetHash(const nsAString& aHash, ErrorResult& aError)
|
|
|
|
{
|
|
|
|
aError = SetHash(aHash);
|
|
|
|
}
|
|
|
|
void Stringify(nsAString& aRetval, ErrorResult& aError)
|
|
|
|
{
|
|
|
|
GetHref(aRetval, aError);
|
|
|
|
}
|
|
|
|
nsPIDOMWindow* GetParentObject() const
|
|
|
|
{
|
|
|
|
return mInnerWindow;
|
|
|
|
}
|
2014-07-11 16:32:46 -07:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
|
2014-07-11 16:31:46 -07:00
|
|
|
|
2011-08-02 21:22:40 -07:00
|
|
|
protected:
|
2014-06-23 12:56:07 -07:00
|
|
|
virtual ~nsLocation();
|
|
|
|
|
2011-08-02 21:22:40 -07:00
|
|
|
// In the case of jar: uris, we sometimes want the place the jar was
|
|
|
|
// fetched from as the URI instead of the jar: uri itself. Pass in
|
2011-10-17 07:59:28 -07:00
|
|
|
// true for aGetInnermostURI when that's the case.
|
2011-09-28 23:19:26 -07:00
|
|
|
nsresult GetURI(nsIURI** aURL, bool aGetInnermostURI = false);
|
2011-08-02 21:22:40 -07:00
|
|
|
nsresult GetWritableURI(nsIURI** aURL);
|
2011-09-28 23:19:26 -07:00
|
|
|
nsresult SetURI(nsIURI* aURL, bool aReplace = false);
|
2011-08-02 21:22:40 -07:00
|
|
|
nsresult SetHrefWithBase(const nsAString& aHref, nsIURI* aBase,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aReplace);
|
2011-08-02 21:22:40 -07:00
|
|
|
nsresult SetHrefWithContext(JSContext* cx, const nsAString& aHref,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aReplace);
|
2011-08-02 21:22:40 -07:00
|
|
|
|
|
|
|
nsresult GetSourceBaseURL(JSContext* cx, nsIURI** sourceURL);
|
|
|
|
nsresult CheckURL(nsIURI *url, nsIDocShellLoadInfo** aLoadInfo);
|
2012-10-18 16:37:14 -07:00
|
|
|
bool CallerSubsumes();
|
2011-08-02 21:22:40 -07:00
|
|
|
|
|
|
|
nsString mCachedHash;
|
2014-07-11 16:31:46 -07:00
|
|
|
nsCOMPtr<nsPIDOMWindow> mInnerWindow;
|
2011-08-02 21:22:40 -07:00
|
|
|
nsWeakPtr mDocShell;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // nsLocation_h__
|
|
|
|
|