Bug 1852740: add tests for the `fetchpriority` attribute in Link headers. r=necko...
[gecko.git] / dom / base / LocationBase.h
blob58bd6f95f6369933fe6802526ff9b2198430a55a
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"
13 class nsIDocShell;
14 class nsIPrincipal;
15 class nsIURI;
16 class nsDocShellLoadState;
18 namespace mozilla {
19 class ErrorResult;
21 namespace dom {
22 class BrowsingContext;
24 //*****************************************************************************
25 // Location: Script "location" object
26 //*****************************************************************************
28 class LocationBase {
29 public:
30 // WebIDL API:
31 void Replace(const nsAString& aUrl, nsIPrincipal& aSubjectPrincipal,
32 ErrorResult& aError);
34 void SetHref(const nsAString& aHref, nsIPrincipal& aSubjectPrincipal,
35 ErrorResult& aError);
37 protected:
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,
45 ErrorResult& aRv);
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
57 // and return it.
58 already_AddRefed<nsDocShellLoadState> CheckURL(
59 nsIURI* url, nsIPrincipal& aSubjectPrincipal, ErrorResult& aRv);
62 } // namespace dom
63 } // namespace mozilla
65 #endif // mozilla_dom_LocationBase_h