mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-25 12:15:18 +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:
parent
16c5fe65ca
commit
8e3a723908
@ -305,9 +305,6 @@ export default class MainBackground {
|
||||
stateEventRunnerService: StateEventRunnerService;
|
||||
ssoLoginService: SsoLoginServiceAbstraction;
|
||||
|
||||
// Passed to the popup for Safari to workaround issues with theming, downloading, etc.
|
||||
backgroundWindow = window;
|
||||
|
||||
onUpdatedRan: boolean;
|
||||
onReplacedRan: boolean;
|
||||
loginToAutoFill: CipherView = null;
|
||||
|
@ -509,13 +509,15 @@ function getBgService<T>(service: keyof MainBackground) {
|
||||
stateService: StateServiceAbstraction,
|
||||
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.
|
||||
// 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,
|
||||
document,
|
||||
);
|
||||
// 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.
|
||||
let windowContext = window;
|
||||
const backgroundWindow = BrowserApi.getBackgroundPage();
|
||||
if (platformUtilsService.isSafari() && backgroundWindow) {
|
||||
windowContext = backgroundWindow;
|
||||
}
|
||||
|
||||
return new ThemingService(stateService, windowContext, document);
|
||||
},
|
||||
deps: [StateServiceAbstraction, PlatformUtilsService],
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user