1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-21 18:53:29 +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

@@ -1,6 +1,6 @@
import { DeviceType } from '../../enums/deviceType.enum';
export interface BrowserUtilsService {
export interface PlatformUtilsService {
getDevice(): DeviceType;
getDeviceString(): string;
isFirefox(): boolean;

View File

@@ -1,8 +1,9 @@
import AppIdService from './appId.service';
import BrowserUtilsService from './browserUtils.service';
import ConstantsService from './constants.service';
import TokenService from './token.service';
import { PlatformUtilsService } from './abstractions/platformUtils.service';
import EnvironmentUrls from '../models/domain/environmentUrls';
import { CipherRequest } from '../models/request/cipherRequest';
@@ -35,10 +36,10 @@ export default class ApiService {
deviceType: string;
logoutCallback: Function;
constructor(private tokenService: TokenService, browserUtilsService: BrowserUtilsService,
constructor(private tokenService: TokenService, platformUtilsService: PlatformUtilsService,
logoutCallback: Function) {
this.logoutCallback = logoutCallback;
this.deviceType = browserUtilsService.getDevice().toString();
this.deviceType = platformUtilsService.getDevice().toString();
}
setUrls(urls: EnvironmentUrls) {

View File

@@ -5,12 +5,13 @@ import AutofillField from '../models/domain/autofillField';
import AutofillPageDetails from '../models/domain/autofillPageDetails';
import AutofillScript from '../models/domain/autofillScript';
import BrowserUtilsService from './browserUtils.service';
import CipherService from './cipher.service';
import TokenService from './token.service';
import TotpService from './totp.service';
import UtilsService from './utils.service';
import { PlatformUtilsService } from '../services/abstractions/platformUtils.service';
const CardAttributes: string[] = ['autoCompleteType', 'data-stripe', 'htmlName', 'htmlID', 'label-tag',
'placeholder', 'label-left', 'label-top'];
@@ -94,7 +95,7 @@ var IsoProvinces: { [id: string]: string; } = {
export default class AutofillService {
constructor(public cipherService: CipherService, public tokenService: TokenService,
public totpService: TotpService, public utilsService: UtilsService,
public browserUtilsService: BrowserUtilsService) {
public platformUtilsService: PlatformUtilsService) {
}
getFormsWithPasswordFields(pageDetails: AutofillPageDetails): any[] {
@@ -169,7 +170,7 @@ export default class AutofillService {
}, { frameId: pd.frameId });
if (options.cipher.type !== CipherType.Login || totpPromise ||
(options.fromBackground && this.browserUtilsService.isFirefox()) || options.skipTotp ||
(options.fromBackground && this.platformUtilsService.isFirefox()) || options.skipTotp ||
!options.cipher.login.totp || !this.tokenService.getPremium()) {
return;
}
@@ -207,7 +208,7 @@ export default class AutofillService {
return;
}
const tabDomain = BrowserUtilsService.getDomain(tab.url);
const tabDomain = this.platformUtilsService.getDomain(tab.url);
if (tabDomain == null) {
return;
}

View File

@@ -1,8 +1,8 @@
import { BrowserUtilsService } from './abstractions/browserUtils.service';
import { MessagingService as MessagingServiceInterface } from './abstractions/messaging.service';
import { PlatformUtilsService } from './abstractions/platformUtils.service';
export default class BrowserMessagingService implements MessagingServiceInterface {
constructor(private browserUtilsService: BrowserUtilsService) {
constructor(private platformUtilsService: PlatformUtilsService) {
}
send(subscriber: string, arg: any = {}) {

View File

@@ -1,8 +1,8 @@
import { BrowserUtilsService } from './abstractions/browserUtils.service';
import { PlatformUtilsService } from './abstractions/platformUtils.service';
import { StorageService as StorageServiceInterface } from './abstractions/storage.service';
export default class BrowserStorageService implements StorageServiceInterface {
constructor(private browserUtilsService: BrowserUtilsService) {
constructor(private platformUtilsService: PlatformUtilsService) {
}
get<T>(key: string): Promise<T> {

View File

@@ -1,6 +1,6 @@
import * as tldjs from 'tldjs';
import { DeviceType } from '../enums/deviceType.enum';
import { BrowserUtilsService as BrowserUtilsServiceInterface } from './abstractions/browserUtils.service';
import { PlatformUtilsService as PlatformUtilsServiceInterface } from './abstractions/platformUtils.service';
const AnalyticsIds = {
[DeviceType.Chrome]: 'UA-81915606-6',
@@ -11,7 +11,7 @@ const AnalyticsIds = {
[DeviceType.Safari]: 'UA-81915606-16',
};
export default class BrowserUtilsService implements BrowserUtilsServiceInterface {
export default class BrowserUtilsService implements PlatformUtilsServiceInterface {
static getDomain(uriString: string): string {
if (uriString == null) {
return null;

View File

@@ -1,4 +1,4 @@
import BrowserUtilsService from './browserUtils.service';
import { PlatformUtilsService } from './abstractions/platformUtils.service';
export default class ConstantsService {
static readonly environmentUrlsKey: string = 'environmentUrls';
@@ -57,8 +57,8 @@ export default class ConstantsService {
twoFactorProviderInfo: any[];
constructor(i18nService: any, browserUtilsService: BrowserUtilsService) {
if (browserUtilsService.isEdge()) {
constructor(i18nService: any, platformUtilsService: PlatformUtilsService) {
if (platformUtilsService.isEdge()) {
// delay for i18n fetch
setTimeout(() => {
this.bootstrap(i18nService);

View File

@@ -1,9 +1,9 @@
import BrowserUtilsService from '../services/browserUtils.service';
import { PlatformUtilsService } from './abstractions/platformUtils.service';
export default function i18nService(browserUtilsService: BrowserUtilsService) {
export default function i18nService(platformUtilsService: PlatformUtilsService) {
const edgeMessages: any = {};
if (browserUtilsService.isEdge()) {
if (platformUtilsService.isEdge()) {
fetch('../_locales/en/messages.json').then((file) => {
return file.json();
}).then((locales) => {

View File

@@ -1,23 +1,23 @@
import BrowserUtilsService from './browserUtils.service';
import CipherService from './cipher.service';
import CollectionService from './collection.service';
import ConstantsService from './constants.service';
import CryptoService from './crypto.service';
import FolderService from './folder.service';
import { PlatformUtilsService } from './abstractions/platformUtils.service';
import { StorageService } from './abstractions/storage.service';
export default class LockService {
constructor(private cipherService: CipherService, private folderService: FolderService,
private collectionService: CollectionService, private cryptoService: CryptoService,
private browserUtilsService: BrowserUtilsService, private storageService: StorageService,
private platformUtilsService: PlatformUtilsService, private storageService: StorageService,
private setIcon: Function, private refreshBadgeAndMenu: Function) {
this.checkLock();
setInterval(() => this.checkLock(), 10 * 1000); // check every 10 seconds
}
async checkLock(): Promise<void> {
if (this.browserUtilsService.isViewOpen()) {
if (this.platformUtilsService.isViewOpen()) {
// Do not lock
return;
}