mirror of
https://github.com/bitwarden/browser.git
synced 2024-09-27 04:03:00 +02:00
[fix] System theming in the Safari extension (#3107)
This commit is contained in:
parent
97f544f7e1
commit
4be301f125
@ -153,6 +153,9 @@ export default class MainBackground {
|
|||||||
broadcasterService: BroadcasterService;
|
broadcasterService: BroadcasterService;
|
||||||
folderApiService: FolderApiServiceAbstraction;
|
folderApiService: FolderApiServiceAbstraction;
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
@ -7,6 +7,8 @@ import {
|
|||||||
MEMORY_STORAGE,
|
MEMORY_STORAGE,
|
||||||
SECURE_STORAGE,
|
SECURE_STORAGE,
|
||||||
} from "@bitwarden/angular/services/jslib-services.module";
|
} from "@bitwarden/angular/services/jslib-services.module";
|
||||||
|
import { ThemingService } from "@bitwarden/angular/services/theming/theming.service";
|
||||||
|
import { AbstractThemingService } from "@bitwarden/angular/services/theming/theming.service.abstraction";
|
||||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||||
import { AppIdService } from "@bitwarden/common/abstractions/appId.service";
|
import { AppIdService } from "@bitwarden/common/abstractions/appId.service";
|
||||||
import { AuditService } from "@bitwarden/common/abstractions/audit.service";
|
import { AuditService } from "@bitwarden/common/abstractions/audit.service";
|
||||||
@ -293,6 +295,20 @@ function getBgService<T>(service: keyof MainBackground) {
|
|||||||
provide: FileDownloadService,
|
provide: FileDownloadService,
|
||||||
useClass: BrowserFileDownloadService,
|
useClass: BrowserFileDownloadService,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
provide: AbstractThemingService,
|
||||||
|
useFactory: () => {
|
||||||
|
return new ThemingService(
|
||||||
|
getBgService<StateServiceAbstraction>("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.
|
||||||
|
getBgService<PlatformUtilsService>("platformUtilsService")().isSafari()
|
||||||
|
? getBgService<Window>("backgroundWindow")()
|
||||||
|
: window,
|
||||||
|
document
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class ServicesModule {}
|
export class ServicesModule {}
|
||||||
|
@ -17,7 +17,7 @@ export class ThemingService implements AbstractThemingService {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private stateService: StateService,
|
private stateService: StateService,
|
||||||
private mediaMatcher: MediaMatcher,
|
private mediaMatcher: MediaMatcher | Window,
|
||||||
@Inject(DOCUMENT) private document: Document
|
@Inject(DOCUMENT) private document: Document
|
||||||
) {
|
) {
|
||||||
this.monitorThemeChanges();
|
this.monitorThemeChanges();
|
||||||
|
Loading…
Reference in New Issue
Block a user