1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-11 10:10:25 +01:00

[PM-8144] Migrate auto-fill policy logic from Tab to new Vault component (#10450)

* little expriment with setting the auto fill policy in the background

* removed unused reference

* removed ng container
This commit is contained in:
SmithThe4th 2024-08-09 11:33:09 -04:00 committed by GitHub
parent 46ecde5d63
commit d1c3ec4a76
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 28 additions and 4 deletions

View File

@ -4170,5 +4170,8 @@
},
"systemDefault": {
"message": "System default"
},
"enterprisePolicyRequirementsApplied": {
"message": "Enterprise policy requirements have been applied to this setting"
}
}

View File

@ -145,8 +145,12 @@
type="checkbox"
(change)="updateAutofillOnPageLoad()"
[(ngModel)]="enableAutofillOnPageLoad"
[disabled]="autofillOnPageLoadFromPolicy$ | async"
/>
<bit-label for="autofillOnPageLoad">{{ "enableAutoFillOnPageLoad" | i18n }}</bit-label>
<bit-hint class="tw-text-sm" *ngIf="autofillOnPageLoadFromPolicy$ | async">{{
"enterprisePolicyRequirementsApplied" | i18n
}}</bit-hint>
</bit-form-control>
<bit-form-field disableMargin>
<bit-label for="defaultAutofill">{{ "defaultAutoFillOnPageLoad" | i18n }}</bit-label>

View File

@ -87,6 +87,9 @@ export class AutofillComponent implements OnInit {
DisablePasswordManagerUris.Unknown;
protected browserShortcutsURI: BrowserShortcutsUri = BrowserShortcutsUris.Unknown;
protected browserClientIsUnknown: boolean;
protected autofillOnPageLoadFromPolicy$ =
this.autofillSettingsService.activateAutofillOnPageLoadFromPolicy$;
enableAutofillOnPageLoad = false;
enableInlineMenu = false;
enableInlineMenuOnIconSelect = false;

View File

@ -81,5 +81,6 @@ export abstract class AutofillService {
fromCommand: boolean,
cipherType?: CipherType,
) => Promise<string | null>;
setAutoFillOnPageLoadOrgPolicy: () => Promise<void>;
isPasswordRepromptRequired: (cipher: CipherView, tab: chrome.tabs.Tab) => Promise<boolean>;
}

View File

@ -570,6 +570,19 @@ export default class AutofillService implements AutofillServiceInterface {
return totpCode;
}
/**
* Activates the autofill on page load org policy.
*/
async setAutoFillOnPageLoadOrgPolicy(): Promise<void> {
const autofillOnPageLoadOrgPolicy = await firstValueFrom(
this.autofillSettingsService.activateAutofillOnPageLoadFromPolicy$,
);
if (autofillOnPageLoadOrgPolicy) {
await this.autofillSettingsService.setAutofillOnPageLoad(true);
}
}
/**
* Gets the active tab from the current window.
* Throws an error if no tab is found.

View File

@ -228,7 +228,7 @@ export default class RuntimeBackground {
// `getAllDecryptedForUrl` and is anticipated to be refactored
await this.main.refreshBadge();
await this.main.refreshMenu(false);
await this.autofillService.setAutoFillOnPageLoadOrgPolicy();
break;
}
case "addToLockedVaultPendingNotifications":
@ -248,6 +248,7 @@ export default class RuntimeBackground {
}, 2000);
await this.configService.ensureConfigFetched();
await this.main.updateOverlayCiphers();
await this.autofillService.setAutoFillOnPageLoadOrgPolicy();
}
break;
case "openPopup":

View File

@ -146,9 +146,8 @@ export class AutofillSettingsService implements AutofillSettingsServiceAbstracti
this.autofillOnPageLoadPolicyToastHasDisplayedState = this.stateProvider.getActive(
AUTOFILL_ON_PAGE_LOAD_POLICY_TOAST_HAS_DISPLAYED,
);
this.autofillOnPageLoadPolicyToastHasDisplayed$ = this.autofillOnPageLoadState.state$.pipe(
map((x) => x ?? false),
);
this.autofillOnPageLoadPolicyToastHasDisplayed$ =
this.autofillOnPageLoadPolicyToastHasDisplayedState.state$.pipe(map((x) => x ?? false));
this.autoCopyTotpState = this.stateProvider.getActive(AUTO_COPY_TOTP);
this.autoCopyTotp$ = this.autoCopyTotpState.state$.pipe(map((x) => x ?? true));