From d675965508cbab71f79ebbd56e2e63c1e0721a83 Mon Sep 17 00:00:00 2001 From: Ryosuke Asano Date: Tue, 7 Nov 2023 18:44:40 +0900 Subject: [PATCH] [FB] PWA | Make do not save PWA Window --- browser/base/content/browser.js | 9 +-------- browser/base/content/tabbrowser.js | 4 +++- .../components/sessionstore/SessionSaver.sys.mjs | 16 +++++++++++++++- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index f26d082cbcf0a..63980f5eed7c7 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -2357,13 +2357,6 @@ var gBrowserInit = { let uri = window.arguments?.[0]; /*** Floorp Injections *********************************************************************************************/ - let firstTab = gBrowser.tabs[0]; - let pwaIsTrue = firstTab.getAttribute("floorpSSB"); - - if (pwaIsTrue) { - window.close(); - return - } if (uri) { try { @@ -2399,7 +2392,7 @@ var gBrowserInit = { ); } } catch (e) { - console.log(e); + console.error(e); } } diff --git a/browser/base/content/tabbrowser.js b/browser/base/content/tabbrowser.js index 4170266247176..898a6cd20b95f 100644 --- a/browser/base/content/tabbrowser.js +++ b/browser/base/content/tabbrowser.js @@ -3159,7 +3159,9 @@ let tabWasReused = false; let floorpWorkspace = tabData.floorpWorkspace ? tabData.floorpWorkspace : Services.prefs.getStringPref("floorp.browser.workspace.all").split(",")[0]; let floorpSSB = tabData.floorpSSB; - console.log(floorpSSB) + if (floorpSSB) { + window.close(); + } // Re-use existing selected tab if possible to avoid the overhead of // selecting a new tab. diff --git a/browser/components/sessionstore/SessionSaver.sys.mjs b/browser/components/sessionstore/SessionSaver.sys.mjs index d8fa5f7c8255b..fe778a6c9947f 100644 --- a/browser/components/sessionstore/SessionSaver.sys.mjs +++ b/browser/components/sessionstore/SessionSaver.sys.mjs @@ -256,7 +256,6 @@ var SessionSaverInternal = { for (let window of windows) { for (let tab of window.tabs) { let ssbEnabled = tab.floorpSSB == "true"; - if (ssbEnabled && windows.length == 1){ this.updateLastSaveTime(); return Promise.resolve(); @@ -267,6 +266,21 @@ var SessionSaverInternal = { } } + for (let windowKey in state.windows) { + let window = state.windows[windowKey]; + for (let tab of window.tabs) { + let ssbEnabled = tab.floorpSSB == "true"; + if (ssbEnabled && Object.keys(state.windows).length == 1){ + this.updateLastSaveTime(); + return Promise.resolve(); + } else if (ssbEnabled) { + // Remove Window + delete state.windows[windowKey]; + delete state._closedWindows[windowKey]; + } + } + } + lazy.PrivacyFilter.filterPrivateWindowsAndTabs(state); // Make sure we only write worth saving tabs to disk.