Back to index

lightning-sunbird  0.9+nobinonly
nsSecureBrowserUIImpl.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998-2001
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *   Hubbie Shaw
00024  *   Doug Turner <dougt@netscape.com>
00025  *   Brian Ryner <bryner@brianryner.com>
00026  *   Kai Engert <kaie@netscape.com>
00027  *
00028  * Alternatively, the contents of this file may be used under the terms of
00029  * either the GNU General Public License Version 2 or later (the "GPL"), or
00030  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00031  * in which case the provisions of the GPL or the LGPL are applicable instead
00032  * of those above. If you wish to allow use of your version of this file only
00033  * under the terms of either the GPL or the LGPL, and not to allow others to
00034  * use your version of this file under the terms of the MPL, indicate your
00035  * decision by deleting the provisions above and replace them with the notice
00036  * and other provisions required by the GPL or the LGPL. If you do not delete
00037  * the provisions above, a recipient may use your version of this file under
00038  * the terms of any one of the MPL, the GPL or the LGPL.
00039  *
00040  * ***** END LICENSE BLOCK ***** */
00041 
00042 #ifndef nsSecureBrowserUIImpl_h_
00043 #define nsSecureBrowserUIImpl_h_
00044 
00045 #include "nsCOMPtr.h"
00046 #include "nsXPIDLString.h"
00047 #include "nsString.h"
00048 #include "nsIObserver.h"
00049 #include "nsIDOMElement.h"
00050 #include "nsIDOMWindow.h"
00051 #include "nsIStringBundle.h"
00052 #include "nsISecureBrowserUI.h"
00053 #include "nsIDocShell.h"
00054 #include "nsIWebProgressListener.h"
00055 #include "nsIFormSubmitObserver.h"
00056 #include "nsIURI.h"
00057 #include "nsISecurityEventSink.h"
00058 #include "nsWeakReference.h"
00059 #include "nsISSLStatusProvider.h"
00060 #include "pldhash.h"
00061 
00062 class nsITransportSecurityInfo;
00063 class nsISecurityWarningDialogs;
00064 class nsIChannel;
00065 
00066 #define NS_SECURE_BROWSER_UI_CID \
00067 { 0xcc75499a, 0x1dd1, 0x11b2, {0x8a, 0x82, 0xca, 0x41, 0x0a, 0xc9, 0x07, 0xb8}}
00068 
00069 
00070 class nsSecureBrowserUIImpl : public nsISecureBrowserUI,
00071                               public nsIWebProgressListener,
00072                               public nsIFormSubmitObserver,
00073                               public nsIObserver,
00074                               public nsSupportsWeakReference,
00075                               public nsISSLStatusProvider
00076 {
00077 public:
00078   
00079   nsSecureBrowserUIImpl();
00080   virtual ~nsSecureBrowserUIImpl();
00081   
00082   NS_DECL_ISUPPORTS
00083   NS_DECL_NSIWEBPROGRESSLISTENER
00084   NS_DECL_NSISECUREBROWSERUI
00085   
00086   // nsIObserver
00087   NS_DECL_NSIOBSERVER
00088   NS_DECL_NSISSLSTATUSPROVIDER
00089 
00090   NS_IMETHOD Notify(nsIContent* formNode, nsIDOMWindowInternal* window,
00091                     nsIURI *actionURL, PRBool* cancelSubmit);
00092   
00093 protected:
00094   
00095   nsCOMPtr<nsIDOMWindow> mWindow;
00096   nsCOMPtr<nsIStringBundle> mStringBundle;
00097   nsCOMPtr<nsIURI> mCurrentURI;
00098   nsCOMPtr<nsISecurityEventSink> mToplevelEventSink;
00099   
00100   enum lockIconState {
00101     lis_no_security,
00102     lis_broken_security,
00103     lis_mixed_security,
00104     lis_low_security,
00105     lis_high_security
00106   };
00107 
00108   lockIconState mPreviousSecurityState;
00109 
00110   void ResetStateTracking();
00111   PRUint32 mNewToplevelSecurityState;
00112   PRPackedBool mNewToplevelSecurityStateKnown;
00113   PRPackedBool mIsViewSource;
00114 
00115   nsXPIDLString mInfoTooltip;
00116   PRInt32 mDocumentRequestsInProgress;
00117   PRInt32 mSubRequestsInProgress;
00118   PRInt32 mSubRequestsHighSecurity;
00119   PRInt32 mSubRequestsLowSecurity;
00120   PRInt32 mSubRequestsBrokenSecurity;
00121   PRInt32 mSubRequestsNoSecurity;
00122 
00123   nsresult UpdateSecurityState(nsIRequest* aRequest);
00124   nsresult EvaluateAndUpdateSecurityState(nsIRequest *aRequest);
00125   void UpdateSubrequestMembers(nsIRequest *aRequest);
00126 
00127   void ObtainEventSink(nsIChannel *channel);
00128   
00129   nsCOMPtr<nsISupports> mSSLStatus;
00130 
00131   void GetBundleString(const PRUnichar* name, nsAString &outString);
00132   
00133   nsresult CheckPost(nsIURI *formURI, nsIURI *actionURL, PRBool *okayToPost);
00134   nsresult IsURLHTTPS(nsIURI* aURL, PRBool *value);
00135   nsresult IsURLJavaScript(nsIURI* aURL, PRBool *value);
00136 
00137   PRBool ConfirmEnteringSecure();
00138   PRBool ConfirmEnteringWeak();
00139   PRBool ConfirmLeavingSecure();
00140   PRBool ConfirmMixedMode();
00141   PRBool ConfirmPostToInsecure();
00142   PRBool ConfirmPostToInsecureFromSecure();
00143 
00144   // Support functions
00145   nsresult GetNSSDialogs(nsISecurityWarningDialogs **);
00146 
00147   PLDHashTable mTransferringRequests;
00148 };
00149 
00150 
00151 #endif /* nsSecureBrowserUIImpl_h_ */