mirror of
https://github.com/bitwarden/browser.git
synced 2025-02-05 23:41:28 +01:00
browserUtilsService.isViewOpen
This commit is contained in:
parent
701d81a2eb
commit
2986bd1e29
@ -14,4 +14,5 @@ export interface BrowserUtilsService {
|
||||
inTab(theWindow: Window): boolean;
|
||||
inPopout(theWindow: Window): boolean;
|
||||
inPopup(theWindow: Window): boolean;
|
||||
isViewOpen(): boolean;
|
||||
}
|
||||
|
@ -212,4 +212,23 @@ export default class BrowserUtilsService implements BrowserUtilsServiceInterface
|
||||
return theWindow.location.search === '' || theWindow.location.search.indexOf('uilocation=') === -1 ||
|
||||
theWindow.location.search.indexOf('uilocation=popup') > -1;
|
||||
}
|
||||
|
||||
isViewOpen(): boolean {
|
||||
const popupOpen = chrome.extension.getViews({ type: 'popup' }).length > 0;
|
||||
const tabOpen = chrome.extension.getViews({ type: 'tab' }).length > 0;
|
||||
const sidebarView = this.sidebarViewName();
|
||||
const sidebarOpen = sidebarView != null && chrome.extension.getViews({ type: sidebarView }).length > 0;
|
||||
|
||||
return popupOpen || tabOpen || sidebarOpen;
|
||||
}
|
||||
|
||||
private sidebarViewName(): string {
|
||||
if ((window as any).chrome.sidebarAction && this.isFirefox()) {
|
||||
return 'sidebar';
|
||||
} else if (this.isOpera() && (typeof opr !== 'undefined') && opr.sidebarAction) {
|
||||
return 'sidebar_panel';
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -29,12 +29,7 @@ export default class LockService {
|
||||
}
|
||||
|
||||
async checkLock(): Promise<void> {
|
||||
const popupOpen = chrome.extension.getViews({ type: 'popup' }).length > 0;
|
||||
const tabOpen = chrome.extension.getViews({ type: 'tab' }).length > 0;
|
||||
const sidebarView = this.sidebarViewName();
|
||||
const sidebarOpen = sidebarView != null && chrome.extension.getViews({ type: sidebarView }).length > 0;
|
||||
|
||||
if (popupOpen || tabOpen || sidebarOpen) {
|
||||
if (this.browserUtilsService.isViewOpen()) {
|
||||
// Do not lock
|
||||
return;
|
||||
}
|
||||
@ -77,16 +72,4 @@ export default class LockService {
|
||||
this.cipherService.clearCache();
|
||||
this.collectionService.clearCache();
|
||||
}
|
||||
|
||||
// Helpers
|
||||
|
||||
private sidebarViewName(): string {
|
||||
if ((window as any).chrome.sidebarAction && this.browserUtilsService.isFirefox()) {
|
||||
return 'sidebar';
|
||||
} else if (this.browserUtilsService.isOpera() && (typeof opr !== 'undefined') && opr.sidebarAction) {
|
||||
return 'sidebar_panel';
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user