extensions/cookie/nsCookiePermission.h
author Mozilla Releng Treescript <release+treescript@mozilla.org>
Fri, 16 Nov 2018 16:05:12 +0000
changeset 501264 f7da5f0188e1cdb842cef460b4e8bfd9af67f2fd
parent 493389 24f05c63c730fc2f2062bb40cca91b02e07ef17b
child 508163 6f3709b3878117466168c40affa7bca0b60cf75b
permissions -rw-r--r--
No bug - Tagging 7473fdd1c21c00299314892ad74b10aa5af67179 with FIREFOX_64_0b10_RELEASE a=release CLOSED TREE DONTBUILD

/* 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 nsCookiePermission_h__
#define nsCookiePermission_h__

#include "nsICookiePermission.h"
#include "nsIPermissionManager.h"
#include "nsIObserver.h"
#include "nsCOMPtr.h"
#include "mozIThirdPartyUtil.h"

class nsIPrefBranch;

class nsCookiePermission final : public nsICookiePermission
                               , public nsIObserver
{
public:
  NS_DECL_ISUPPORTS
  NS_DECL_NSICOOKIEPERMISSION
  NS_DECL_NSIOBSERVER

  // Singleton accessor
  static already_AddRefed<nsICookiePermission> GetOrCreate();
  static void Shutdown();

  bool Init();
  void PrefChanged(nsIPrefBranch *, const char *);

private:
  nsCookiePermission()
    : mCookiesLifetimePolicy(0) // ACCEPT_NORMALLY
    {}
  virtual ~nsCookiePermission() {}

  bool EnsureInitialized() { return (mPermMgr != nullptr && mThirdPartyUtil != nullptr) || Init(); };

  nsCOMPtr<nsIPermissionManager> mPermMgr;
  nsCOMPtr<mozIThirdPartyUtil> mThirdPartyUtil;

  uint8_t      mCookiesLifetimePolicy;         // pref for how long cookies are stored
};

#endif