1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-15 15:53:27 +00:00

[PM-8027] Incorporating a feature flag to allow us to fallback to the basic inline menu fielld qualification method if needed

This commit is contained in:
Cesar Gonzalez
2024-06-07 07:24:35 -05:00
parent a898fa4386
commit 8fda52ef7e
3 changed files with 35 additions and 0 deletions

View File

@@ -1,5 +1,6 @@
import AutofillField from "../models/autofill-field";
import AutofillPageDetails from "../models/autofill-page-details";
import { sendExtensionMessage } from "../utils";
import { InlineMenuFieldQualificationsService as InlineMenuFieldQualificationsServiceInterface } from "./abstractions/inline-menu-field-qualifications.service";
import { AutoFillConstants } from "./autofill-constants";
@@ -16,6 +17,15 @@ export class InlineMenuFieldQualificationService
private autofillFieldKeywordsMap: WeakMap<AutofillField, string> = new WeakMap();
private autocompleteDisabledValues = new Set(["off", "false"]);
private newFieldKeywords = new Set(["new", "change", "neue", "ändern"]);
private useBasicInlineMenuFieldQualificationFlagSet = false;
constructor() {
void sendExtensionMessage("getUseTreeWalkerApiForPageDetailsCollectionFeatureFlag").then(
(getUseBasicInlineMenuFieldQualificationFlag) =>
(this.useBasicInlineMenuFieldQualificationFlagSet =
!!getUseBasicInlineMenuFieldQualificationFlag?.result),
);
}
/**
* Validates the provided field as a field for a login form.
@@ -24,6 +34,10 @@ export class InlineMenuFieldQualificationService
* @param pageDetails - The details of the page that the field is on.
*/
isFieldForLoginForm(field: AutofillField, pageDetails: AutofillPageDetails): boolean {
if (this.useBasicInlineMenuFieldQualificationFlagSet) {
return this.isFieldForLoginFormFallback(field);
}
const isCurrentPasswordField = this.isCurrentPasswordField(field);
if (isCurrentPasswordField) {
return this.isPasswordFieldForLoginForm(field, pageDetails);
@@ -392,4 +406,18 @@ export class InlineMenuFieldQualificationService
return keywordValues;
}
/**
* This method represents the previous rudimentary approach to qualifying fields for login forms.
*
* @param field - The field to validate
* @deprecated - This method will only be used when the fallback flag is set to true.
*/
private isFieldForLoginFormFallback(field: AutofillField): boolean {
if (field.type === "password") {
return true;
}
return this.isUsernameField(field);
}
}

View File

@@ -186,6 +186,11 @@ export default class RuntimeBackground {
FeatureFlag.UseTreeWalkerApiForPageDetailsCollection,
);
}
case "getUseBasicInlineMenuFieldQualificationFeatureFlag": {
return await this.configService.getFeatureFlag(
FeatureFlag.UseBasicInlineMenuFieldQualification,
);
}
}
}