1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 08:13:42 +00:00

rename browser utils to platform utils

This commit is contained in:
Kyle Spearrin
2018-01-05 16:30:15 -05:00
parent 01cf48bbed
commit 4a08bf6b71
39 changed files with 147 additions and 137 deletions

View File

@@ -36,13 +36,14 @@ import UserService from '../services/user.service';
import UtilsService from '../services/utils.service';
import { MessagingService } from '../services/abstractions/messaging.service';
import { PlatformUtilsService } from '../services/abstractions/platformUtils.service';
import { StorageService } from '../services/abstractions/storage.service';
export default class MainBackground {
messagingService: MessagingService;
storageService: StorageService;
i18nService: any;
browserUtilsService: BrowserUtilsService;
platformUtilsService: PlatformUtilsService;
utilsService: UtilsService;
constantsService: ConstantsService;
cryptoService: CryptoService;
@@ -82,16 +83,16 @@ export default class MainBackground {
constructor() {
// Services
this.utilsService = new UtilsService();
this.browserUtilsService = new BrowserUtilsService();
this.messagingService = new BrowserMessagingService(this.browserUtilsService);
this.storageService = new BrowserStorageService(this.browserUtilsService);
this.i18nService = i18nService(this.browserUtilsService);
this.constantsService = new ConstantsService(this.i18nService, this.browserUtilsService);
this.platformUtilsService = new BrowserUtilsService();
this.messagingService = new BrowserMessagingService(this.platformUtilsService);
this.storageService = new BrowserStorageService(this.platformUtilsService);
this.i18nService = i18nService(this.platformUtilsService);
this.constantsService = new ConstantsService(this.i18nService, this.platformUtilsService);
this.cryptoService = ContainerService.cryptoService = new CryptoService(this.storageService,
this.storageService);
this.tokenService = new TokenService(this.storageService);
this.appIdService = new AppIdService(this.storageService);
this.apiService = new ApiService(this.tokenService, this.browserUtilsService,
this.apiService = new ApiService(this.tokenService, this.platformUtilsService,
(expired: boolean) => this.logout(expired));
this.environmentService = new EnvironmentService(this.apiService, this.storageService);
this.userService = new UserService(this.tokenService, this.storageService);
@@ -102,7 +103,7 @@ export default class MainBackground {
this.apiService, this.storageService);
this.collectionService = new CollectionService(this.cryptoService, this.userService, this.storageService);
this.lockService = new LockService(this.cipherService, this.folderService, this.collectionService,
this.cryptoService, this.browserUtilsService, this.storageService,
this.cryptoService, this.platformUtilsService, this.storageService,
() => this.setIcon(), () => this.refreshBadgeAndMenu());
this.syncService = new SyncService(this.userService, this.apiService, this.settingsService,
this.folderService, this.cipherService, this.cryptoService, this.collectionService,
@@ -110,7 +111,7 @@ export default class MainBackground {
this.passwordGenerationService = new PasswordGenerationService(this.cryptoService, this.storageService);
this.totpService = new TotpService(this.storageService);
this.autofillService = new AutofillService(this.cipherService, this.tokenService,
this.totpService, this.utilsService, this.browserUtilsService);
this.totpService, this.utilsService, this.platformUtilsService);
// Other fields
this.sidebarAction = (typeof opr !== 'undefined') && opr.sidebarAction ?
@@ -121,9 +122,10 @@ export default class MainBackground {
this.contextMenusBackground = new ContextMenusBackground(this, this.cipherService,
this.passwordGenerationService);
this.idleBackground = new IdleBackground(this, this.lockService, this.storageService);
this.runtimeBackground = new RuntimeBackground(this, this.autofillService, this.cipherService);
this.runtimeBackground = new RuntimeBackground(this, this.autofillService, this.cipherService,
this.platformUtilsService);
this.tabsBackground = new TabsBackground(this);
this.webRequestBackground = new WebRequestBackground(this.browserUtilsService, this.cipherService);
this.webRequestBackground = new WebRequestBackground(this.platformUtilsService, this.cipherService);
this.windowsBackground = new WindowsBackground(this);
}
@@ -262,7 +264,7 @@ export default class MainBackground {
});
// Firefox & Edge do not support writing to the clipboard from background
if (!this.browserUtilsService.isFirefox() && !this.browserUtilsService.isEdge()) {
if (!this.platformUtilsService.isFirefox() && !this.platformUtilsService.isEdge()) {
await this.contextMenusCreate({
type: 'normal',
id: 'copy-username',
@@ -306,7 +308,7 @@ export default class MainBackground {
return;
}
const tabDomain = BrowserUtilsService.getDomain(url);
const tabDomain = this.platformUtilsService.getDomain(url);
if (tabDomain == null) {
return;
}
@@ -381,7 +383,7 @@ export default class MainBackground {
});
}
if (this.browserUtilsService.isFirefox()) {
if (this.platformUtilsService.isFirefox()) {
// Firefox does not support writing to the clipboard from background
return;
}
@@ -422,7 +424,7 @@ export default class MainBackground {
return;
}
const tabDomain = BrowserUtilsService.getDomain(tab.url);
const tabDomain = this.platformUtilsService.getDomain(tab.url);
if (tabDomain == null) {
return;
}
@@ -500,7 +502,7 @@ export default class MainBackground {
},
};
if (this.browserUtilsService.isFirefox()) {
if (this.platformUtilsService.isFirefox()) {
await theAction.setIcon(options);
} else {
return new Promise((resolve) => {

View File

@@ -5,17 +5,18 @@ import BrowserApi from '../browser/browserApi';
import MainBackground from './main.background';
import AutofillService from '../services/autofill.service';
import BrowserUtilsService from '../services/browserUtils.service';
import CipherService from '../services/cipher.service';
import UtilsService from '../services/utils.service';
import { PlatformUtilsService } from '../services/abstractions/platformUtils.service';
export default class RuntimeBackground {
private runtime: any;
private autofillTimeout: number;
private pageDetailsToAutoFill: any[] = [];
constructor(private main: MainBackground, private autofillService: AutofillService,
private cipherService: CipherService) {
private cipherService: CipherService, private platformUtilsService: PlatformUtilsService) {
this.runtime = chrome.runtime;
}
@@ -135,7 +136,7 @@ export default class RuntimeBackground {
}
const loginInfo = this.main.loginsToAdd[i];
const tabDomain = BrowserUtilsService.getDomain(tab.url);
const tabDomain = this.platformUtilsService.getDomain(tab.url);
if (tabDomain != null && tabDomain !== loginInfo.domain) {
continue;
}
@@ -173,7 +174,7 @@ export default class RuntimeBackground {
}
const loginInfo = this.main.loginsToAdd[i];
const tabDomain = BrowserUtilsService.getDomain(tab.url);
const tabDomain = this.platformUtilsService.getDomain(tab.url);
if (tabDomain != null && tabDomain !== loginInfo.domain) {
continue;
}
@@ -186,7 +187,7 @@ export default class RuntimeBackground {
}
private async addLogin(loginInfo: any, tab: any) {
const loginDomain = BrowserUtilsService.getDomain(loginInfo.url);
const loginDomain = this.platformUtilsService.getDomain(loginInfo.url);
if (loginDomain == null) {
return;
}

View File

@@ -1,14 +1,15 @@
import BrowserUtilsService from '../services/browserUtils.service';
import CipherService from '../services/cipher.service';
import { PlatformUtilsService } from '../services/abstractions/platformUtils.service';
export default class WebRequestBackground {
private pendingAuthRequests: any[] = [];
private webRequest: any;
private isFirefox: boolean;
constructor(browserUtilsService: BrowserUtilsService, private cipherService: CipherService) {
constructor(private platformUtilsService: PlatformUtilsService, private cipherService: CipherService) {
this.webRequest = (window as any).chrome.webRequest;
this.isFirefox = browserUtilsService.isFirefox();
this.isFirefox = platformUtilsService.isFirefox();
}
async init() {
@@ -24,7 +25,7 @@ export default class WebRequestBackground {
return;
}
const domain = BrowserUtilsService.getDomain(details.url);
const domain = this.platformUtilsService.getDomain(details.url);
if (domain == null) {
if (callback) {
callback();