mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 16:23:44 +00:00
[PM-6978] Add menubar option for toggling hardware acceleration (#8424)
* Add menubar option for toggling hardware acceleration * Fix paths to service * Fix last path
This commit is contained in:
@@ -2687,5 +2687,14 @@
|
|||||||
"commonImportFormats": {
|
"commonImportFormats": {
|
||||||
"message": "Common formats",
|
"message": "Common formats",
|
||||||
"description": "Label indicating the most common import formats"
|
"description": "Label indicating the most common import formats"
|
||||||
|
},
|
||||||
|
"troubleshooting": {
|
||||||
|
"message": "Troubleshooting"
|
||||||
|
},
|
||||||
|
"disableHardwareAccelerationRestart": {
|
||||||
|
"message": "Disable hardware acceleration and restart"
|
||||||
|
},
|
||||||
|
"enableHardwareAccelerationRestart": {
|
||||||
|
"message": "Enable hardware acceleration and restart"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -207,6 +207,7 @@ export class Main {
|
|||||||
this.environmentService,
|
this.environmentService,
|
||||||
this.windowMain,
|
this.windowMain,
|
||||||
this.updaterMain,
|
this.updaterMain,
|
||||||
|
this.desktopSettingsService,
|
||||||
);
|
);
|
||||||
|
|
||||||
this.biometricsService = new BiometricsService(
|
this.biometricsService = new BiometricsService(
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import { shell, MenuItemConstructorOptions } from "electron";
|
import { shell, MenuItemConstructorOptions, app } from "electron";
|
||||||
|
|
||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
|
|
||||||
|
import { DesktopSettingsService } from "../../platform/services/desktop-settings.service";
|
||||||
import { isMacAppStore, isWindowsStore } from "../../utils";
|
import { isMacAppStore, isWindowsStore } from "../../utils";
|
||||||
|
|
||||||
import { AboutMenu } from "./menu.about";
|
import { AboutMenu } from "./menu.about";
|
||||||
@@ -26,23 +27,23 @@ export class HelpMenu implements IMenubarMenu {
|
|||||||
this.separator,
|
this.separator,
|
||||||
this.getMobileApp,
|
this.getMobileApp,
|
||||||
this.getBrowserExtension,
|
this.getBrowserExtension,
|
||||||
|
this.separator,
|
||||||
|
this.troubleshooting,
|
||||||
];
|
];
|
||||||
|
|
||||||
if (this._aboutMenu != null) {
|
if (this.aboutMenu != null) {
|
||||||
items.push(...this._aboutMenu.items);
|
items.push(...this.aboutMenu.items);
|
||||||
}
|
}
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly _i18nService: I18nService;
|
constructor(
|
||||||
private readonly _webVaultUrl: string;
|
private i18nService: I18nService,
|
||||||
private readonly _aboutMenu: AboutMenu;
|
private desktopSettingsService: DesktopSettingsService,
|
||||||
|
private webVaultUrl: string,
|
||||||
constructor(i18nService: I18nService, webVaultUrl: string, aboutMenu: AboutMenu) {
|
private hardwareAccelerationEnabled: boolean,
|
||||||
this._i18nService = i18nService;
|
private aboutMenu: AboutMenu,
|
||||||
this._webVaultUrl = webVaultUrl;
|
) {}
|
||||||
this._aboutMenu = aboutMenu;
|
|
||||||
}
|
|
||||||
|
|
||||||
private get helpAndFeedback(): MenuItemConstructorOptions {
|
private get helpAndFeedback(): MenuItemConstructorOptions {
|
||||||
return {
|
return {
|
||||||
@@ -130,7 +131,7 @@ export class HelpMenu implements IMenubarMenu {
|
|||||||
return {
|
return {
|
||||||
id: "goToWebVault",
|
id: "goToWebVault",
|
||||||
label: this.localize("goToWebVault"),
|
label: this.localize("goToWebVault"),
|
||||||
click: () => shell.openExternal(this._webVaultUrl),
|
click: () => shell.openExternal(this.webVaultUrl),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,25 +149,19 @@ export class HelpMenu implements IMenubarMenu {
|
|||||||
{
|
{
|
||||||
id: "iOS",
|
id: "iOS",
|
||||||
label: "iOS",
|
label: "iOS",
|
||||||
click: () => {
|
click: () =>
|
||||||
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
||||||
shell.openExternal(
|
shell.openExternal(
|
||||||
"https://itunes.apple.com/app/" + "bitwarden-free-password-manager/id1137397744?mt=8",
|
"https://itunes.apple.com/app/" + "bitwarden-free-password-manager/id1137397744?mt=8",
|
||||||
);
|
),
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "android",
|
id: "android",
|
||||||
label: "Android",
|
label: "Android",
|
||||||
visible: !isMacAppStore(), // Apple Guideline 2.3.10 - Accurate Metadata
|
visible: !isMacAppStore(), // Apple Guideline 2.3.10 - Accurate Metadata
|
||||||
click: () => {
|
click: () =>
|
||||||
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
||||||
shell.openExternal(
|
shell.openExternal(
|
||||||
"https://play.google.com/store/apps/" + "details?id=com.x8bit.bitwarden",
|
"https://play.google.com/store/apps/" + "details?id=com.x8bit.bitwarden",
|
||||||
);
|
),
|
||||||
},
|
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -185,62 +180,74 @@ export class HelpMenu implements IMenubarMenu {
|
|||||||
{
|
{
|
||||||
id: "chrome",
|
id: "chrome",
|
||||||
label: "Chrome",
|
label: "Chrome",
|
||||||
click: () => {
|
click: () =>
|
||||||
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
||||||
shell.openExternal(
|
shell.openExternal(
|
||||||
"https://chromewebstore.google.com/detail/" +
|
"https://chromewebstore.google.com/detail/" +
|
||||||
"bitwarden-free-password-m/nngceckbapebfimnlniiiahkandclblb",
|
"bitwarden-free-password-m/nngceckbapebfimnlniiiahkandclblb",
|
||||||
);
|
),
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "firefox",
|
id: "firefox",
|
||||||
label: "Firefox",
|
label: "Firefox",
|
||||||
click: () => {
|
click: () =>
|
||||||
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
||||||
shell.openExternal(
|
shell.openExternal(
|
||||||
"https://addons.mozilla.org/firefox/addon/" + "bitwarden-password-manager/",
|
"https://addons.mozilla.org/firefox/addon/" + "bitwarden-password-manager/",
|
||||||
);
|
),
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "firefox",
|
id: "firefox",
|
||||||
label: "Opera",
|
label: "Opera",
|
||||||
click: () => {
|
click: () =>
|
||||||
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
||||||
shell.openExternal(
|
shell.openExternal(
|
||||||
"https://addons.opera.com/extensions/details/" + "bitwarden-free-password-manager/",
|
"https://addons.opera.com/extensions/details/" + "bitwarden-free-password-manager/",
|
||||||
);
|
),
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "firefox",
|
id: "firefox",
|
||||||
label: "Edge",
|
label: "Edge",
|
||||||
click: () => {
|
click: () =>
|
||||||
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
||||||
shell.openExternal(
|
shell.openExternal(
|
||||||
"https://microsoftedge.microsoft.com/addons/" +
|
"https://microsoftedge.microsoft.com/addons/" +
|
||||||
"detail/jbkfoedolllekgbhcbcoahefnbanhhlh",
|
"detail/jbkfoedolllekgbhcbcoahefnbanhhlh",
|
||||||
);
|
),
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "safari",
|
id: "safari",
|
||||||
label: "Safari",
|
label: "Safari",
|
||||||
click: () => {
|
click: () => shell.openExternal("https://bitwarden.com/download/"),
|
||||||
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
|
},
|
||||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
];
|
||||||
shell.openExternal("https://bitwarden.com/download/");
|
}
|
||||||
|
|
||||||
|
private get troubleshooting(): MenuItemConstructorOptions {
|
||||||
|
return {
|
||||||
|
id: "troubleshooting",
|
||||||
|
label: this.localize("troubleshooting"),
|
||||||
|
submenu: this.troubleshootingSubmenu,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private get troubleshootingSubmenu(): MenuItemConstructorOptions[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
id: "hardwareAcceleration",
|
||||||
|
label: this.localize(
|
||||||
|
this.hardwareAccelerationEnabled
|
||||||
|
? "disableHardwareAccelerationRestart"
|
||||||
|
: "enableHardwareAccelerationRestart",
|
||||||
|
),
|
||||||
|
click: async () => {
|
||||||
|
await this.desktopSettingsService.setHardwareAcceleration(
|
||||||
|
!this.hardwareAccelerationEnabled,
|
||||||
|
);
|
||||||
|
app.relaunch();
|
||||||
|
app.exit();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
private localize(s: string) {
|
private localize(s: string) {
|
||||||
return this._i18nService.t(s);
|
return this.i18nService.t(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { EnvironmentService } from "@bitwarden/common/platform/abstractions/envi
|
|||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
||||||
|
|
||||||
|
import { DesktopSettingsService } from "../../platform/services/desktop-settings.service";
|
||||||
import { UpdaterMain } from "../updater.main";
|
import { UpdaterMain } from "../updater.main";
|
||||||
import { WindowMain } from "../window.main";
|
import { WindowMain } from "../window.main";
|
||||||
|
|
||||||
@@ -20,6 +21,7 @@ export class MenuMain {
|
|||||||
private environmentService: EnvironmentService,
|
private environmentService: EnvironmentService,
|
||||||
private windowMain: WindowMain,
|
private windowMain: WindowMain,
|
||||||
private updaterMain: UpdaterMain,
|
private updaterMain: UpdaterMain,
|
||||||
|
private desktopSettingsService: DesktopSettingsService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async init() {
|
async init() {
|
||||||
@@ -36,10 +38,12 @@ export class MenuMain {
|
|||||||
new Menubar(
|
new Menubar(
|
||||||
this.i18nService,
|
this.i18nService,
|
||||||
this.messagingService,
|
this.messagingService,
|
||||||
|
this.desktopSettingsService,
|
||||||
this.updaterMain,
|
this.updaterMain,
|
||||||
this.windowMain,
|
this.windowMain,
|
||||||
await this.getWebVaultUrl(),
|
await this.getWebVaultUrl(),
|
||||||
app.getVersion(),
|
app.getVersion(),
|
||||||
|
await firstValueFrom(this.desktopSettingsService.hardwareAcceleration$),
|
||||||
updateRequest,
|
updateRequest,
|
||||||
).menu,
|
).menu,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { Menu, MenuItemConstructorOptions } from "electron";
|
|||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
||||||
|
|
||||||
|
import { DesktopSettingsService } from "../../platform/services/desktop-settings.service";
|
||||||
import { isMac } from "../../utils";
|
import { isMac } from "../../utils";
|
||||||
import { UpdaterMain } from "../updater.main";
|
import { UpdaterMain } from "../updater.main";
|
||||||
import { WindowMain } from "../window.main";
|
import { WindowMain } from "../window.main";
|
||||||
@@ -47,10 +48,12 @@ export class Menubar {
|
|||||||
constructor(
|
constructor(
|
||||||
i18nService: I18nService,
|
i18nService: I18nService,
|
||||||
messagingService: MessagingService,
|
messagingService: MessagingService,
|
||||||
|
desktopSettingsService: DesktopSettingsService,
|
||||||
updaterMain: UpdaterMain,
|
updaterMain: UpdaterMain,
|
||||||
windowMain: WindowMain,
|
windowMain: WindowMain,
|
||||||
webVaultUrl: string,
|
webVaultUrl: string,
|
||||||
appVersion: string,
|
appVersion: string,
|
||||||
|
hardwareAccelerationEnabled: boolean,
|
||||||
updateRequest?: MenuUpdateRequest,
|
updateRequest?: MenuUpdateRequest,
|
||||||
) {
|
) {
|
||||||
let isLocked = true;
|
let isLocked = true;
|
||||||
@@ -89,7 +92,9 @@ export class Menubar {
|
|||||||
new WindowMenu(i18nService, messagingService, windowMain),
|
new WindowMenu(i18nService, messagingService, windowMain),
|
||||||
new HelpMenu(
|
new HelpMenu(
|
||||||
i18nService,
|
i18nService,
|
||||||
|
desktopSettingsService,
|
||||||
webVaultUrl,
|
webVaultUrl,
|
||||||
|
hardwareAccelerationEnabled,
|
||||||
new AboutMenu(i18nService, appVersion, windowMain.win, updaterMain),
|
new AboutMenu(i18nService, appVersion, windowMain.win, updaterMain),
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user