mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 08:13:42 +00:00
browserUtilsService.isViewOpen
This commit is contained in:
@@ -14,4 +14,5 @@ export interface BrowserUtilsService {
|
|||||||
inTab(theWindow: Window): boolean;
|
inTab(theWindow: Window): boolean;
|
||||||
inPopout(theWindow: Window): boolean;
|
inPopout(theWindow: Window): boolean;
|
||||||
inPopup(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 ||
|
return theWindow.location.search === '' || theWindow.location.search.indexOf('uilocation=') === -1 ||
|
||||||
theWindow.location.search.indexOf('uilocation=popup') > -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> {
|
async checkLock(): Promise<void> {
|
||||||
const popupOpen = chrome.extension.getViews({ type: 'popup' }).length > 0;
|
if (this.browserUtilsService.isViewOpen()) {
|
||||||
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) {
|
|
||||||
// Do not lock
|
// Do not lock
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -77,16 +72,4 @@ export default class LockService {
|
|||||||
this.cipherService.clearCache();
|
this.cipherService.clearCache();
|
||||||
this.collectionService.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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user