Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PM-12352] Incorporate the minimum amount of changes to ensure OverlayBackground instantiates on init of the extension #11134

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
10 changes: 0 additions & 10 deletions apps/browser/src/autofill/background/tabs.background.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";

import MainBackground from "../../background/main.background";

import { OverlayBackground } from "./abstractions/overlay.background";
Expand Down Expand Up @@ -88,14 +86,6 @@ export default class TabsBackground {
changeInfo: chrome.tabs.TabChangeInfo,
tab: chrome.tabs.Tab,
) => {
const overlayImprovementsFlag = await this.main.configService.getFeatureFlag(
FeatureFlag.InlineMenuPositioningImprovements,
);
const removePageDetailsStatus = new Set(["loading", "unloaded"]);
if (!!overlayImprovementsFlag && removePageDetailsStatus.has(changeInfo.status)) {
this.overlayBackground.removePageDetails(tabId);
}

if (this.focusedWindowId > 0 && tab.windowId !== this.focusedWindowId) {
return;
}
Expand Down
7 changes: 0 additions & 7 deletions apps/browser/src/autofill/services/autofill.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,6 @@ export default class AutofillService implements AutofillServiceInterface {
inlineMenuVisibility = await this.getInlineMenuVisibility();
}

const inlineMenuPositioningImprovements = await this.configService.getFeatureFlag(
FeatureFlag.InlineMenuPositioningImprovements,
);
if (!inlineMenuPositioningImprovements) {
return "bootstrap-legacy-autofill-overlay.js";
}

const enableChangedPasswordPrompt = await firstValueFrom(
this.userNotificationSettingsService.enableChangedPasswordPrompt$,
);
Expand Down
84 changes: 23 additions & 61 deletions apps/browser/src/background/main.background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@
import { CipherContextMenuHandler } from "../autofill/browser/cipher-context-menu-handler";
import { ContextMenuClickedHandler } from "../autofill/browser/context-menu-clicked-handler";
import { MainContextMenuHandler } from "../autofill/browser/main-context-menu-handler";
import LegacyOverlayBackground from "../autofill/deprecated/background/overlay.background.deprecated";
import { Fido2Background as Fido2BackgroundAbstraction } from "../autofill/fido2/background/abstractions/fido2.background";
import { Fido2Background } from "../autofill/fido2/background/fido2.background";
import { BrowserFido2UserInterfaceService } from "../autofill/fido2/services/browser-fido2-user-interface.service";
Expand Down Expand Up @@ -1133,6 +1132,27 @@
this.notificationBackground,
);

this.overlayBackground = new OverlayBackground(

Check warning on line 1135 in apps/browser/src/background/main.background.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/background/main.background.ts#L1135

Added line #L1135 was not covered by tests
this.logService,
this.cipherService,
this.autofillService,
this.authService,
this.environmentService,
this.domainSettingsService,
this.autofillSettingsService,
this.i18nService,
this.platformUtilsService,
this.vaultSettingsService,
this.fido2ActiveRequestManager,
this.themeStateService,
);

this.tabsBackground = new TabsBackground(

Check warning on line 1150 in apps/browser/src/background/main.background.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/background/main.background.ts#L1150

Added line #L1150 was not covered by tests
this,
this.notificationBackground,
this.overlayBackground,
);

this.filelessImporterBackground = new FilelessImporterBackground(
this.configService,
this.authService,
Expand Down Expand Up @@ -1268,6 +1288,8 @@
await this.runtimeBackground.init();
await this.notificationBackground.init();
this.overlayNotificationsBackground.init();
await this.overlayBackground.init();
await this.tabsBackground.init();

Check warning on line 1292 in apps/browser/src/background/main.background.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/background/main.background.ts#L1291-L1292

Added lines #L1291 - L1292 were not covered by tests
this.filelessImporterBackground.init();
this.commandsBackground.init();
this.contextMenusBackground?.init();
Expand Down Expand Up @@ -1297,8 +1319,6 @@
}
}

await this.initOverlayAndTabsBackground();

return new Promise<void>((resolve) => {
setTimeout(async () => {
await this.refreshBadge();
Expand Down Expand Up @@ -1578,62 +1598,4 @@
await this.syncService.fullSync(override);
}
}

/**
* Temporary solution to handle initialization of the overlay background behind a feature flag.
* Will be reverted to instantiation within the constructor once the feature flag is removed.
*/
async initOverlayAndTabsBackground() {
if (
this.popupOnlyContext ||
this.overlayBackground ||
this.tabsBackground ||
(await firstValueFrom(this.authService.activeAccountStatus$)) ===
AuthenticationStatus.LoggedOut
) {
return;
}

const inlineMenuPositioningImprovementsEnabled = await this.configService.getFeatureFlag(
FeatureFlag.InlineMenuPositioningImprovements,
);

if (!inlineMenuPositioningImprovementsEnabled) {
this.overlayBackground = new LegacyOverlayBackground(
this.cipherService,
this.autofillService,
this.authService,
this.environmentService,
this.domainSettingsService,
this.autofillSettingsService,
this.i18nService,
this.platformUtilsService,
this.themeStateService,
);
} else {
this.overlayBackground = new OverlayBackground(
this.logService,
this.cipherService,
this.autofillService,
this.authService,
this.environmentService,
this.domainSettingsService,
this.autofillSettingsService,
this.i18nService,
this.platformUtilsService,
this.vaultSettingsService,
this.fido2ActiveRequestManager,
this.themeStateService,
);
}

this.tabsBackground = new TabsBackground(
this,
this.notificationBackground,
this.overlayBackground,
);

await this.overlayBackground.init();
await this.tabsBackground.init();
}
}
1 change: 0 additions & 1 deletion apps/browser/src/background/runtime.background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ export default class RuntimeBackground {
let item: LockedVaultPendingNotificationsData;

if (msg.command === "loggedIn") {
await this.main.initOverlayAndTabsBackground();
await this.sendBwInstalledMessageToVault();
await this.autofillService.reloadAutofillScripts();
}
Expand Down
Loading