Bug 1688832: part 5) Add `static` `AccessibleCaretManager::GetSelection`, `::GetFrame...
[gecko.git] / netwerk / url-classifier / ChannelClassifierService.h
blob97d0646b408550bbd23cec0332e32cdabfdfd994
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set expandtab ts=2 sw=2 sts=2 cin: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_net_ChannelClassifierService_h
8 #define mozilla_net_ChannelClassifierService_h
10 #include "nsIChannelClassifierService.h"
11 #include "mozilla/net/UrlClassifierCommon.h"
13 namespace mozilla {
14 namespace net {
16 enum class ChannelBlockDecision {
17 Blocked,
18 Unblocked,
19 Allowed,
22 class UrlClassifierBlockedChannel final
23 : public nsIUrlClassifierBlockedChannel {
24 public:
25 NS_DECL_ISUPPORTS
26 NS_DECL_NSIURLCLASSIFIERBLOCKEDCHANNEL
28 explicit UrlClassifierBlockedChannel(nsIChannel* aChannel);
30 bool IsUnblocked() const {
31 return mDecision != ChannelBlockDecision::Blocked;
34 ChannelBlockDecision GetDecision() { return mDecision; };
36 void SetReason(const nsACString& aFeatureName, const nsACString& aTableName);
38 protected:
39 ~UrlClassifierBlockedChannel() = default;
41 private:
42 nsCOMPtr<nsIChannel> mChannel;
43 ChannelBlockDecision mDecision;
44 uint8_t mReason;
45 nsCString mTables;
48 class ChannelClassifierService final : public nsIChannelClassifierService {
49 public:
50 NS_DECL_ISUPPORTS
51 NS_DECL_NSICHANNELCLASSIFIERSERVICE
53 friend class UrlClassifierBlockedChannel;
55 static already_AddRefed<nsIChannelClassifierService> GetSingleton();
57 static ChannelBlockDecision OnBeforeBlockChannel(
58 nsIChannel* aChannel, const nsACString& aFeatureName,
59 const nsACString& aTableName);
61 nsresult OnBeforeBlockChannel(nsIChannel* aChannel,
62 const nsACString& aFeatureName,
63 const nsACString& aTableName,
64 ChannelBlockDecision& aDecision);
66 bool HasListener() const { return !mListeners.IsEmpty(); }
68 private:
69 ChannelClassifierService();
70 ~ChannelClassifierService() = default;
72 nsTArray<nsCOMPtr<nsIObserver>> mListeners;
75 } // namespace net
76 } // namespace mozilla
78 #endif // mozilla_net_ChannelClassifierService_h