Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ feat(completions): add tab favicon for better image quality #4533

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions background_scripts/completion.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class Suggestion {
// The generated HTML string for showing this suggestion in the Vomnibar.
html;
searchUrl;
favIconUrl;

constructor(options) {
Object.seal(this);
Expand Down Expand Up @@ -77,8 +78,9 @@ class Suggestion {
if (this.description === "tab" && !BgUtils.isFirefox()) {
const faviconUrl = new URL(chrome.runtime.getURL("/_favicon/"));
faviconUrl.searchParams.set("pageUrl", this.url);
faviconUrl.searchParams.set("size", "16");
faviconHtml = `<img class="vomnibarIcon" src="${faviconUrl.toString()}" />`;
faviconUrl.searchParams.set("size", "64");
const src = this.favIconUrl?.startsWith("http") ? this.favIconUrl : faviconUrl.toString();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this.faviconUrl is valid and present, then for clarity, we shouldn't bother constructing and initializing the faviconUrl URL object in the preceding lines.

What caused you to add a startsWith("http") check here?

faviconHtml = `<img class="vomnibarIcon" src="${src}" />`;
}
if (this.isCustomSearch) {
this.html = `\
Expand Down Expand Up @@ -489,6 +491,7 @@ class TabCompleter {
queryTerms,
description: "tab",
url: tab.url,
favIconUrl: tab.favIconUrl,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems we're passing this along because tab.favIconUrl is sometimes a higher quality image than what can be fetched from chrome's favicon API? Is so, we should mention that here in a comment, with a reference. This is the Chromium bug I found about it, and some related discussion.

title: tab.title,
tabId: tab.id,
deDuplicate: false,
Expand Down
1 change: 1 addition & 0 deletions pages/vomnibar.css
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
#vomnibar li .vomnibarIcon {
padding: 0 13px 0 6px;
vertical-align: bottom;
width: 16px;
}

#vomnibar li .vomnibarSource {
Expand Down