[MM-36793][MM-37954] Upgrade to Electron v13.2.0 (#1707)
* [MM-36793][MM-37954] Upgrade to Electron v13.2.0 * Update config.yml
This commit is contained in:
@@ -89,72 +89,70 @@ const denyNewWindow = (event: Event, url: string) => {
|
||||
};
|
||||
|
||||
const generateNewWindowListener = (getServersFunction: () => TeamWithTabs[], spellcheck?: boolean) => {
|
||||
return (event: Event, url: string) => {
|
||||
const parsedURL = urlUtils.parseURL(url);
|
||||
return (details: Electron.HandlerDetails): {action: 'deny' | 'allow'} => {
|
||||
const parsedURL = urlUtils.parseURL(details.url);
|
||||
if (!parsedURL) {
|
||||
event.preventDefault();
|
||||
log.warn(`Ignoring non-url ${url}`);
|
||||
return;
|
||||
log.warn(`Ignoring non-url ${details.url}`);
|
||||
return {action: 'deny'};
|
||||
}
|
||||
|
||||
const configServers = getServersFunction();
|
||||
|
||||
// Dev tools case
|
||||
if (parsedURL.protocol === 'devtools:') {
|
||||
return;
|
||||
return {action: 'allow'};
|
||||
}
|
||||
event.preventDefault();
|
||||
|
||||
// Check for valid URL
|
||||
if (!urlUtils.isValidURI(url)) {
|
||||
return;
|
||||
if (!urlUtils.isValidURI(details.url)) {
|
||||
return {action: 'deny'};
|
||||
}
|
||||
|
||||
// Check for custom protocol
|
||||
if (parsedURL.protocol !== 'http:' && parsedURL.protocol !== 'https:' && parsedURL.protocol !== `${scheme}:`) {
|
||||
allowProtocolDialog.handleDialogEvent(parsedURL.protocol, url);
|
||||
return;
|
||||
allowProtocolDialog.handleDialogEvent(parsedURL.protocol, details.url);
|
||||
return {action: 'deny'};
|
||||
}
|
||||
|
||||
const server = urlUtils.getView(parsedURL, configServers);
|
||||
|
||||
if (!server) {
|
||||
shell.openExternal(url);
|
||||
return;
|
||||
shell.openExternal(details.url);
|
||||
return {action: 'deny'};
|
||||
}
|
||||
|
||||
// Public download links case
|
||||
// TODO: We might be handling different types differently in the future, for now
|
||||
// we are going to mimic the browser and just pop a new browser window for public links
|
||||
if (parsedURL.pathname.match(/^(\/api\/v[3-4]\/public)*\/files\//)) {
|
||||
shell.openExternal(url);
|
||||
return;
|
||||
shell.openExternal(details.url);
|
||||
return {action: 'deny'};
|
||||
}
|
||||
|
||||
// Image proxy case
|
||||
if (parsedURL.pathname.match(/^\/api\/v[3-4]\/image/)) {
|
||||
shell.openExternal(url);
|
||||
return;
|
||||
shell.openExternal(details.url);
|
||||
return {action: 'deny'};
|
||||
}
|
||||
|
||||
if (parsedURL.pathname.match(/^\/help\//)) {
|
||||
// Help links case
|
||||
// continue to open special case internal urls in default browser
|
||||
shell.openExternal(url);
|
||||
return;
|
||||
shell.openExternal(details.url);
|
||||
return {action: 'deny'};
|
||||
}
|
||||
|
||||
if (urlUtils.isTeamUrl(server.url, parsedURL, true)) {
|
||||
WindowManager.showMainWindow(parsedURL);
|
||||
return;
|
||||
return {action: 'deny'};
|
||||
}
|
||||
if (urlUtils.isAdminUrl(server.url, parsedURL)) {
|
||||
log.info(`${url} is an admin console page, preventing to open a new window`);
|
||||
return;
|
||||
log.info(`${details.url} is an admin console page, preventing to open a new window`);
|
||||
return {action: 'deny'};
|
||||
}
|
||||
if (popupWindow && popupWindow.webContents.getURL() === url) {
|
||||
log.info(`Popup window already open at provided url: ${url}`);
|
||||
return;
|
||||
if (popupWindow && popupWindow.webContents.getURL() === details.url) {
|
||||
log.info(`Popup window already open at provided url: ${details.url}`);
|
||||
return {action: 'deny'};
|
||||
}
|
||||
|
||||
// TODO: move popups to its own and have more than one.
|
||||
@@ -183,15 +181,17 @@ const generateNewWindowListener = (getServersFunction: () => TeamWithTabs[], spe
|
||||
}
|
||||
|
||||
if (urlUtils.isManagedResource(server.url, parsedURL)) {
|
||||
popupWindow.loadURL(url);
|
||||
popupWindow.loadURL(details.url);
|
||||
} else {
|
||||
// currently changing the userAgent for popup windows to allow plugins to go through google's oAuth
|
||||
// should be removed once a proper oAuth2 implementation is setup.
|
||||
popupWindow.loadURL(url, {
|
||||
popupWindow.loadURL(details.url, {
|
||||
userAgent: composeUserAgent(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return {action: 'deny'};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -226,7 +226,7 @@ export const addWebContentsEventListeners = (mmview: MattermostView, getServersF
|
||||
|
||||
const spellcheck = mmview.options.webPreferences?.spellcheck;
|
||||
const newWindow = generateNewWindowListener(getServersFunction, spellcheck);
|
||||
contents.on('new-window', newWindow);
|
||||
contents.setWindowOpenHandler(newWindow);
|
||||
|
||||
contents.on('page-title-updated', mmview.handleTitleUpdate);
|
||||
contents.on('page-favicon-updated', mmview.handleFaviconUpdate);
|
||||
@@ -237,7 +237,6 @@ export const addWebContentsEventListeners = (mmview: MattermostView, getServersF
|
||||
try {
|
||||
contents.removeListener('will-navigate', willNavigate as (e: Event, u: string) => void);
|
||||
contents.removeListener('did-start-navigation', didStartNavigation as (e: Event, u: string) => void);
|
||||
contents.removeListener('new-window', newWindow);
|
||||
contents.removeListener('page-title-updated', mmview.handleTitleUpdate);
|
||||
contents.removeListener('page-favicon-updated', mmview.handleFaviconUpdate);
|
||||
contents.removeListener('update-target-url', mmview.handleUpdateTarget);
|
||||
|
@@ -71,7 +71,7 @@ function createMainWindow(config: CombinedConfig, options: {linuxAppIcon: string
|
||||
frame: !isFramelessWindow(),
|
||||
fullscreen: savedWindowState.fullscreen,
|
||||
titleBarStyle: 'hidden' as const,
|
||||
trafficLightPosition: {x: 12, y: 24},
|
||||
trafficLightPosition: {x: 12, y: 12},
|
||||
backgroundColor: '#fff', // prevents blurry text: https://electronjs.org/docs/faq#the-font-looks-blurry-what-is-this-and-what-can-i-do
|
||||
webPreferences: {
|
||||
nodeIntegration: process.env.NODE_ENV === 'test',
|
||||
|
Reference in New Issue
Block a user