|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* vim: set ts=2 sw=2 et 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/. */ |
|
6 |
|
7 #ifndef nsLocation_h__ |
|
8 #define nsLocation_h__ |
|
9 |
|
10 #include "nsIDOMLocation.h" |
|
11 #include "nsString.h" |
|
12 #include "nsIWeakReferenceUtils.h" |
|
13 #include "nsWrapperCache.h" |
|
14 #include "nsCycleCollectionParticipant.h" |
|
15 #include "js/TypeDecls.h" |
|
16 |
|
17 class nsIURI; |
|
18 class nsIDocShell; |
|
19 class nsIDocShellLoadInfo; |
|
20 |
|
21 //***************************************************************************** |
|
22 // nsLocation: Script "location" object |
|
23 //***************************************************************************** |
|
24 |
|
25 class nsLocation : public nsIDOMLocation |
|
26 , public nsWrapperCache |
|
27 { |
|
28 public: |
|
29 nsLocation(nsIDocShell *aDocShell); |
|
30 virtual ~nsLocation(); |
|
31 |
|
32 NS_DECL_CYCLE_COLLECTING_ISUPPORTS |
|
33 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsLocation) |
|
34 |
|
35 void SetDocShell(nsIDocShell *aDocShell); |
|
36 nsIDocShell *GetDocShell(); |
|
37 |
|
38 // nsIDOMLocation |
|
39 NS_DECL_NSIDOMLOCATION |
|
40 |
|
41 protected: |
|
42 // In the case of jar: uris, we sometimes want the place the jar was |
|
43 // fetched from as the URI instead of the jar: uri itself. Pass in |
|
44 // true for aGetInnermostURI when that's the case. |
|
45 nsresult GetURI(nsIURI** aURL, bool aGetInnermostURI = false); |
|
46 nsresult GetWritableURI(nsIURI** aURL); |
|
47 nsresult SetURI(nsIURI* aURL, bool aReplace = false); |
|
48 nsresult SetHrefWithBase(const nsAString& aHref, nsIURI* aBase, |
|
49 bool aReplace); |
|
50 nsresult SetHrefWithContext(JSContext* cx, const nsAString& aHref, |
|
51 bool aReplace); |
|
52 |
|
53 nsresult GetSourceBaseURL(JSContext* cx, nsIURI** sourceURL); |
|
54 nsresult CheckURL(nsIURI *url, nsIDocShellLoadInfo** aLoadInfo); |
|
55 bool CallerSubsumes(); |
|
56 |
|
57 nsString mCachedHash; |
|
58 nsWeakPtr mDocShell; |
|
59 nsWeakPtr mOuter; |
|
60 }; |
|
61 |
|
62 #endif // nsLocation_h__ |
|
63 |