Skip to content

Commit

Permalink
♻️ Chrome Tabs instantiation method renamed to newTabContainer
Browse files Browse the repository at this point in the history
Signed-off-by: Marc Nuri <[email protected]>
  • Loading branch information
manusa committed Nov 5, 2022
1 parent f3cd6f7 commit 41940c1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/chrome-tabs/__tests__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ describe('Chrome Tabs Module module test suite', () => {
};
chromeTabs = require('../');
});
describe('initTabContainer', () => {
describe('newTabContainer', () => {
test('webPreferences is sandboxed and has no node integration', () => {
// When
chromeTabs.initTabContainer(mainWindow);
chromeTabs.newTabContainer(mainWindow);
// Then
const BrowserView = require('electron').BrowserView;
expect(BrowserView).toHaveBeenCalledTimes(1);
Expand Down
8 changes: 6 additions & 2 deletions src/chrome-tabs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ const handleContextMenu = (event, params) => {
menu.popup({x, y});
};

const initTabContainer = () => {
/**
* Creates a new BrowserView instance with the Chrome Tabs
* @returns {Electron.CrossProcessExports.BrowserView}
*/
const newTabContainer = () => {
const tabContainer = new BrowserView({webPreferences});
tabContainer.isTabContainer = true;
tabContainer.setAutoResize({width: false, horizontal: false, height: false, vertical: false});
Expand All @@ -55,5 +59,5 @@ const initTabContainer = () => {
const isNotTabContainer = bv => bv.isTabContainer !== true;

module.exports = {
TABS_CONTAINER_HEIGHT, initTabContainer, isNotTabContainer
TABS_CONTAINER_HEIGHT, newTabContainer, isNotTabContainer
};
6 changes: 3 additions & 3 deletions src/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
const {BrowserWindow, Notification, app, desktopCapturer, ipcMain: ipc, nativeTheme} = require('electron');
const {APP_EVENTS} = require('../constants');
const {newAppMenu, isNotAppMenu} = require('../app-menu');
const {TABS_CONTAINER_HEIGHT, initTabContainer, isNotTabContainer} = require('../chrome-tabs');
const {TABS_CONTAINER_HEIGHT, newTabContainer, isNotTabContainer} = require('../chrome-tabs');
const {openHelpDialog} = require('../help');
const {loadSettings, updateSettings, openSettingsDialog} = require('../settings');
const {
Expand Down Expand Up @@ -182,7 +182,7 @@ const saveSettings = (_event, settings) => {
tabManager.removeAll();
const viewsToDestroy = [currentBrowserView, tabContainer];
viewsToDestroy.forEach(view => view.webContents.destroy());
tabContainer = initTabContainer();
tabContainer = newTabContainer();
};

const initGlobalListeners = () => {
Expand All @@ -200,7 +200,7 @@ const initGlobalListeners = () => {

const browserVersionsReady = () => {
app.userAgentFallback = userAgentForView(mainWindow);
tabContainer = initTabContainer();
tabContainer = newTabContainer();
appMenu = newAppMenu();
};

Expand Down

0 comments on commit 41940c1

Please sign in to comment.