michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsSecureBrowserUIImpl_h_ michael@0: #define nsSecureBrowserUIImpl_h_ michael@0: michael@0: #ifdef DEBUG michael@0: #include "mozilla/Atomics.h" michael@0: #endif michael@0: #include "mozilla/ReentrantMonitor.h" michael@0: #include "nsCOMPtr.h" michael@0: #include "nsString.h" michael@0: #include "nsIDOMElement.h" michael@0: #include "nsIDOMWindow.h" michael@0: #include "nsIDOMHTMLFormElement.h" michael@0: #include "nsISecureBrowserUI.h" michael@0: #include "nsIDocShell.h" michael@0: #include "nsIDocShellTreeItem.h" michael@0: #include "nsIWebProgressListener.h" michael@0: #include "nsIFormSubmitObserver.h" michael@0: #include "nsIURI.h" michael@0: #include "nsISecurityEventSink.h" michael@0: #include "nsWeakReference.h" michael@0: #include "nsISSLStatusProvider.h" michael@0: #include "nsIAssociatedContentSecurity.h" michael@0: #include "pldhash.h" michael@0: #include "nsINetUtil.h" michael@0: michael@0: class nsISSLStatus; michael@0: class nsITransportSecurityInfo; michael@0: class nsISecurityWarningDialogs; michael@0: class nsIChannel; michael@0: class nsIInterfaceRequestor; michael@0: michael@0: #define NS_SECURE_BROWSER_UI_CID \ michael@0: { 0xcc75499a, 0x1dd1, 0x11b2, {0x8a, 0x82, 0xca, 0x41, 0x0a, 0xc9, 0x07, 0xb8}} michael@0: michael@0: michael@0: class nsSecureBrowserUIImpl : public nsISecureBrowserUI, michael@0: public nsIWebProgressListener, michael@0: public nsIFormSubmitObserver, michael@0: public nsSupportsWeakReference, michael@0: public nsISSLStatusProvider michael@0: { michael@0: public: michael@0: michael@0: nsSecureBrowserUIImpl(); michael@0: virtual ~nsSecureBrowserUIImpl(); michael@0: michael@0: NS_DECL_THREADSAFE_ISUPPORTS michael@0: NS_DECL_NSIWEBPROGRESSLISTENER michael@0: NS_DECL_NSISECUREBROWSERUI michael@0: michael@0: NS_DECL_NSISSLSTATUSPROVIDER michael@0: michael@0: NS_IMETHOD Notify(nsIDOMHTMLFormElement* formNode, nsIDOMWindow* window, michael@0: nsIURI *actionURL, bool* cancelSubmit); michael@0: NS_IMETHOD NotifyInvalidSubmit(nsIDOMHTMLFormElement* formNode, michael@0: nsIArray* invalidElements) { return NS_OK; } michael@0: michael@0: protected: michael@0: mozilla::ReentrantMonitor mReentrantMonitor; michael@0: michael@0: nsWeakPtr mWindow; michael@0: nsWeakPtr mDocShell; michael@0: nsCOMPtr mIOService; michael@0: nsCOMPtr mCurrentURI; michael@0: nsCOMPtr mToplevelEventSink; michael@0: michael@0: enum lockIconState { michael@0: lis_no_security, michael@0: lis_broken_security, michael@0: lis_mixed_security, michael@0: lis_high_security michael@0: }; michael@0: michael@0: lockIconState mNotifiedSecurityState; michael@0: bool mNotifiedToplevelIsEV; michael@0: michael@0: void ResetStateTracking(); michael@0: uint32_t mNewToplevelSecurityState; michael@0: bool mNewToplevelIsEV; michael@0: bool mNewToplevelSecurityStateKnown; michael@0: bool mIsViewSource; michael@0: michael@0: int32_t mDocumentRequestsInProgress; michael@0: int32_t mSubRequestsBrokenSecurity; michael@0: int32_t mSubRequestsNoSecurity; michael@0: bool mRestoreSubrequests; michael@0: bool mOnLocationChangeSeen; michael@0: #ifdef DEBUG michael@0: /* related to mReentrantMonitor */ michael@0: mozilla::Atomic mOnStateLocationChangeReentranceDetection; michael@0: #endif michael@0: michael@0: static already_AddRefed ExtractSecurityInfo(nsIRequest* aRequest); michael@0: nsresult MapInternalToExternalState(uint32_t* aState, lockIconState lock, bool ev); michael@0: nsresult UpdateSecurityState(nsIRequest* aRequest, bool withNewLocation, michael@0: bool withUpdateStatus); michael@0: bool UpdateMyFlags(lockIconState &warnSecurityState); michael@0: nsresult TellTheWorld(lockIconState warnSecurityState, michael@0: nsIRequest* aRequest); michael@0: michael@0: nsresult EvaluateAndUpdateSecurityState(nsIRequest* aRequest, nsISupports *info, michael@0: bool withNewLocation); michael@0: void UpdateSubrequestMembers(nsISupports *securityInfo); michael@0: michael@0: void ObtainEventSink(nsIChannel *channel, michael@0: nsCOMPtr &sink); michael@0: michael@0: nsCOMPtr mSSLStatus; michael@0: nsCOMPtr mCurrentToplevelSecurityInfo; michael@0: michael@0: nsresult CheckPost(nsIURI *formURI, nsIURI *actionURL, bool *okayToPost); michael@0: nsresult IsURLHTTPS(nsIURI* aURL, bool *value); michael@0: nsresult IsURLJavaScript(nsIURI* aURL, bool *value); michael@0: michael@0: bool ConfirmEnteringSecure(); michael@0: bool ConfirmEnteringWeak(); michael@0: bool ConfirmLeavingSecure(); michael@0: bool ConfirmMixedMode(); michael@0: bool ConfirmPostToInsecure(); michael@0: bool ConfirmPostToInsecureFromSecure(); michael@0: michael@0: bool GetNSSDialogs(nsCOMPtr & dialogs, michael@0: nsCOMPtr & window); michael@0: michael@0: PLDHashTable mTransferringRequests; michael@0: }; michael@0: michael@0: michael@0: #endif /* nsSecureBrowserUIImpl_h_ */