diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /comm/mailnews/base/src/nsMsgContentPolicy.h | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'comm/mailnews/base/src/nsMsgContentPolicy.h')
-rw-r--r-- | comm/mailnews/base/src/nsMsgContentPolicy.h | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/comm/mailnews/base/src/nsMsgContentPolicy.h b/comm/mailnews/base/src/nsMsgContentPolicy.h new file mode 100644 index 0000000000..e6d3d10e79 --- /dev/null +++ b/comm/mailnews/base/src/nsMsgContentPolicy.h @@ -0,0 +1,95 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/****************************************************************************** + * nsMsgContentPolicy enforces the specified content policy on images, js, + * plugins, etc. This is the class used to determine what elements in a message + * should be loaded. + * + * nsMsgCookiePolicy enforces our cookie policy for mail and RSS messages. + ******************************************************************************/ + +#ifndef _nsMsgContentPolicy_H_ +#define _nsMsgContentPolicy_H_ + +#include "nsIContentPolicy.h" +#include "nsIObserver.h" +#include "nsWeakReference.h" +#include "nsString.h" +#include "nsIMsgMailNewsUrl.h" +#include "nsIMsgCompose.h" +#include "nsIDocShell.h" +#include "nsIPermissionManager.h" +#include "nsIMsgContentPolicy.h" +#include "nsTArray.h" + +/* DBFCFDF0-4489-4faa-8122-190FD1EFA16C */ +#define NS_MSGCONTENTPOLICY_CID \ + { \ + 0xdbfcfdf0, 0x4489, 0x4faa, { \ + 0x81, 0x22, 0x19, 0xf, 0xd1, 0xef, 0xa1, 0x6c \ + } \ + } + +#define NS_MSGCONTENTPOLICY_CONTRACTID "@mozilla.org/messenger/content-policy;1" + +class nsIMsgDBHdr; +class nsIDocShell; + +class nsMsgContentPolicy : public nsIContentPolicy, + public nsIObserver, + public nsIMsgContentPolicy, + public nsSupportsWeakReference { + public: + nsMsgContentPolicy(); + + nsresult Init(); + + NS_DECL_ISUPPORTS + NS_DECL_NSICONTENTPOLICY + NS_DECL_NSIOBSERVER + NS_DECL_NSIMSGCONTENTPOLICY + + protected: + virtual ~nsMsgContentPolicy(); + + bool mBlockRemoteImages; + nsCString mTrustedMailDomains; + nsCOMPtr<nsIPermissionManager> mPermissionManager; + + bool IsTrustedDomain(nsIURI* aContentLocation); + bool IsSafeRequestingLocation(nsIURI* aRequestingLocation); + bool IsExposedProtocol(nsIURI* aContentLocation); + bool IsExposedChromeProtocol(nsIURI* aContentLocation); + bool ShouldBlockUnexposedProtocol(nsIURI* aContentLocation); + + bool ShouldAcceptRemoteContentForSender(nsIMsgDBHdr* aMsgHdr); + int16_t ShouldAcceptRemoteContentForMsgHdr(nsIMsgDBHdr* aMsgHdr, + nsIURI* aRequestingLocation, + nsIURI* aContentLocation); + void NotifyContentWasBlocked(uint64_t aBrowsingContextId, + nsIURI* aContentLocation); + void ShouldAcceptContentForPotentialMsg(uint64_t aBrowsingContextId, + nsIURI* aOriginatorLocation, + nsIURI* aContentLocation, + int16_t* aDecision); + void ComposeShouldLoad(nsIMsgCompose* aMsgCompose, + nsISupports* aRequestingContext, + nsIURI* aOriginatorLocation, nsIURI* aContentLocation, + int16_t* aDecision); + already_AddRefed<nsIMsgCompose> GetMsgComposeForBrowsingContext( + mozilla::dom::BrowsingContext* aRequestingContext); + + nsresult GetRootDocShellForContext(nsISupports* aRequestingContext, + nsIDocShell** aDocShell); + nsresult GetOriginatingURIForContext(nsISupports* aRequestingContext, + nsIURI** aURI); + nsresult SetDisableItemsOnMailNewsUrlDocshells(nsIURI* aContentLocation, + nsILoadInfo* aLoadInfo); + + nsTArray<nsCString> mCustomExposedProtocols; +}; + +#endif // _nsMsgContentPolicy_H_ |