diff options
Diffstat (limited to '')
-rw-r--r-- | toolkit/components/contentanalysis/ContentAnalysis.h | 45 |
1 files changed, 43 insertions, 2 deletions
diff --git a/toolkit/components/contentanalysis/ContentAnalysis.h b/toolkit/components/contentanalysis/ContentAnalysis.h index f2545624fd..2d8a1891b7 100644 --- a/toolkit/components/contentanalysis/ContentAnalysis.h +++ b/toolkit/components/contentanalysis/ContentAnalysis.h @@ -7,6 +7,7 @@ #define mozilla_contentanalysis_h #include "mozilla/DataMutex.h" +#include "mozilla/MoveOnlyFunction.h" #include "mozilla/MozPromise.h" #include "mozilla/dom/BrowsingContext.h" #include "mozilla/dom/MaybeDiscarded.h" @@ -24,6 +25,7 @@ # include <windows.h> #endif // XP_WIN +class nsBaseClipboard; class nsIPrincipal; class nsIPrintSettings; class ContentAnalysisTest; @@ -42,6 +44,13 @@ class ContentAnalysisResponse; namespace mozilla::contentanalysis { +enum class DefaultResult : uint8_t { + eBlock = 0, + eWarn = 1, + eAllow = 2, + eLastValue = 2 +}; + class ContentAnalysisDiagnosticInfo final : public nsIContentAnalysisDiagnosticInfo { public: @@ -149,6 +158,7 @@ class ContentAnalysis final : public nsIContentAnalysis { nsCString GetUserActionId(); void SetLastResult(nsresult aLastResult) { mLastResult = aLastResult; } +#if defined(XP_WIN) struct PrintAllowedResult final { bool mAllowed; dom::MaybeDiscarded<dom::BrowsingContext> @@ -175,13 +185,42 @@ class ContentAnalysis final : public nsIContentAnalysis { }; using PrintAllowedPromise = MozPromise<PrintAllowedResult, PrintAllowedError, true>; -#if defined(XP_WIN) MOZ_CAN_RUN_SCRIPT static RefPtr<PrintAllowedPromise> PrintToPDFToDetermineIfPrintAllowed( dom::CanonicalBrowsingContext* aBrowsingContext, nsIPrintSettings* aPrintSettings); #endif // defined(XP_WIN) + class SafeContentAnalysisResultCallback final + : public nsIContentAnalysisCallback { + public: + NS_DECL_THREADSAFE_ISUPPORTS + NS_DECL_NSICONTENTANALYSISCALLBACK + explicit SafeContentAnalysisResultCallback( + std::function<void(RefPtr<nsIContentAnalysisResult>&&)> aResolver) + : mResolver(std::move(aResolver)) {} + void Callback(RefPtr<nsIContentAnalysisResult>&& aResult) { + MOZ_ASSERT(mResolver, "Called SafeContentAnalysisResultCallback twice!"); + if (auto resolver = std::move(mResolver)) { + resolver(std::move(aResult)); + } + } + + private: + ~SafeContentAnalysisResultCallback() { + MOZ_ASSERT(!mResolver, "SafeContentAnalysisResultCallback never called!"); + } + mozilla::MoveOnlyFunction<void(RefPtr<nsIContentAnalysisResult>&&)> + mResolver; + }; + static bool CheckClipboardContentAnalysisSync( + nsBaseClipboard* aClipboard, mozilla::dom::WindowGlobalParent* aWindow, + const nsCOMPtr<nsITransferable>& trans, int32_t aClipboardType); + static void CheckClipboardContentAnalysis( + nsBaseClipboard* aClipboard, mozilla::dom::WindowGlobalParent* aWindow, + nsITransferable* aTransferable, int32_t aClipboardType, + SafeContentAnalysisResultCallback* aResolver); + private: ~ContentAnalysis(); // Remove unneeded copy constructor/assignment @@ -210,7 +249,6 @@ class ContentAnalysis final : public nsIContentAnalysis { const std::shared_ptr<content_analysis::sdk::Client>& aClient); void IssueResponse(RefPtr<ContentAnalysisResponse>& response); bool LastRequestSucceeded(); - // Did the URL filter completely handle the request or do we need to check // with the agent. enum UrlFilterResult { eCheck, eDeny, eAllow }; @@ -259,6 +297,9 @@ class ContentAnalysis final : public nsIContentAnalysis { RefPtr<ContentAnalysisResponse> mResponse; }; DataMutex<nsTHashMap<nsCString, WarnResponseData>> mWarnResponseDataMap; + void SendWarnResponse(nsCString&& aResponseRequestToken, + CallbackData aCallbackData, + RefPtr<ContentAnalysisResponse>& aResponse); std::vector<std::regex> mAllowUrlList; std::vector<std::regex> mDenyUrlList; |