Bug 1700051: part 35) Reduce accessibility of `mSoftText.mDOMMapping` to `private...
[gecko.git] / dom / base / Location.h
blobce472b318d04be6eda04b9371817e3e3dc5f09cc
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_Location_h
8 #define mozilla_dom_Location_h
10 #include "js/TypeDecls.h"
11 #include "mozilla/ErrorResult.h"
12 #include "mozilla/dom/BrowsingContext.h"
13 #include "mozilla/dom/LocationBase.h"
14 #include "nsCycleCollectionParticipant.h"
15 #include "nsString.h"
16 #include "nsWrapperCache.h"
18 class nsIDocShell;
19 class nsIPrincipal;
20 class nsIURI;
21 class nsPIDOMWindowInner;
23 namespace mozilla {
24 namespace dom {
26 //*****************************************************************************
27 // Location: Script "location" object
28 //*****************************************************************************
30 class Location final : public nsISupports,
31 public LocationBase,
32 public nsWrapperCache {
33 public:
34 typedef BrowsingContext::LocationProxy RemoteProxy;
36 Location(nsPIDOMWindowInner* aWindow, BrowsingContext* aBrowsingContext);
38 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
39 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Location)
41 // WebIDL API:
42 void Assign(const nsAString& aUrl, nsIPrincipal& aSubjectPrincipal,
43 ErrorResult& aError);
45 void Reload(bool aForceget, nsIPrincipal& aSubjectPrincipal,
46 ErrorResult& aError) {
47 if (!CallerSubsumes(&aSubjectPrincipal)) {
48 aError.Throw(NS_ERROR_DOM_SECURITY_ERR);
49 return;
52 Reload(aForceget, aError);
55 void GetHref(nsAString& aHref, nsIPrincipal& aSubjectPrincipal,
56 ErrorResult& aError) {
57 if (!CallerSubsumes(&aSubjectPrincipal)) {
58 aError.Throw(NS_ERROR_DOM_SECURITY_ERR);
59 return;
62 aError = GetHref(aHref);
65 void GetOrigin(nsAString& aOrigin, nsIPrincipal& aSubjectPrincipal,
66 ErrorResult& aError);
68 void GetProtocol(nsAString& aProtocol, nsIPrincipal& aSubjectPrincipal,
69 ErrorResult& aError);
71 void SetProtocol(const nsAString& aProtocol, nsIPrincipal& aSubjectPrincipal,
72 ErrorResult& aError);
74 void GetHost(nsAString& aHost, nsIPrincipal& aSubjectPrincipal,
75 ErrorResult& aError);
77 void SetHost(const nsAString& aHost, nsIPrincipal& aSubjectPrincipal,
78 ErrorResult& aError);
80 void GetHostname(nsAString& aHostname, nsIPrincipal& aSubjectPrincipal,
81 ErrorResult& aError);
83 void SetHostname(const nsAString& aHostname, nsIPrincipal& aSubjectPrincipal,
84 ErrorResult& aError);
86 void GetPort(nsAString& aPort, nsIPrincipal& aSubjectPrincipal,
87 ErrorResult& aError);
89 void SetPort(const nsAString& aPort, nsIPrincipal& aSubjectPrincipal,
90 ErrorResult& aError);
92 void GetPathname(nsAString& aPathname, nsIPrincipal& aSubjectPrincipal,
93 ErrorResult& aError);
95 void SetPathname(const nsAString& aPathname, nsIPrincipal& aSubjectPrincipal,
96 ErrorResult& aError);
98 void GetSearch(nsAString& aSeach, nsIPrincipal& aSubjectPrincipal,
99 ErrorResult& aError);
101 void SetSearch(const nsAString& aSeach, nsIPrincipal& aSubjectPrincipal,
102 ErrorResult& aError);
104 void GetHash(nsAString& aHash, nsIPrincipal& aSubjectPrincipal,
105 ErrorResult& aError);
107 void SetHash(const nsAString& aHash, nsIPrincipal& aSubjectPrincipal,
108 ErrorResult& aError);
110 nsPIDOMWindowInner* GetParentObject() const { return mInnerWindow; }
112 virtual JSObject* WrapObject(JSContext* aCx,
113 JS::Handle<JSObject*> aGivenProto) override;
115 // Non WebIDL methods:
117 nsresult GetHref(nsAString& aHref);
119 nsresult ToString(nsAString& aString) { return GetHref(aString); }
121 void Reload(bool aForceget, ErrorResult& aRv);
123 protected:
124 virtual ~Location();
126 BrowsingContext* GetBrowsingContext() override;
127 already_AddRefed<nsIDocShell> GetDocShell() override;
129 // In the case of jar: uris, we sometimes want the place the jar was
130 // fetched from as the URI instead of the jar: uri itself. Pass in
131 // true for aGetInnermostURI when that's the case.
132 // Note, this method can return NS_OK with a null value for aURL. This happens
133 // if the docShell is null.
134 nsresult GetURI(nsIURI** aURL, bool aGetInnermostURI = false);
136 bool CallerSubsumes(nsIPrincipal* aSubjectPrincipal);
138 nsString mCachedHash;
139 nsCOMPtr<nsPIDOMWindowInner> mInnerWindow;
140 uint64_t mBrowsingContextId = 0;
143 } // namespace dom
144 } // namespace mozilla
146 #endif // mozilla_dom_Location_h