mirror of
https://github.com/bitwarden/browser
synced 2025-12-13 06:43:35 +00: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:
@@ -4170,5 +4170,8 @@
|
|||||||
},
|
},
|
||||||
"systemDefault": {
|
"systemDefault": {
|
||||||
"message": "System default"
|
"message": "System default"
|
||||||
|
},
|
||||||
|
"enterprisePolicyRequirementsApplied": {
|
||||||
|
"message": "Enterprise policy requirements have been applied to this setting"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -145,8 +145,12 @@
|
|||||||
type="checkbox"
|
type="checkbox"
|
||||||
(change)="updateAutofillOnPageLoad()"
|
(change)="updateAutofillOnPageLoad()"
|
||||||
[(ngModel)]="enableAutofillOnPageLoad"
|
[(ngModel)]="enableAutofillOnPageLoad"
|
||||||
|
[disabled]="autofillOnPageLoadFromPolicy$ | async"
|
||||||
/>
|
/>
|
||||||
<bit-label for="autofillOnPageLoad">{{ "enableAutoFillOnPageLoad" | i18n }}</bit-label>
|
<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-control>
|
||||||
<bit-form-field disableMargin>
|
<bit-form-field disableMargin>
|
||||||
<bit-label for="defaultAutofill">{{ "defaultAutoFillOnPageLoad" | i18n }}</bit-label>
|
<bit-label for="defaultAutofill">{{ "defaultAutoFillOnPageLoad" | i18n }}</bit-label>
|
||||||
|
|||||||
@@ -87,6 +87,9 @@ export class AutofillComponent implements OnInit {
|
|||||||
DisablePasswordManagerUris.Unknown;
|
DisablePasswordManagerUris.Unknown;
|
||||||
protected browserShortcutsURI: BrowserShortcutsUri = BrowserShortcutsUris.Unknown;
|
protected browserShortcutsURI: BrowserShortcutsUri = BrowserShortcutsUris.Unknown;
|
||||||
protected browserClientIsUnknown: boolean;
|
protected browserClientIsUnknown: boolean;
|
||||||
|
protected autofillOnPageLoadFromPolicy$ =
|
||||||
|
this.autofillSettingsService.activateAutofillOnPageLoadFromPolicy$;
|
||||||
|
|
||||||
enableAutofillOnPageLoad = false;
|
enableAutofillOnPageLoad = false;
|
||||||
enableInlineMenu = false;
|
enableInlineMenu = false;
|
||||||
enableInlineMenuOnIconSelect = false;
|
enableInlineMenuOnIconSelect = false;
|
||||||
|
|||||||
@@ -81,5 +81,6 @@ export abstract class AutofillService {
|
|||||||
fromCommand: boolean,
|
fromCommand: boolean,
|
||||||
cipherType?: CipherType,
|
cipherType?: CipherType,
|
||||||
) => Promise<string | null>;
|
) => Promise<string | null>;
|
||||||
|
setAutoFillOnPageLoadOrgPolicy: () => Promise<void>;
|
||||||
isPasswordRepromptRequired: (cipher: CipherView, tab: chrome.tabs.Tab) => Promise<boolean>;
|
isPasswordRepromptRequired: (cipher: CipherView, tab: chrome.tabs.Tab) => Promise<boolean>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -570,6 +570,19 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
return totpCode;
|
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.
|
* Gets the active tab from the current window.
|
||||||
* Throws an error if no tab is found.
|
* Throws an error if no tab is found.
|
||||||
|
|||||||
@@ -228,7 +228,7 @@ export default class RuntimeBackground {
|
|||||||
// `getAllDecryptedForUrl` and is anticipated to be refactored
|
// `getAllDecryptedForUrl` and is anticipated to be refactored
|
||||||
await this.main.refreshBadge();
|
await this.main.refreshBadge();
|
||||||
await this.main.refreshMenu(false);
|
await this.main.refreshMenu(false);
|
||||||
|
await this.autofillService.setAutoFillOnPageLoadOrgPolicy();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "addToLockedVaultPendingNotifications":
|
case "addToLockedVaultPendingNotifications":
|
||||||
@@ -248,6 +248,7 @@ export default class RuntimeBackground {
|
|||||||
}, 2000);
|
}, 2000);
|
||||||
await this.configService.ensureConfigFetched();
|
await this.configService.ensureConfigFetched();
|
||||||
await this.main.updateOverlayCiphers();
|
await this.main.updateOverlayCiphers();
|
||||||
|
await this.autofillService.setAutoFillOnPageLoadOrgPolicy();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "openPopup":
|
case "openPopup":
|
||||||
|
|||||||
@@ -146,9 +146,8 @@ export class AutofillSettingsService implements AutofillSettingsServiceAbstracti
|
|||||||
this.autofillOnPageLoadPolicyToastHasDisplayedState = this.stateProvider.getActive(
|
this.autofillOnPageLoadPolicyToastHasDisplayedState = this.stateProvider.getActive(
|
||||||
AUTOFILL_ON_PAGE_LOAD_POLICY_TOAST_HAS_DISPLAYED,
|
AUTOFILL_ON_PAGE_LOAD_POLICY_TOAST_HAS_DISPLAYED,
|
||||||
);
|
);
|
||||||
this.autofillOnPageLoadPolicyToastHasDisplayed$ = this.autofillOnPageLoadState.state$.pipe(
|
this.autofillOnPageLoadPolicyToastHasDisplayed$ =
|
||||||
map((x) => x ?? false),
|
this.autofillOnPageLoadPolicyToastHasDisplayedState.state$.pipe(map((x) => x ?? false));
|
||||||
);
|
|
||||||
|
|
||||||
this.autoCopyTotpState = this.stateProvider.getActive(AUTO_COPY_TOTP);
|
this.autoCopyTotpState = this.stateProvider.getActive(AUTO_COPY_TOTP);
|
||||||
this.autoCopyTotp$ = this.autoCopyTotpState.state$.pipe(map((x) => x ?? true));
|
this.autoCopyTotp$ = this.autoCopyTotpState.state$.pipe(map((x) => x ?? true));
|
||||||
|
|||||||
Reference in New Issue
Block a user