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