diff --git a/index.js b/index.js index 281c5d3e6..036d33a1c 100644 --- a/index.js +++ b/index.js @@ -162,6 +162,9 @@ portDiscovery.on('runtime/launched', (portInfo) => { includeFlashPlugin(); +// Enable Single tenant for MAC +handleMacSingleTenant(); + // Opt in to launch crash reporter initializeCrashReporter(coreState.argo); @@ -712,6 +715,19 @@ function registerMacMenu() { } } +// Set usrData & userCache path specifically for each application for MAC_OS +function handleMacSingleTenant() { + if (process.platform === 'darwin') { + const configUrl = coreState.argo['startup-url'] || coreState.argo['config']; + let pathPost = encodeURIComponent(configUrl); + if (coreState.argo['security-realm']) { + pathPost = pathPost.concat(coreState.argo['security-realm']); + } + app.setPath('userData', path.join(USER_DATA, pathPost)); + app.setPath('userCache', path.join(USER_DATA, pathPost)); + } +} + function needsCrashReporter(argo) { return !!(argo['diagnostics'] || argo['enable-crash-reporting']); } diff --git a/src/browser/api/window.js b/src/browser/api/window.js index 7dccb2fdf..8737281fe 100644 --- a/src/browser/api/window.js +++ b/src/browser/api/window.js @@ -61,7 +61,6 @@ import { const subscriptionManager = new SubscriptionManager(); const isWin32 = process.platform === 'win32'; const windowPosCacheFolder = 'winposCache'; -const userCache = electronApp.getPath('userCache'); const WindowsMessages = { WM_KEYDOWN: 0x0100, WM_KEYUP: 0x0101, @@ -1942,6 +1941,7 @@ function saveBoundsToDisk(identity, bounds, callback) { }; try { + const userCache = electronApp.getPath('userCache'); fs.mkdir(path.join(userCache, windowPosCacheFolder), () => { fs.writeFile(cacheFile, JSON.stringify(data), (writeFileErr) => { callback(writeFileErr); @@ -1955,6 +1955,7 @@ function saveBoundsToDisk(identity, bounds, callback) { //make sure the uuid/names with special characters do not break the bounds cache. function getBoundsCacheSafeFileName(identity) { let safeName = new Buffer(identity.uuid + '-' + identity.name).toString('hex'); + const userCache = electronApp.getPath('userCache'); return path.join(userCache, windowPosCacheFolder, `${safeName}.json`); }