Skip to content

Commit

Permalink
[PM-5148] Removing Browser Autofill Override Setting and Add Message (#…
Browse files Browse the repository at this point in the history
…7110)

* [PM-5148] Removing Browser Autofill Override Setting and Add Message

* [PM-5148] Removing translation keys

* [PM-5148] Removing translation keys

* [PM-5148] Modifying how we present the link to users to ensure translations can be more effective
  • Loading branch information
cagonzalezcs authored Dec 7, 2023
1 parent 2b3faca commit e5b8fd4
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 136 deletions.
30 changes: 6 additions & 24 deletions apps/browser/src/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
24 changes: 11 additions & 13 deletions apps/browser/src/autofill/popup/settings/autofill.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,20 @@ <h1 class="center">
<div class="box-footer" *ngIf="accountSwitcherEnabled">
{{ "showAutoFillMenuOnFormFieldsDescAlt" | i18n }}
</div>
<div class="box-footer">
{{ "turnOffBrowserBuiltInPasswordManagerSettings" | i18n }}
<a
[attr.href]="disablePasswordManagerLink"
(click)="openDisablePasswordManagerLink($event)"
target="_blank"
rel="noopener noreferrer"
>
{{ "turnOffBrowserBuiltInPasswordManagerSettingsLink" | i18n }}
</a>
</div>
</div>
</div>
</ng-container>
<div class="box tw-mt-4" *ngIf="canOverrideBrowserAutofillSetting">
<div class="box-content">
<div class="box-content-row box-content-row-checkbox" appBoxRow>
<label for="overrideBrowserAutofill">{{ "overrideBrowserAutoFillSettings" | i18n }}</label>
<input
id="overrideBrowserAutofill"
type="checkbox"
(change)="updateDefaultBrowserAutofillDisabled()"
[(ngModel)]="defaultBrowserAutofillDisabled"
/>
</div>
</div>
</div>
<div class="box tw-mt-4">
<div class="box-content">
<div class="box-content-row box-content-row-checkbox" appBoxRow>
Expand Down
85 changes: 17 additions & 68 deletions apps/browser/src/autofill/popup/settings/autofill.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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[];
Expand All @@ -37,7 +35,6 @@ export class AutofillComponent implements OnInit {
private platformUtilsService: PlatformUtilsService,
private configService: ConfigServiceAbstraction,
private settingsService: SettingsService,
private dialogService: DialogService,
) {
this.autoFillOverlayVisibilityOptions = [
{
Expand Down Expand Up @@ -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<boolean>(
FeatureFlag.AutofillOverlay,
);
Expand All @@ -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() {
Expand Down Expand Up @@ -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 (!(await this.privacyPermissionGranted())) {
return false;
if (this.platformUtilsService.isOpera()) {
return "opera://settings/autofill";
}
if (this.platformUtilsService.isEdge()) {
return "edge://settings/passwords";
}
if (this.platformUtilsService.isVivaldi()) {
return "vivaldi://settings/autofill";
}

return await BrowserApi.browserAutofillSettingsOverridden();
return "https://bitwarden.com/help/disable-browser-autofill/";
}

async privacyPermissionGranted(): Promise<boolean> {
return await BrowserApi.permissionsGranted(["privacy"]);
protected openDisablePasswordManagerLink(event: Event) {
event.preventDefault();
BrowserApi.createNewTab(this.disablePasswordManagerLink);
}
}
2 changes: 1 addition & 1 deletion apps/browser/src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
2 changes: 1 addition & 1 deletion apps/browser/src/manifest.v3.json
Original file line number Diff line number Diff line change
Expand Up @@ -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'",
Expand Down
29 changes: 0 additions & 29 deletions apps/browser/src/platform/browser/browser-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -439,33 +439,4 @@ export class BrowserApi {
});
});
}

/**
* Identifies if the browser autofill settings are overridden by the extension.
*/
static async browserAutofillSettingsOverridden(): Promise<boolean> {
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 });
}
}

0 comments on commit e5b8fd4

Please sign in to comment.