1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_LocationBase_h
8 #define mozilla_dom_LocationBase_h
10 #include "mozilla/AlreadyAddRefed.h"
11 #include "nsStringFwd.h"
16 class nsDocShellLoadState
;
22 class BrowsingContext
;
24 //*****************************************************************************
25 // Location: Script "location" object
26 //*****************************************************************************
31 void Replace(const nsAString
& aUrl
, nsIPrincipal
& aSubjectPrincipal
,
34 void SetHref(const nsAString
& aHref
, nsIPrincipal
& aSubjectPrincipal
,
38 virtual BrowsingContext
* GetBrowsingContext() = 0;
39 virtual nsIDocShell
* GetDocShell() = 0;
41 void SetURI(nsIURI
* aURL
, nsIPrincipal
& aSubjectPrincipal
, ErrorResult
& aRv
,
42 bool aReplace
= false);
43 void SetHrefWithBase(const nsAString
& aHref
, nsIURI
* aBase
,
44 nsIPrincipal
& aSubjectPrincipal
, bool aReplace
,
47 // Helper for Assign/SetHref/Replace
48 void DoSetHref(const nsAString
& aHref
, nsIPrincipal
& aSubjectPrincipal
,
49 bool aReplace
, ErrorResult
& aRv
);
51 // Get the base URL we should be using for our relative URL
52 // resolution for SetHref/Assign/Replace.
53 nsIURI
* GetSourceBaseURL();
55 // Check whether it's OK to load the given url with the given subject
56 // principal, and if so construct the right nsDocShellLoadInfo for the load
58 already_AddRefed
<nsDocShellLoadState
> CheckURL(
59 nsIURI
* url
, nsIPrincipal
& aSubjectPrincipal
, ErrorResult
& aRv
);
63 } // namespace mozilla
65 #endif // mozilla_dom_LocationBase_h