mirror of
https://github.com/bitwarden/browser.git
synced 2025-01-19 20:51:35 +01:00
avoid chrome refs
This commit is contained in:
parent
625ae961c4
commit
6b507c9071
@ -100,6 +100,7 @@ export default class MainBackground {
|
|||||||
private buildingContextMenu: boolean;
|
private buildingContextMenu: boolean;
|
||||||
private menuOptionsLoaded: any[] = [];
|
private menuOptionsLoaded: any[] = [];
|
||||||
private syncTimeout: number;
|
private syncTimeout: number;
|
||||||
|
private isSafari: boolean;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
// Services
|
// Services
|
||||||
@ -136,7 +137,8 @@ export default class MainBackground {
|
|||||||
this.containerService = new ContainerService(this.cryptoService, this.platformUtilsService);
|
this.containerService = new ContainerService(this.cryptoService, this.platformUtilsService);
|
||||||
|
|
||||||
// Other fields
|
// Other fields
|
||||||
this.sidebarAction = (typeof opr !== 'undefined') && opr.sidebarAction ?
|
this.isSafari = this.platformUtilsService.isSafari();
|
||||||
|
this.sidebarAction = this.isSafari ? null : (typeof opr !== 'undefined') && opr.sidebarAction ?
|
||||||
opr.sidebarAction : (window as any).chrome.sidebarAction;
|
opr.sidebarAction : (window as any).chrome.sidebarAction;
|
||||||
|
|
||||||
// Background
|
// Background
|
||||||
@ -154,6 +156,7 @@ export default class MainBackground {
|
|||||||
async bootstrap() {
|
async bootstrap() {
|
||||||
this.containerService.attachToWindow(window);
|
this.containerService.attachToWindow(window);
|
||||||
|
|
||||||
|
if (!this.isSafari) {
|
||||||
await this.commandsBackground.init();
|
await this.commandsBackground.init();
|
||||||
await this.contextMenusBackground.init();
|
await this.contextMenusBackground.init();
|
||||||
await this.idleBackground.init();
|
await this.idleBackground.init();
|
||||||
@ -161,6 +164,7 @@ export default class MainBackground {
|
|||||||
await this.tabsBackground.init();
|
await this.tabsBackground.init();
|
||||||
await this.webRequestBackground.init();
|
await this.webRequestBackground.init();
|
||||||
await this.windowsBackground.init();
|
await this.windowsBackground.init();
|
||||||
|
}
|
||||||
|
|
||||||
await this.environmentService.setUrlsFromStorage();
|
await this.environmentService.setUrlsFromStorage();
|
||||||
await this.setIcon();
|
await this.setIcon();
|
||||||
@ -169,7 +173,7 @@ export default class MainBackground {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async setIcon() {
|
async setIcon() {
|
||||||
if (!chrome.browserAction && !this.sidebarAction) {
|
if (this.isSafari || (!chrome.browserAction && !this.sidebarAction)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,7 +192,7 @@ export default class MainBackground {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async refreshBadgeAndMenu() {
|
async refreshBadgeAndMenu() {
|
||||||
if (!chrome.windows || !chrome.contextMenus) {
|
if (this.isSafari || !chrome.windows || !chrome.contextMenus) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,7 +269,7 @@ export default class MainBackground {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async buildContextMenu() {
|
private async buildContextMenu() {
|
||||||
if (!chrome.contextMenus || this.buildingContextMenu) {
|
if (this.isSafari || !chrome.contextMenus || this.buildingContextMenu) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ angular
|
|||||||
$urlRouterProvider.otherwise(function ($injector, $location) {
|
$urlRouterProvider.otherwise(function ($injector, $location) {
|
||||||
var $state = $injector.get('$state');
|
var $state = $injector.get('$state');
|
||||||
|
|
||||||
if (!chrome.extension.getBackgroundPage()) {
|
if ((typeof chrome !== 'undefined') && !chrome.extension.getBackgroundPage()) {
|
||||||
$state.go('privateMode');
|
$state.go('privateMode');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -250,9 +250,8 @@ angular
|
|||||||
params: { animation: null }
|
params: { animation: null }
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.run(function ($trace, $transitions, userService, $state, constantsService, stateService) {
|
.run(function ($trace, $transitions, userService, $state, constantsService, stateService,
|
||||||
//$trace.enable('TRANSITION');
|
storageService, messagingService) {
|
||||||
|
|
||||||
stateService.init();
|
stateService.init();
|
||||||
|
|
||||||
$transitions.onStart({}, function (trans) {
|
$transitions.onStart({}, function (trans) {
|
||||||
@ -265,17 +264,14 @@ angular
|
|||||||
}
|
}
|
||||||
|
|
||||||
const userService = trans.injector().get('userService');
|
const userService = trans.injector().get('userService');
|
||||||
const messagingService = trans.injector().get('messagingService');
|
|
||||||
|
|
||||||
if (!userService || !messagingService) {
|
if (!userService) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
userService.isAuthenticated().then((isAuthenticated) => {
|
userService.isAuthenticated().then((isAuthenticated) => {
|
||||||
if (isAuthenticated) {
|
if (isAuthenticated) {
|
||||||
var obj = {};
|
storageService.save(constantsService.lastActiveKey, (new Date()).getTime());
|
||||||
obj[constantsService.lastActiveKey] = (new Date()).getTime();
|
|
||||||
chrome.storage.local.set(obj, function () { });
|
|
||||||
}
|
}
|
||||||
else if (toState.data && toState.data.authorize) {
|
else if (toState.data && toState.data.authorize) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
Loading…
Reference in New Issue
Block a user