DomainPolicy.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef DomainPolicy_h__
  6. #define DomainPolicy_h__
  7. #include "nsIDomainPolicy.h"
  8. #include "nsTHashtable.h"
  9. #include "nsURIHashKey.h"
  10. namespace mozilla {
  11. namespace ipc {
  12. class URIParams;
  13. } // namespace ipc
  14. enum DomainSetChangeType{
  15. ACTIVATE_POLICY,
  16. DEACTIVATE_POLICY,
  17. ADD_DOMAIN,
  18. REMOVE_DOMAIN,
  19. CLEAR_DOMAINS
  20. };
  21. enum DomainSetType{
  22. NO_TYPE,
  23. BLACKLIST,
  24. SUPER_BLACKLIST,
  25. WHITELIST,
  26. SUPER_WHITELIST
  27. };
  28. class DomainSet final : public nsIDomainSet
  29. {
  30. public:
  31. NS_DECL_ISUPPORTS
  32. NS_DECL_NSIDOMAINSET
  33. explicit DomainSet(DomainSetType aType)
  34. : mType(aType)
  35. {}
  36. void CloneSet(InfallibleTArray<mozilla::ipc::URIParams>* aDomains);
  37. protected:
  38. virtual ~DomainSet() {}
  39. nsTHashtable<nsURIHashKey> mHashTable;
  40. DomainSetType mType;
  41. };
  42. class DomainPolicy final : public nsIDomainPolicy
  43. {
  44. public:
  45. NS_DECL_ISUPPORTS
  46. NS_DECL_NSIDOMAINPOLICY
  47. DomainPolicy();
  48. private:
  49. virtual ~DomainPolicy();
  50. RefPtr<DomainSet> mBlacklist;
  51. RefPtr<DomainSet> mSuperBlacklist;
  52. RefPtr<DomainSet> mWhitelist;
  53. RefPtr<DomainSet> mSuperWhitelist;
  54. };
  55. } /* namespace mozilla */
  56. #endif /* DomainPolicy_h__ */