Bug 1624294 - Remove underused Utils.hasRootDomain. r=mikedeboer

Differential Revision: https://phabricator.services.mozilla.com/D67839

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Dão Gottwald 2020-03-24 15:15:31 +00:00
Родитель 069676f934
Коммит 0e85250451
2 изменённых файлов: 10 добавлений и 34 удалений

Просмотреть файл

@ -239,7 +239,6 @@ XPCOMUtils.defineLazyModuleGetters(this, {
TabState: "resource:///modules/sessionstore/TabState.jsm",
TabStateCache: "resource:///modules/sessionstore/TabStateCache.jsm",
TabStateFlusher: "resource:///modules/sessionstore/TabStateFlusher.jsm",
Utils: "resource://gre/modules/sessionstore/Utils.jsm",
setTimeout: "resource://gre/modules/Timer.jsm",
});
@ -2416,13 +2415,19 @@ var SessionStoreInternal = {
/**
* On purge of domain data
* @param aData
* String domain data
* @param {string} aDomain
* The domain we want to purge data for
*/
onPurgeDomainData: function ssi_onPurgeDomainData(aData) {
onPurgeDomainData: function ssi_onPurgeDomainData(aDomain) {
// does a session history entry contain a url for the given domain?
function containsDomain(aEntry) {
if (Utils.hasRootDomain(aEntry.url, aData)) {
let host;
try {
host = Services.io.newURI(aEntry.url).host;
} catch (e) {
// The given URL probably doesn't have a host.
}
if (host && Services.eTLD.hasRootDomain(host, aDomain)) {
return true;
}
return aEntry.children && aEntry.children.some(containsDomain, this);

Просмотреть файл

@ -6,36 +6,7 @@
var EXPORTED_SYMBOLS = ["Utils"];
ChromeUtils.import("resource://gre/modules/Services.jsm", this);
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm", this);
XPCOMUtils.defineLazyServiceGetter(
this,
"eTLDService",
"@mozilla.org/network/effective-tld-service;1",
"nsIEffectiveTLDService"
);
var Utils = Object.freeze({
/**
* Returns true if the |url| passed in is part of the given root |domain|.
* For example, if |url| is "www.mozilla.org", and we pass in |domain| as
* "mozilla.org", this will return true. It would return false the other way
* around.
*/
hasRootDomain(url, domain) {
let host;
try {
host = Services.io.newURI(url).host;
} catch (e) {
// The given URL probably doesn't have a host.
return false;
}
return eTLDService.hasRootDomain(host, domain);
},
/**
* Restores frame tree |data|, starting at the given root |frame|. As the
* function recurses into descendant frames it will call cb(frame, data) for