Skip to content

Commit 262e889

Browse files
authored
Remove waslocked
1 parent 96f6607 commit 262e889

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

background.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ state.ignoredTabs = new Set();
2626
state.mutedMedia = new Set(); // Tab IDs of resumable muted media.
2727
state.legacyMedia = new Set(); // Tab IDs of old media.
2828
state.autoPauseWindow = null;
29-
state.denyPlayback = false;
29+
state.locked = false;
3030

3131
let resolveInitialization;
3232
const initializationCompletePromise = new Promise((resolve) => {
@@ -405,7 +405,7 @@ function autoResume(id) {
405405
hasProperty(options, 'disableresume') ||
406406
state.media.size === 0 ||
407407
(state.otherTabs.size > 0 && !hasProperty(options, 'ignoreother')) ||
408-
state.denyPlayback
408+
state.locked
409409
)
410410
return;
411411
if (
@@ -494,7 +494,7 @@ chrome.tabs.onUpdated.addListener(async (tabId, changeInfo, tab) => {
494494

495495
function denyPlay(tab, userActivation = false) {
496496
// Security: Logic used to determine if videos are not allowed to play.
497-
if (state.denyPlayback) return true;
497+
if (state.locked) return true;
498498
if (userActivation) return false;
499499
if (tab.id === state.activeTab) return false;
500500
if (tab.id === state.lastPlaying) return false;
@@ -505,7 +505,7 @@ function denyPlay(tab, userActivation = false) {
505505

506506
async function denyPause(id, exclude, skipLast, allowbg, auto) {
507507
// Security: Logic used to determine if the extension is not allowed to pause automatically.
508-
if (state.denyPlayback) return false;
508+
if (state.locked) return false;
509509
if (id === exclude) return true;
510510
if (allowbg && state.backgroundaudio.has(id)) return true;
511511
if (skipLast && id === state.lastPlaying) return true;
@@ -698,14 +698,12 @@ async function checkIdle(userState) {
698698
await initializationCompletePromise;
699699
if (!hasProperty(options, 'checkidle')) return;
700700
if (userState === 'locked') {
701-
state.waslocked = true;
702-
// Security: While locked no media should be playing and state.denyPlayback should stay true.
703-
state.denyPlayback = true;
701+
// Security: While locked no media should be playing and state.locked should stay true.
702+
state.locked = true;
704703
// Pause everything
705704
pauseAll();
706-
} else if (state.waslocked) {
707-
state.waslocked = false;
708-
state.denyPlayback = false;
705+
} else if (state.locked) {
706+
state.locked = false;
709707
const tabId = getResumeTab();
710708
if (tabId !== false) play(tabId);
711709
}

0 commit comments

Comments
 (0)