Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
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/. */
6 #ifndef nsSecureBrowserUIImpl_h_
7 #define nsSecureBrowserUIImpl_h_
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"
31 class nsISSLStatus;
32 class nsITransportSecurityInfo;
33 class nsISecurityWarningDialogs;
34 class nsIChannel;
35 class nsIInterfaceRequestor;
37 #define NS_SECURE_BROWSER_UI_CID \
38 { 0xcc75499a, 0x1dd1, 0x11b2, {0x8a, 0x82, 0xca, 0x41, 0x0a, 0xc9, 0x07, 0xb8}}
41 class nsSecureBrowserUIImpl : public nsISecureBrowserUI,
42 public nsIWebProgressListener,
43 public nsIFormSubmitObserver,
44 public nsSupportsWeakReference,
45 public nsISSLStatusProvider
46 {
47 public:
49 nsSecureBrowserUIImpl();
50 virtual ~nsSecureBrowserUIImpl();
52 NS_DECL_THREADSAFE_ISUPPORTS
53 NS_DECL_NSIWEBPROGRESSLISTENER
54 NS_DECL_NSISECUREBROWSERUI
56 NS_DECL_NSISSLSTATUSPROVIDER
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; }
63 protected:
64 mozilla::ReentrantMonitor mReentrantMonitor;
66 nsWeakPtr mWindow;
67 nsWeakPtr mDocShell;
68 nsCOMPtr<nsINetUtil> mIOService;
69 nsCOMPtr<nsIURI> mCurrentURI;
70 nsCOMPtr<nsISecurityEventSink> mToplevelEventSink;
72 enum lockIconState {
73 lis_no_security,
74 lis_broken_security,
75 lis_mixed_security,
76 lis_high_security
77 };
79 lockIconState mNotifiedSecurityState;
80 bool mNotifiedToplevelIsEV;
82 void ResetStateTracking();
83 uint32_t mNewToplevelSecurityState;
84 bool mNewToplevelIsEV;
85 bool mNewToplevelSecurityStateKnown;
86 bool mIsViewSource;
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
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);
106 nsresult EvaluateAndUpdateSecurityState(nsIRequest* aRequest, nsISupports *info,
107 bool withNewLocation);
108 void UpdateSubrequestMembers(nsISupports *securityInfo);
110 void ObtainEventSink(nsIChannel *channel,
111 nsCOMPtr<nsISecurityEventSink> &sink);
113 nsCOMPtr<nsISSLStatus> mSSLStatus;
114 nsCOMPtr<nsISupports> mCurrentToplevelSecurityInfo;
116 nsresult CheckPost(nsIURI *formURI, nsIURI *actionURL, bool *okayToPost);
117 nsresult IsURLHTTPS(nsIURI* aURL, bool *value);
118 nsresult IsURLJavaScript(nsIURI* aURL, bool *value);
120 bool ConfirmEnteringSecure();
121 bool ConfirmEnteringWeak();
122 bool ConfirmLeavingSecure();
123 bool ConfirmMixedMode();
124 bool ConfirmPostToInsecure();
125 bool ConfirmPostToInsecureFromSecure();
127 bool GetNSSDialogs(nsCOMPtr<nsISecurityWarningDialogs> & dialogs,
128 nsCOMPtr<nsIInterfaceRequestor> & window);
130 PLDHashTable mTransferringRequests;
131 };
134 #endif /* nsSecureBrowserUIImpl_h_ */