|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #ifndef nsSecureBrowserUIImpl_h_ |
|
7 #define nsSecureBrowserUIImpl_h_ |
|
8 |
|
9 #ifdef DEBUG |
|
10 #include "mozilla/Atomics.h" |
|
11 #endif |
|
12 #include "mozilla/ReentrantMonitor.h" |
|
13 #include "nsCOMPtr.h" |
|
14 #include "nsString.h" |
|
15 #include "nsIDOMElement.h" |
|
16 #include "nsIDOMWindow.h" |
|
17 #include "nsIDOMHTMLFormElement.h" |
|
18 #include "nsISecureBrowserUI.h" |
|
19 #include "nsIDocShell.h" |
|
20 #include "nsIDocShellTreeItem.h" |
|
21 #include "nsIWebProgressListener.h" |
|
22 #include "nsIFormSubmitObserver.h" |
|
23 #include "nsIURI.h" |
|
24 #include "nsISecurityEventSink.h" |
|
25 #include "nsWeakReference.h" |
|
26 #include "nsISSLStatusProvider.h" |
|
27 #include "nsIAssociatedContentSecurity.h" |
|
28 #include "pldhash.h" |
|
29 #include "nsINetUtil.h" |
|
30 |
|
31 class nsISSLStatus; |
|
32 class nsITransportSecurityInfo; |
|
33 class nsISecurityWarningDialogs; |
|
34 class nsIChannel; |
|
35 class nsIInterfaceRequestor; |
|
36 |
|
37 #define NS_SECURE_BROWSER_UI_CID \ |
|
38 { 0xcc75499a, 0x1dd1, 0x11b2, {0x8a, 0x82, 0xca, 0x41, 0x0a, 0xc9, 0x07, 0xb8}} |
|
39 |
|
40 |
|
41 class nsSecureBrowserUIImpl : public nsISecureBrowserUI, |
|
42 public nsIWebProgressListener, |
|
43 public nsIFormSubmitObserver, |
|
44 public nsSupportsWeakReference, |
|
45 public nsISSLStatusProvider |
|
46 { |
|
47 public: |
|
48 |
|
49 nsSecureBrowserUIImpl(); |
|
50 virtual ~nsSecureBrowserUIImpl(); |
|
51 |
|
52 NS_DECL_THREADSAFE_ISUPPORTS |
|
53 NS_DECL_NSIWEBPROGRESSLISTENER |
|
54 NS_DECL_NSISECUREBROWSERUI |
|
55 |
|
56 NS_DECL_NSISSLSTATUSPROVIDER |
|
57 |
|
58 NS_IMETHOD Notify(nsIDOMHTMLFormElement* formNode, nsIDOMWindow* window, |
|
59 nsIURI *actionURL, bool* cancelSubmit); |
|
60 NS_IMETHOD NotifyInvalidSubmit(nsIDOMHTMLFormElement* formNode, |
|
61 nsIArray* invalidElements) { return NS_OK; } |
|
62 |
|
63 protected: |
|
64 mozilla::ReentrantMonitor mReentrantMonitor; |
|
65 |
|
66 nsWeakPtr mWindow; |
|
67 nsWeakPtr mDocShell; |
|
68 nsCOMPtr<nsINetUtil> mIOService; |
|
69 nsCOMPtr<nsIURI> mCurrentURI; |
|
70 nsCOMPtr<nsISecurityEventSink> mToplevelEventSink; |
|
71 |
|
72 enum lockIconState { |
|
73 lis_no_security, |
|
74 lis_broken_security, |
|
75 lis_mixed_security, |
|
76 lis_high_security |
|
77 }; |
|
78 |
|
79 lockIconState mNotifiedSecurityState; |
|
80 bool mNotifiedToplevelIsEV; |
|
81 |
|
82 void ResetStateTracking(); |
|
83 uint32_t mNewToplevelSecurityState; |
|
84 bool mNewToplevelIsEV; |
|
85 bool mNewToplevelSecurityStateKnown; |
|
86 bool mIsViewSource; |
|
87 |
|
88 int32_t mDocumentRequestsInProgress; |
|
89 int32_t mSubRequestsBrokenSecurity; |
|
90 int32_t mSubRequestsNoSecurity; |
|
91 bool mRestoreSubrequests; |
|
92 bool mOnLocationChangeSeen; |
|
93 #ifdef DEBUG |
|
94 /* related to mReentrantMonitor */ |
|
95 mozilla::Atomic<int32_t> mOnStateLocationChangeReentranceDetection; |
|
96 #endif |
|
97 |
|
98 static already_AddRefed<nsISupports> ExtractSecurityInfo(nsIRequest* aRequest); |
|
99 nsresult MapInternalToExternalState(uint32_t* aState, lockIconState lock, bool ev); |
|
100 nsresult UpdateSecurityState(nsIRequest* aRequest, bool withNewLocation, |
|
101 bool withUpdateStatus); |
|
102 bool UpdateMyFlags(lockIconState &warnSecurityState); |
|
103 nsresult TellTheWorld(lockIconState warnSecurityState, |
|
104 nsIRequest* aRequest); |
|
105 |
|
106 nsresult EvaluateAndUpdateSecurityState(nsIRequest* aRequest, nsISupports *info, |
|
107 bool withNewLocation); |
|
108 void UpdateSubrequestMembers(nsISupports *securityInfo); |
|
109 |
|
110 void ObtainEventSink(nsIChannel *channel, |
|
111 nsCOMPtr<nsISecurityEventSink> &sink); |
|
112 |
|
113 nsCOMPtr<nsISSLStatus> mSSLStatus; |
|
114 nsCOMPtr<nsISupports> mCurrentToplevelSecurityInfo; |
|
115 |
|
116 nsresult CheckPost(nsIURI *formURI, nsIURI *actionURL, bool *okayToPost); |
|
117 nsresult IsURLHTTPS(nsIURI* aURL, bool *value); |
|
118 nsresult IsURLJavaScript(nsIURI* aURL, bool *value); |
|
119 |
|
120 bool ConfirmEnteringSecure(); |
|
121 bool ConfirmEnteringWeak(); |
|
122 bool ConfirmLeavingSecure(); |
|
123 bool ConfirmMixedMode(); |
|
124 bool ConfirmPostToInsecure(); |
|
125 bool ConfirmPostToInsecureFromSecure(); |
|
126 |
|
127 bool GetNSSDialogs(nsCOMPtr<nsISecurityWarningDialogs> & dialogs, |
|
128 nsCOMPtr<nsIInterfaceRequestor> & window); |
|
129 |
|
130 PLDHashTable mTransferringRequests; |
|
131 }; |
|
132 |
|
133 |
|
134 #endif /* nsSecureBrowserUIImpl_h_ */ |