mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 00:33:44 +00:00
Safari Web Extension Port from App Extension (#1531)
This commit is contained in:
@@ -4,7 +4,6 @@ import { CipherView } from 'jslib/models/view/cipherView';
|
||||
import { LoginUriView } from 'jslib/models/view/loginUriView';
|
||||
import { LoginView } from 'jslib/models/view/loginView';
|
||||
|
||||
import { AuthService } from 'jslib/abstractions/auth.service';
|
||||
import { AutofillService } from '../services/abstractions/autofill.service';
|
||||
import BrowserPlatformUtilsService from '../services/browserPlatformUtils.service';
|
||||
import { CipherService } from 'jslib/abstractions/cipher.service';
|
||||
@@ -13,10 +12,7 @@ import { EnvironmentService } from 'jslib/abstractions/environment.service';
|
||||
import { I18nService } from 'jslib/abstractions/i18n.service';
|
||||
import { NotificationsService } from 'jslib/abstractions/notifications.service';
|
||||
import { PolicyService } from 'jslib/abstractions/policy.service';
|
||||
import { PopupUtilsService } from '../popup/services/popup-utils.service';
|
||||
import { StateService } from 'jslib/abstractions/state.service';
|
||||
import { StorageService } from 'jslib/abstractions/storage.service';
|
||||
import { SyncService } from 'jslib/abstractions/sync.service';
|
||||
import { SystemService } from 'jslib/abstractions/system.service';
|
||||
import { UserService } from 'jslib/abstractions/user.service';
|
||||
import { VaultTimeoutService } from 'jslib/abstractions/vaultTimeout.service';
|
||||
@@ -24,7 +20,6 @@ import { VaultTimeoutService } from 'jslib/abstractions/vaultTimeout.service';
|
||||
import { BrowserApi } from '../browser/browserApi';
|
||||
|
||||
import MainBackground from './main.background';
|
||||
import { NativeMessagingBackground } from './nativeMessaging.background';
|
||||
|
||||
import { Analytics } from 'jslib/misc';
|
||||
import { Utils } from 'jslib/misc/utils';
|
||||
@@ -36,7 +31,6 @@ export default class RuntimeBackground {
|
||||
private runtime: any;
|
||||
private autofillTimeout: any;
|
||||
private pageDetailsToAutoFill: any[] = [];
|
||||
private isSafari: boolean;
|
||||
private onInstalledReason: string = null;
|
||||
|
||||
constructor(private main: MainBackground, private autofillService: AutofillService,
|
||||
@@ -46,19 +40,15 @@ export default class RuntimeBackground {
|
||||
private systemService: SystemService, private vaultTimeoutService: VaultTimeoutService,
|
||||
private environmentService: EnvironmentService, private policyService: PolicyService,
|
||||
private userService: UserService) {
|
||||
this.isSafari = this.platformUtilsService.isSafari();
|
||||
this.runtime = this.isSafari ? {} : chrome.runtime;
|
||||
|
||||
// onInstalled listener must be wired up before anything else, so we do it in the ctor
|
||||
if (!this.isSafari) {
|
||||
this.runtime.onInstalled.addListener((details: any) => {
|
||||
this.onInstalledReason = details.reason;
|
||||
});
|
||||
}
|
||||
chrome.runtime.onInstalled.addListener((details: any) => {
|
||||
this.onInstalledReason = details.reason;
|
||||
});
|
||||
}
|
||||
|
||||
async init() {
|
||||
if (!this.runtime) {
|
||||
if (!chrome.runtime) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -399,20 +389,6 @@ export default class RuntimeBackground {
|
||||
}
|
||||
|
||||
private async checkOnInstalled() {
|
||||
if (this.isSafari) {
|
||||
const installedVersion = await this.storageService.get<string>(ConstantsService.installedVersionKey);
|
||||
if (installedVersion == null) {
|
||||
this.onInstalledReason = 'install';
|
||||
} else if (BrowserApi.getApplicationVersion() !== installedVersion) {
|
||||
this.onInstalledReason = 'update';
|
||||
}
|
||||
|
||||
if (this.onInstalledReason != null) {
|
||||
await this.storageService.save(ConstantsService.installedVersionKey,
|
||||
BrowserApi.getApplicationVersion());
|
||||
}
|
||||
}
|
||||
|
||||
setTimeout(async () => {
|
||||
if (this.onInstalledReason != null) {
|
||||
if (this.onInstalledReason === 'install') {
|
||||
|
||||
Reference in New Issue
Block a user