Bug 1552815: Use setFaviconForPage() instead of replaceFaviconDataFromDataURL() r=sync-reviewers,mak

Depends on D192535

Differential Revision: https://phabricator.services.mozilla.com/D192536
This commit is contained in:
Daisuke Akatsuka
2024-05-01 05:47:08 +00:00
parent 4441b7719f
commit 588b426c7e
14 changed files with 124 additions and 242 deletions

View File

@@ -204,44 +204,30 @@ async function insertBookmark(bookmark) {
}
function setFaviconForBookmark(bookmark) {
let faviconURI;
let nullPrincipal = Services.scriptSecurityManager.createNullPrincipal({});
switch (bookmark.Favicon.protocol) {
case "data:":
// data urls must first call replaceFaviconDataFromDataURL, using a
// fake URL. Later, it's needed to call setAndFetchFaviconForPage
// with the same URL.
faviconURI = Services.io.newURI("fake-favicon-uri:" + bookmark.URL.href);
lazy.PlacesUtils.favicons.replaceFaviconDataFromDataURL(
faviconURI,
bookmark.Favicon.href,
0 /* max expiration length */,
nullPrincipal
);
break;
case "http:":
case "https:":
faviconURI = Services.io.newURI(bookmark.Favicon.href);
break;
default:
lazy.log.error(
`Bad URL given for favicon on bookmark "${bookmark.Title}"`
case "data:": {
lazy.PlacesUtils.favicons.setFaviconForPage(
bookmark.URL.URI,
Services.io.newURI("fake-favicon-uri:" + bookmark.URL.href),
bookmark.Favicon.URI
);
return;
}
case "http:":
case "https:": {
lazy.PlacesUtils.favicons.setAndFetchFaviconForPage(
bookmark.URL.URI,
bookmark.Favicon.URI,
false /* forceReload */,
lazy.PlacesUtils.favicons.FAVICON_LOAD_NON_PRIVATE,
null,
Services.scriptSecurityManager.createNullPrincipal({})
);
return;
}
}
lazy.PlacesUtils.favicons.setAndFetchFaviconForPage(
Services.io.newURI(bookmark.URL.href),
faviconURI,
false /* forceReload */,
lazy.PlacesUtils.favicons.FAVICON_LOAD_NON_PRIVATE,
null,
nullPrincipal
);
lazy.log.error(`Bad URL given for favicon on bookmark "${bookmark.Title}"`);
}
// Cache of folder names to guids to be used by the getParentGuid