diff --git a/apps/browser/src/_locales/en/messages.json b/apps/browser/src/_locales/en/messages.json index 361d8076ba..a6aff9e455 100644 --- a/apps/browser/src/_locales/en/messages.json +++ b/apps/browser/src/_locales/en/messages.json @@ -1033,6 +1033,12 @@ "showAutoFillMenuOnFormFieldsDescAlt": { "message": "Applies to all logged in accounts." }, + "turnOffBrowserBuiltInPasswordManagerSettings": { + "message": "Turn off your browser’s built in password manager settings to avoid conflicts." + }, + "turnOffBrowserBuiltInPasswordManagerSettingsLink": { + "message": "Edit browser settings." + }, "autofillOverlayVisibilityOff": { "message": "Off", "description": "Overlay setting select option for disabling autofill overlay" @@ -2547,36 +2553,12 @@ "message": "Bitwarden auto-fill menu available. Press the down arrow key to select.", "description": "Screen reader text for announcing when the overlay opens on the page" }, - "overrideBrowserAutofillTitle": { - "message": "Override browser auto-fill?", - "description": "Dialog title facilitating the ability to override a chrome browser's default autofill behavior" - }, - "overrideBrowserAutofillDescription": { - "message": "Leaving this setting off may cause conflicts between the Bitwarden auto-fill menu and your browser’s.", - "description": "Dialog message facilitating the ability to override a chrome browser's default autofill behavior" - }, - "overrideBrowserAutofillPrivacyRequiredDescription": { - "message": "Leaving this setting off may cause conflicts between the Bitwarden auto-fill menu and your browser’s. Turning this on will restart the Bitwarden extension.", - "description": "Dialog message facilitating the ability to override a chrome browser's default autofill behavior" - }, "turnOn": { "message": "Turn on" }, "ignore": { "message": "Ignore" }, - "overrideBrowserAutoFillSettings": { - "message": "Override browser auto-fill settings", - "description": "Label for the setting that allows overriding the default browser autofill settings" - }, - "extensionPrivacyPermissionNotGrantedTitle": { - "message": "Unable to override browser auto-fill", - "description": "Title for the dialog that appears when the user has not granted the extension permission to set privacy settings" - }, - "extensionPrivacyPermissionNotGrantedDescription": { - "message": "Bitwarden must have access to the extension's privacy permission to override browser auto-fill settings.", - "description": "Description for the dialog that appears when the user has not granted the extension permission to set privacy settings" - }, "importData": { "message": "Import data", "description": "Used for the header of the import dialog, the import button and within the file-password-prompt" diff --git a/apps/browser/src/autofill/popup/settings/autofill.component.html b/apps/browser/src/autofill/popup/settings/autofill.component.html index 9204add445..d675615ac8 100644 --- a/apps/browser/src/autofill/popup/settings/autofill.component.html +++ b/apps/browser/src/autofill/popup/settings/autofill.component.html @@ -45,22 +45,20 @@ + -
-
-
- - -
-
-
diff --git a/apps/browser/src/autofill/popup/settings/autofill.component.ts b/apps/browser/src/autofill/popup/settings/autofill.component.ts index 341f5b9d63..d9038b0eb2 100644 --- a/apps/browser/src/autofill/popup/settings/autofill.component.ts +++ b/apps/browser/src/autofill/popup/settings/autofill.component.ts @@ -7,7 +7,6 @@ import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.servic import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service"; import { StateService } from "@bitwarden/common/platform/abstractions/state.service"; import { UriMatchType } from "@bitwarden/common/vault/enums"; -import { DialogService } from "@bitwarden/components"; import { BrowserApi } from "../../../platform/browser/browser-api"; import { flagEnabled } from "../../../platform/flags"; @@ -18,11 +17,10 @@ import { AutofillOverlayVisibility } from "../../utils/autofill-overlay.enum"; templateUrl: "autofill.component.html", }) export class AutofillComponent implements OnInit { - protected canOverrideBrowserAutofillSetting = false; - protected defaultBrowserAutofillDisabled = false; protected isAutoFillOverlayFlagEnabled = false; protected autoFillOverlayVisibility: number; protected autoFillOverlayVisibilityOptions: any[]; + protected disablePasswordManagerLink: string; enableAutoFillOnPageLoad = false; autoFillOnPageLoadDefault = false; autoFillOnPageLoadOptions: any[]; @@ -37,7 +35,6 @@ export class AutofillComponent implements OnInit { private platformUtilsService: PlatformUtilsService, private configService: ConfigServiceAbstraction, private settingsService: SettingsService, - private dialogService: DialogService, ) { this.autoFillOverlayVisibilityOptions = [ { @@ -67,13 +64,10 @@ export class AutofillComponent implements OnInit { ]; this.accountSwitcherEnabled = flagEnabled("accountSwitching"); + this.disablePasswordManagerLink = this.getDisablePasswordManagerLink(); } async ngOnInit() { - this.canOverrideBrowserAutofillSetting = this.platformUtilsService.isChrome(); - - this.defaultBrowserAutofillDisabled = await this.browserAutofillSettingCurrentlyOverridden(); - this.isAutoFillOverlayFlagEnabled = await this.configService.getFeatureFlag( FeatureFlag.AutofillOverlay, ); @@ -91,54 +85,8 @@ export class AutofillComponent implements OnInit { await this.setAutofillKeyboardHelperText(command); } - async updateDefaultBrowserAutofillDisabled() { - const privacyPermissionGranted = await this.privacyPermissionGranted(); - if (!this.defaultBrowserAutofillDisabled && !privacyPermissionGranted) { - return; - } - - if ( - !privacyPermissionGranted && - !(await BrowserApi.requestPermission({ permissions: ["privacy"] })) - ) { - await this.dialogService.openSimpleDialog({ - title: { key: "extensionPrivacyPermissionNotGrantedTitle" }, - content: { key: "extensionPrivacyPermissionNotGrantedDescription" }, - acceptButtonText: { key: "ok" }, - cancelButtonText: null, - type: "warning", - }); - this.defaultBrowserAutofillDisabled = false; - - return; - } - - await BrowserApi.updateDefaultBrowserAutofillSettings(!this.defaultBrowserAutofillDisabled); - } - async updateAutoFillOverlayVisibility() { await this.settingsService.setAutoFillOverlayVisibility(this.autoFillOverlayVisibility); - - if ( - this.autoFillOverlayVisibility === AutofillOverlayVisibility.Off || - !this.canOverrideBrowserAutofillSetting || - (await this.browserAutofillSettingCurrentlyOverridden()) - ) { - return; - } - - const permissionGranted = await this.privacyPermissionGranted(); - const contentKey = permissionGranted - ? "overrideBrowserAutofillDescription" - : "overrideBrowserAutofillPrivacyRequiredDescription"; - await this.dialogService.openSimpleDialog({ - title: { key: "overrideBrowserAutofillTitle" }, - content: { key: contentKey }, - acceptButtonText: { key: "turnOn" }, - acceptAction: async () => await this.handleOverrideDialogAccept(), - cancelButtonText: { key: "ignore" }, - type: "info", - }); } async updateAutoFillOnPageLoad() { @@ -175,24 +123,25 @@ export class AutofillComponent implements OnInit { } } - private handleOverrideDialogAccept = async () => { - this.defaultBrowserAutofillDisabled = true; - await this.updateDefaultBrowserAutofillDisabled(); - }; - - async browserAutofillSettingCurrentlyOverridden() { - if (!this.canOverrideBrowserAutofillSetting) { - return false; + private getDisablePasswordManagerLink(): string { + if (this.platformUtilsService.isChrome()) { + return "chrome://settings/autofill"; + } + if (this.platformUtilsService.isOpera()) { + return "opera://settings/autofill"; + } + if (this.platformUtilsService.isEdge()) { + return "edge://settings/passwords"; + } + if (this.platformUtilsService.isVivaldi()) { + return "vivaldi://settings/autofill"; } - if (!(await this.privacyPermissionGranted())) { - return false; - } - - return await BrowserApi.browserAutofillSettingsOverridden(); + return "https://bitwarden.com/help/disable-browser-autofill/"; } - async privacyPermissionGranted(): Promise { - return await BrowserApi.permissionsGranted(["privacy"]); + protected openDisablePasswordManagerLink(event: Event) { + event.preventDefault(); + BrowserApi.createNewTab(this.disablePasswordManagerLink); } } diff --git a/apps/browser/src/manifest.json b/apps/browser/src/manifest.json index ab56206aa5..2bd032495c 100644 --- a/apps/browser/src/manifest.json +++ b/apps/browser/src/manifest.json @@ -59,7 +59,7 @@ "webRequest", "webRequestBlocking" ], - "optional_permissions": ["nativeMessaging", "privacy"], + "optional_permissions": ["nativeMessaging"], "content_security_policy": "script-src 'self' 'wasm-unsafe-eval'; object-src 'self'", "sandbox": { "pages": ["overlay/button.html", "overlay/list.html"], diff --git a/apps/browser/src/manifest.v3.json b/apps/browser/src/manifest.v3.json index 937f141190..dba40744e7 100644 --- a/apps/browser/src/manifest.v3.json +++ b/apps/browser/src/manifest.v3.json @@ -69,7 +69,7 @@ "alarms", "scripting" ], - "optional_permissions": ["nativeMessaging", "privacy"], + "optional_permissions": ["nativeMessaging"], "host_permissions": ["http://*/*", "https://*/*"], "content_security_policy": { "extension_pages": "script-src 'self' 'wasm-unsafe-eval'; object-src 'self'", diff --git a/apps/browser/src/platform/browser/browser-api.ts b/apps/browser/src/platform/browser/browser-api.ts index 8330d0797d..aaab7e113a 100644 --- a/apps/browser/src/platform/browser/browser-api.ts +++ b/apps/browser/src/platform/browser/browser-api.ts @@ -439,33 +439,4 @@ export class BrowserApi { }); }); } - - /** - * Identifies if the browser autofill settings are overridden by the extension. - */ - static async browserAutofillSettingsOverridden(): Promise { - const autofillAddressOverridden: boolean = await new Promise((resolve) => - chrome.privacy.services.autofillAddressEnabled.get({}, (details) => - resolve(details.levelOfControl === "controlled_by_this_extension" && !details.value), - ), - ); - - const autofillCreditCardOverridden: boolean = await new Promise((resolve) => - chrome.privacy.services.autofillCreditCardEnabled.get({}, (details) => - resolve(details.levelOfControl === "controlled_by_this_extension" && !details.value), - ), - ); - - return autofillAddressOverridden && autofillCreditCardOverridden; - } - - /** - * Updates the browser autofill settings to the given value. - * - * @param value - Determines whether to enable or disable the autofill settings. - */ - static async updateDefaultBrowserAutofillSettings(value: boolean) { - chrome.privacy.services.autofillAddressEnabled.set({ value }); - chrome.privacy.services.autofillCreditCardEnabled.set({ value }); - } }