Skip to content
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: 7 additions & 0 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,10 @@
"message": "Use High Contrast",
"description": "Use High Contrast"
},
"show_favicon": {
"message": "Show Website Icon",
"description": "Show Issuer Icon"
},
"theme": {
"message": "Theme",
"description": "Theme"
Expand Down Expand Up @@ -512,6 +516,9 @@
"permission_onedrive_cannot_revoke": {
"message": "You must disable OneDrive backup first."
},
"permission_favicon": {
"message": "Allows fetching website icons."
},
"permission_unknown_permission": {
"message": "Unknown permission. If see this message, please send a bug report."
},
Expand Down
3 changes: 2 additions & 1 deletion manifests/manifest-chrome-testing.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@
],
"optional_permissions": [
"clipboardWrite",
"contextMenus"
"contextMenus",
"favicon"
],
"optional_host_permissions": [
"https://www.google.com/",
Expand Down
3 changes: 2 additions & 1 deletion manifests/manifest-chrome.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@
],
"optional_permissions": [
"clipboardWrite",
"contextMenus"
"contextMenus",
"favicon"
],
"optional_host_permissions": [
"https://www.google.com/",
Expand Down
3 changes: 2 additions & 1 deletion manifests/manifest-edge.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
],
"optional_permissions": [
"clipboardWrite",
"contextMenus"
"contextMenus",
"favicon"
],
"optional_host_permissions": [
"https://www.google.com/",
Expand Down
14 changes: 14 additions & 0 deletions sass/popup.scss
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,20 @@ svg {
width: 80%;
text-overflow: ellipsis;
overflow: hidden;

.issuerFavicon {
vertical-align: bottom;
margin-right: 5px;
height: 16px;
width: 16px;
border-radius: 3px;
border: 1px solid transparent;
}
}

.issuerFavicon {
background-color: #fff;
border: 1px solid #fff;
}

.code {
Expand Down
23 changes: 22 additions & 1 deletion src/components/Popup/EntryComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@
<IconRedo />
</div>
<div class="issuer">
<img
class="issuerFavicon"
v-if="shouldShowFavicon && entry.issuer.split('::')[1]"
v-bind:src="getFaviconUrl(entry.issuer.split('::')[1])"
/><IconMedal
class="issuerFavicon"
v-if="shouldShowFavicon && !entry.issuer.split('::')[1]"
/>
{{
entry.issuer.split("::")[0] +
(theme === "compact" ? ` (${entry.account})` : "")
Expand Down Expand Up @@ -90,13 +98,15 @@ import { mapState } from "vuex";
import * as QRGen from "qrcode-generator";
import { OTPEntry, OTPType, CodeState, OTPAlgorithm } from "../../models/otp";
import { EntryStorage } from "../../models/storage";
import { isFirefox, isSafari } from "../../browser";
import { getCurrentTab, okToInjectContentScript } from "../../utils";

import IconMinusCircle from "../../../svg/minus-circle.svg";
import IconRedo from "../../../svg/redo.svg";
import IconQr from "../../../svg/qrcode.svg";
import IconBars from "../../../svg/bars.svg";
import IconPin from "../../../svg/pin.svg";
import IconMedal from "../../../svg/medal.svg";

const computedPrototype = [
mapState("accounts", [
Expand All @@ -110,7 +120,11 @@ const computedPrototype = [
mapState("menu", ["theme"]),
];

let computed = {};
let computed = {
shouldShowFavicon(this: any) {
return !isFirefox && !isSafari && this.$store.state.menu.showFavicon;
},
};

for (const module of computedPrototype) {
Object.assign(computed, module);
Expand Down Expand Up @@ -138,6 +152,12 @@ export default Vue.extend({
entry.type !== OTPType.steam
);
},
getFaviconUrl(u: string) {
const url = new URL(chrome.runtime.getURL("/_favicon/"));
url.searchParams.set("pageUrl", "https://" + u);
url.searchParams.set("size", "16");
return url.toString();
},
showCode(code: string) {
if (code === CodeState.Encrypted) {
return this.i18n.encrypted;
Expand Down Expand Up @@ -254,6 +274,7 @@ export default Vue.extend({
IconQr,
IconBars,
IconPin,
IconMedal,
},
});

Expand Down
21 changes: 21 additions & 0 deletions src/components/Popup/PreferencesPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@
@change="requireContextMenuPermission()"
v-if="isSupported"
/>
<a-toggle-input
:label="i18n.show_favicon"
v-model="showFavicon"
v-if="isSupported"
/>
<div class="control-group" v-show="!!defaultEncryption">
<label class="combo-label">{{ i18n.autolock }}</label>
<input
Expand Down Expand Up @@ -103,6 +108,22 @@ export default Vue.extend({
this.$store.commit("menu/setEnableContextMenu", enableContextMenu);
},
},
showFavicon: {
get(): boolean {
return this.$store.state.menu.showFavicon;
},
set(showFavicon: boolean) {
chrome.permissions.request(
{ permissions: ["favicon"] },
(granted) => {
this.$store.commit(
"menu/setShowFavicon",
granted ? showFavicon : false
);
}
);
},
},
theme: {
get(): string {
return this.$store.state.menu.theme;
Expand Down
1 change: 1 addition & 0 deletions src/definitions/module-interface.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ interface MenuState {
useAutofill: boolean;
smartFilter: boolean;
enableContextMenu: boolean;
showFavicon: boolean;
theme: string;
backupDisabled: boolean;
storageArea: "sync" | "local";
Expand Down
5 changes: 4 additions & 1 deletion src/models/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ interface UserSettingsData {
enableContextMenu?: boolean;
encodedPhrase?: string;
smartFilter?: boolean;
showFavicon?: boolean;
theme?: string;
zoom?: number;
}
Expand Down Expand Up @@ -184,7 +185,8 @@ type BooleanOption =
| "oneDriveBusiness"
| "oneDriveEncrypted"
| "oneDriveRevoked"
| "smartFilter";
| "smartFilter"
| "showFavicon";

type NumberOption = "autolock" | "lastRemindingBackupTime" | "offset" | "zoom";

Expand All @@ -202,6 +204,7 @@ function isBooleanOption(key: string): key is BooleanOption {
"oneDriveEncrypted",
"oneDriveRevoked",
"smartFilter",
"showFavicon",
].includes(key);
}

Expand Down
6 changes: 6 additions & 0 deletions src/store/Menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export class Menu implements Module {
useAutofill: UserSettings.items.autofill === true,
smartFilter: UserSettings.items.smartFilter === true,
enableContextMenu: UserSettings.items.enableContextMenu === true,
showFavicon: UserSettings.items.showFavicon === true,
theme: UserSettings.items.theme || (isSafari ? "flat" : "normal"),
autolock: Number(UserSettings.items.autolock) || 30,
backupDisabled: await ManagedStorage.get("disableBackup", false),
Expand Down Expand Up @@ -48,6 +49,11 @@ export class Menu implements Module {
UserSettings.items.enableContextMenu = enableContextMenu;
UserSettings.commitItems();
},
setShowFavicon(state: MenuState, showFavicon: boolean) {
state.showFavicon = showFavicon;
UserSettings.items.showFavicon = showFavicon;
UserSettings.commitItems();
},
setTheme(state: MenuState, theme: string) {
state.theme = theme;
UserSettings.items.theme = theme;
Expand Down
5 changes: 5 additions & 0 deletions src/store/Permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ const permissions: Permission[] = [
description: chrome.i18n.getMessage("permission_context_menus"),
revocable: true,
},
{
id: "favicon",
description: chrome.i18n.getMessage("permission_favicon"),
revocable: true,
},
{
id: "https://www.google.com/*",
description: chrome.i18n.getMessage("permission_sync_clock"),
Expand Down
1 change: 1 addition & 0 deletions svg/medal.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.