|
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
|
2 * |
|
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 nsDSURIContentListener_h__ |
|
8 #define nsDSURIContentListener_h__ |
|
9 |
|
10 #include "nsCOMPtr.h" |
|
11 #include "nsIURIContentListener.h" |
|
12 #include "nsWeakReference.h" |
|
13 |
|
14 class nsDocShell; |
|
15 class nsIWebNavigationInfo; |
|
16 class nsIHttpChannel; |
|
17 class nsAString; |
|
18 |
|
19 class nsDSURIContentListener : |
|
20 public nsIURIContentListener, |
|
21 public nsSupportsWeakReference |
|
22 |
|
23 { |
|
24 friend class nsDocShell; |
|
25 public: |
|
26 NS_DECL_THREADSAFE_ISUPPORTS |
|
27 NS_DECL_NSIURICONTENTLISTENER |
|
28 |
|
29 nsresult Init(); |
|
30 |
|
31 protected: |
|
32 nsDSURIContentListener(nsDocShell* aDocShell); |
|
33 virtual ~nsDSURIContentListener(); |
|
34 |
|
35 void DropDocShellreference() { |
|
36 mDocShell = nullptr; |
|
37 } |
|
38 |
|
39 // Determine if X-Frame-Options allows content to be framed |
|
40 // as a subdocument |
|
41 bool CheckFrameOptions(nsIRequest* request); |
|
42 bool CheckOneFrameOptionsPolicy(nsIHttpChannel* httpChannel, |
|
43 const nsAString& policy); |
|
44 |
|
45 enum XFOHeader { |
|
46 eDENY, |
|
47 eSAMEORIGIN, |
|
48 eALLOWFROM |
|
49 }; |
|
50 |
|
51 void ReportXFOViolation(nsIDocShellTreeItem* aTopDocShellItem, |
|
52 nsIURI* aThisURI, |
|
53 XFOHeader aHeader); |
|
54 protected: |
|
55 nsDocShell* mDocShell; |
|
56 |
|
57 // Store the parent listener in either of these depending on |
|
58 // if supports weak references or not. Proper weak refs are |
|
59 // preferred and encouraged! |
|
60 nsWeakPtr mWeakParentContentListener; |
|
61 nsIURIContentListener* mParentContentListener; |
|
62 |
|
63 nsCOMPtr<nsIWebNavigationInfo> mNavInfo; |
|
64 }; |
|
65 |
|
66 #endif /* nsDSURIContentListener_h__ */ |