browser/components/preferences/CookiesUtil.jsm
author Fischer.json <fischer.json@gmail.com>
Tue, 15 Nov 2016 14:49:18 +0800
changeset 442749 a213b2bf244889d2c388f8db0b3d1ab9918e6a35
permissions -rw-r--r--
Bug 1312361 - Clear all sites data from the Site Data section MozReview-Commit-ID: 7JbzO7TQaeX

"use strict";

Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");

XPCOMUtils.defineLazyModuleGetter(this, "ContextualIdentityService",
                                  "resource://gre/modules/ContextualIdentityService.jsm");

this.EXPORTED_SYMBOLS = [
  "CookiesUtil"
];

this.CookiesUtil = {

  isPrivateCookie(cookie) {
      var { userContextId } = cookie.originAttributes;
      if (!userContextId) {
        // Default identity is public.
        return false;
      }
      return !ContextualIdentityService.getIdentityFromId(userContextId).public;
  },

  makeStrippedHost(host) {
    var formattedHost = host.charAt(0) == "." ? host.substring(1, host.length) : host;
    return formattedHost.substring(0, 4) == "www." ? formattedHost.substring(4, formattedHost.length) : formattedHost;
  }
};