mirror of
https://github.com/bitwarden/browser.git
synced 2025-01-06 18:57:56 +01: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:
parent
a898fa4386
commit
8fda52ef7e
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -186,6 +186,11 @@ export default class RuntimeBackground {
|
||||
FeatureFlag.UseTreeWalkerApiForPageDetailsCollection,
|
||||
);
|
||||
}
|
||||
case "getUseBasicInlineMenuFieldQualificationFeatureFlag": {
|
||||
return await this.configService.getFeatureFlag(
|
||||
FeatureFlag.UseBasicInlineMenuFieldQualification,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@ export enum FeatureFlag {
|
||||
RestrictProviderAccess = "restrict-provider-access",
|
||||
UseTreeWalkerApiForPageDetailsCollection = "use-tree-walker-api-for-page-details-collection",
|
||||
BulkDeviceApproval = "bulk-device-approval",
|
||||
UseBasicInlineMenuFieldQualification = "use-basic-inline-menu-field-qualification",
|
||||
}
|
||||
|
||||
export type AllowedFeatureFlagTypes = boolean | number | string;
|
||||
@ -44,6 +45,7 @@ export const DefaultFeatureFlagValue = {
|
||||
[FeatureFlag.RestrictProviderAccess]: FALSE,
|
||||
[FeatureFlag.UseTreeWalkerApiForPageDetailsCollection]: FALSE,
|
||||
[FeatureFlag.BulkDeviceApproval]: FALSE,
|
||||
[FeatureFlag.UseBasicInlineMenuFieldQualification]: FALSE,
|
||||
} satisfies Record<FeatureFlag, AllowedFeatureFlagTypes>;
|
||||
|
||||
export type DefaultFeatureFlagValueType = typeof DefaultFeatureFlagValue;
|
||||
|
Loading…
Reference in New Issue
Block a user