caps/DomainPolicy.h
author Andreas Pehrson <apehrson@mozilla.com>
Tue, 12 Nov 2019 10:30:16 +0000
changeset 501560 9e3f44e87a1a2be927c7fab135653c6b86b982c9
parent 482194 97c36afd06420842387a5cfcd7073b8b8b7b123b
permissions -rw-r--r--
Bug 1594466 - Don't rewrite mimeType if fully defined. r=bryce Prior to this patch the mimetype was rewritten per the printf format "%s; codecs=%s" also when codecs were defined in the constrained mime type. The latter '%s' would be the codecs string from the mime type parser, which would have dropped any quotation marks surrounding the string. Hence 'codecs="vp8, opus"' would be considered supported (quotation marks included), but when selecting mime type in start(), it would be rewritten with quotation marks dropped. Thus looking like 'codecs=vp8,' which is not supported. This patch removes the rewrite step when the mime type is fully defined with codecs, so that the quotation marks are left in place as given to the constructor. Differential Revision: https://phabricator.services.mozilla.com/D52520

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */

#ifndef DomainPolicy_h__
#define DomainPolicy_h__

#include "nsIDomainPolicy.h"
#include "nsTHashtable.h"
#include "nsURIHashKey.h"

namespace mozilla {

namespace ipc {
class URIParams;
}  // namespace ipc

enum DomainSetChangeType {
  ACTIVATE_POLICY,
  DEACTIVATE_POLICY,
  ADD_DOMAIN,
  REMOVE_DOMAIN,
  CLEAR_DOMAINS
};

enum DomainSetType {
  NO_TYPE,
  BLOCKLIST,
  SUPER_BLOCKLIST,
  ALLOWLIST,
  SUPER_ALLOWLIST
};

class DomainSet final : public nsIDomainSet {
 public:
  NS_DECL_ISUPPORTS
  NS_DECL_NSIDOMAINSET

  explicit DomainSet(DomainSetType aType) : mType(aType) {}

  void CloneSet(nsTArray<mozilla::ipc::URIParams>* aDomains);

 protected:
  virtual ~DomainSet() {}
  nsTHashtable<nsURIHashKey> mHashTable;
  DomainSetType mType;
};

class DomainPolicy final : public nsIDomainPolicy {
 public:
  NS_DECL_ISUPPORTS
  NS_DECL_NSIDOMAINPOLICY
  DomainPolicy();

 private:
  virtual ~DomainPolicy();

  RefPtr<DomainSet> mBlocklist;
  RefPtr<DomainSet> mSuperBlocklist;
  RefPtr<DomainSet> mAllowlist;
  RefPtr<DomainSet> mSuperAllowlist;
};

} /* namespace mozilla */

#endif /* DomainPolicy_h__ */