Bug 1526053 - Convert rule models to ES6 classes. r=miker
[gecko.git] / caps / DomainPolicy.h
bloba46ff252b25bd9b456448d4855f553b50d2c0140
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
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 DomainPolicy_h__
8 #define DomainPolicy_h__
10 #include "nsIDomainPolicy.h"
11 #include "nsTHashtable.h"
12 #include "nsURIHashKey.h"
14 namespace mozilla {
16 namespace ipc {
17 class URIParams;
18 } // namespace ipc
20 enum DomainSetChangeType {
21 ACTIVATE_POLICY,
22 DEACTIVATE_POLICY,
23 ADD_DOMAIN,
24 REMOVE_DOMAIN,
25 CLEAR_DOMAINS
28 enum DomainSetType {
29 NO_TYPE,
30 BLOCKLIST,
31 SUPER_BLOCKLIST,
32 ALLOWLIST,
33 SUPER_ALLOWLIST
36 class DomainSet final : public nsIDomainSet {
37 public:
38 NS_DECL_ISUPPORTS
39 NS_DECL_NSIDOMAINSET
41 explicit DomainSet(DomainSetType aType) : mType(aType) {}
43 void CloneSet(InfallibleTArray<mozilla::ipc::URIParams>* aDomains);
45 protected:
46 virtual ~DomainSet() {}
47 nsTHashtable<nsURIHashKey> mHashTable;
48 DomainSetType mType;
51 class DomainPolicy final : public nsIDomainPolicy {
52 public:
53 NS_DECL_ISUPPORTS
54 NS_DECL_NSIDOMAINPOLICY
55 DomainPolicy();
57 private:
58 virtual ~DomainPolicy();
60 RefPtr<DomainSet> mBlocklist;
61 RefPtr<DomainSet> mSuperBlocklist;
62 RefPtr<DomainSet> mAllowlist;
63 RefPtr<DomainSet> mSuperAllowlist;
66 } /* namespace mozilla */
68 #endif /* DomainPolicy_h__ */