/* 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/. */

include protocol PNecko;
include NeckoChannelParams;

using mozilla::OriginAttributes from "mozilla/ipc/BackgroundUtils.h";
[RefCounted] using class nsIURI from "mozilla/ipc/URIUtils.h";
using struct mozilla::void_t from "ipc/IPCMessageUtils.h";
using struct nsID from "nsID.h";

namespace mozilla {
namespace net {

/**
 * PCookieService
 *
 * Provides IPDL methods for setting and getting cookies. These are stored on
 * and managed by the parent; the child process goes through the parent for
 * all cookie operations. Lower-level programmatic operations (i.e. those
 * provided by the nsICookieManager interface) are not
 * currently implemented and requesting these interfaces in the child will fail.
 *
 * @see nsICookieService
 * @see nsICookiePermission
 */

[ManualDealloc, NestedUpTo=inside_cpow] sync protocol PCookieService
{
  manager PNecko;

parent:
  [Nested=inside_cpow] async SetCookies(nsCString baseDomain,
                                        OriginAttributes attrs,
                                        nullable nsIURI host,
                                        bool isThirdParty,
                                        CookieStruct[] cookies);

  async GetCookieList(nullable nsIURI host,
                        bool isForeign,
                        bool isThirdPartyTrackingResource,
                        bool isThirdPartySocialTrackingResource,
                        bool firstPartyStorageAccessPermissionGranted,
                        uint32_t rejectedReason,
                        bool isSafeTopLevelNav,
                        bool isSameSiteForeign,
                        bool hadCrossSiteRedirects,
                        OriginAttributes[] attrsList)
                        returns (CookieStructTable[] cookies);

  async __delete__();

child:
  async TrackCookiesLoad(CookieStructTable[] cookiesListTable);

  async RemoveCookie(CookieStruct cookie,
                     OriginAttributes attrs,
                     nsID? operationId);

  async RemoveBatchDeletedCookies(CookieStruct[] cookiesList,
                                  OriginAttributes[] attrsList);

  async RemoveAll();

  async AddCookie(CookieStruct cookie,
                  OriginAttributes attrs,
                  nsID? operationId);
};

}
}

