Back to index

lightning-sunbird  0.9+nobinonly
nsMsgContentPolicy.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) 2001
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *   Scott MacGregor <scott@scott-macgregor.org>
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either of the GNU General Public License Version 2 or later (the "GPL"),
00027  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK ***** */
00038 
00039 /**********************************************************************************
00040  * nsMsgContentPolicy enforces the specified content policy on images, js, plugins, etc.
00041  * This is the class used to determine what elements in a message should be loaded.
00042  *
00043  * nsMsgCookiePolicy enforces our cookie policy for mail and RSS messages. 
00044  ***********************************************************************************/
00045 
00046 #ifndef _nsMsgContentPolicy_H_
00047 #define _nsMsgContentPolicy_H_
00048 
00049 #include "nsIContentPolicy.h"
00050 #include "nsIObserver.h"
00051 #include "nsWeakReference.h"
00052 #include "nsString.h"
00053 
00054 #include "nsICookiePermission.h" 
00055 
00056 /* DBFCFDF0-4489-4faa-8122-190FD1EFA16C */
00057 #define NS_MSGCONTENTPOLICY_CID \
00058 { 0xdbfcfdf0, 0x4489, 0x4faa, { 0x81, 0x22, 0x19, 0xf, 0xd1, 0xef, 0xa1, 0x6c } }
00059 
00060 #define NS_MSGCONTENTPOLICY_CONTRACTID "@mozilla.org/messenger/content-policy;1"
00061 
00062 class nsIMsgDBHdr;
00063 class nsIDocShell;
00064 
00065 class nsMsgContentPolicy : public nsIContentPolicy,
00066                            public nsIObserver,
00067                            public nsSupportsWeakReference
00068 {
00069 public:
00070   nsMsgContentPolicy();
00071   virtual ~nsMsgContentPolicy();
00072 
00073   nsresult Init();
00074     
00075   NS_DECL_ISUPPORTS
00076   NS_DECL_NSICONTENTPOLICY
00077   NS_DECL_NSIOBSERVER
00078 
00079 protected:
00080   PRBool   mBlockRemoteImages;
00081   PRBool   mAllowPlugins;
00082   nsAdoptingCString  mTrustedMailDomains;
00083 
00084   PRBool IsTrustedDomain(nsIURI * aContentLocation);
00085   nsresult AllowRemoteContentForSender(nsIMsgDBHdr * aMsgHdr, PRBool * aAllowForSender);
00086   nsresult AllowRemoteContentForMsgHdr(nsIMsgDBHdr * aMsgHdr, nsIURI * aRequestingLocation, nsIURI * aContentLocation, PRInt16 *aDecision);
00087   nsresult MailShouldLoad(nsIURI * aRequestingLocation, nsIURI * aContentLocation, PRInt16 * aDecision);
00088   nsresult ComposeShouldLoad(nsIDocShell * aRootDocShell, nsISupports *aRequestingContext, 
00089                              nsIURI * aContentLocation, PRInt16 * aDecision);
00090   
00091   nsresult GetRootDocShellForContext(nsISupports * aRequestingContext, nsIDocShell ** aDocShell);
00092   nsresult GetMessagePaneURI(nsIDocShell * aRootDocShell, nsIURI ** aURI);
00093 };
00094 
00095 /* 2C4B5CC1-8C0F-4080-92A7-D133CC30F43B */
00096 #define NS_MSGCOOKIEPOLICY_CID \
00097 { 0x2c4b5cc1, 0x8c0f, 0x4080, { 0x92, 0xa7, 0xd1, 0x33, 0xcc, 0x30, 0xf4, 0x3b } }
00098 
00099 
00100 class nsMsgCookiePolicy : public nsICookiePermission
00101 {
00102 public:
00103   NS_DECL_ISUPPORTS
00104   NS_DECL_NSICOOKIEPERMISSION
00105 
00106   nsMsgCookiePolicy() {}
00107 
00108   virtual ~nsMsgCookiePolicy() {}
00109 };
00110 
00111 #endif // _nsMsgContentPolicy_H_