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

[PM-5879] Remove backgroundWindow reference used for determing system theme preference in Safari (#7859)

* [PM-5879] Removing `backgroundWindow` reference used for determing system theme preference in Safari

* [PM-5879] Removing `backgroundWindow` reference used for determing system theme preference in Safari

* [PM-5879] Reworking factory logic within ThemingService factory
This commit is contained in:
Cesar Gonzalez 2024-03-05 13:42:16 -06:00 committed by GitHub
parent 16c5fe65ca
commit 8e3a723908
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 10 deletions

View File

@ -305,9 +305,6 @@ export default class MainBackground {
stateEventRunnerService: StateEventRunnerService; stateEventRunnerService: StateEventRunnerService;
ssoLoginService: SsoLoginServiceAbstraction; ssoLoginService: SsoLoginServiceAbstraction;
// Passed to the popup for Safari to workaround issues with theming, downloading, etc.
backgroundWindow = window;
onUpdatedRan: boolean; onUpdatedRan: boolean;
onReplacedRan: boolean; onReplacedRan: boolean;
loginToAutoFill: CipherView = null; loginToAutoFill: CipherView = null;

View File

@ -509,13 +509,15 @@ function getBgService<T>(service: keyof MainBackground) {
stateService: StateServiceAbstraction, stateService: StateServiceAbstraction,
platformUtilsService: PlatformUtilsService, platformUtilsService: PlatformUtilsService,
) => { ) => {
return new ThemingService(
stateService,
// Safari doesn't properly handle the (prefers-color-scheme) media query in the popup window, it always returns light. // Safari doesn't properly handle the (prefers-color-scheme) media query in the popup window, it always returns light.
// In Safari we have to use the background page instead, which comes with limitations like not dynamically changing the extension theme when the system theme is changed. // In Safari, we have to use the background page instead, which comes with limitations like not dynamically changing the extension theme when the system theme is changed.
platformUtilsService.isSafari() ? getBgService<Window>("backgroundWindow")() : window, let windowContext = window;
document, const backgroundWindow = BrowserApi.getBackgroundPage();
); if (platformUtilsService.isSafari() && backgroundWindow) {
windowContext = backgroundWindow;
}
return new ThemingService(stateService, windowContext, document);
}, },
deps: [StateServiceAbstraction, PlatformUtilsService], deps: [StateServiceAbstraction, PlatformUtilsService],
}, },