mirror of
https://github.com/Llewellynvdm/nativefier.git
synced 2024-09-28 04:19:01 +00:00
Implement rudimentary inferment of flash
This commit is contained in:
parent
cf24858ba6
commit
6ca4e794cd
@ -5,6 +5,14 @@ function isOSX() {
|
||||
return os.platform() === 'darwin';
|
||||
}
|
||||
|
||||
function isLinux() {
|
||||
return os.platform() === 'linux';
|
||||
}
|
||||
|
||||
function isWindows() {
|
||||
return os.platform() === 'win32';
|
||||
}
|
||||
|
||||
function linkIsInternal(currentUrl, newUrl) {
|
||||
var currentDomain = wurl('domain', currentUrl);
|
||||
var newDomain = wurl('domain', newUrl);
|
||||
@ -13,5 +21,7 @@ function linkIsInternal(currentUrl, newUrl) {
|
||||
|
||||
export default {
|
||||
isOSX,
|
||||
isLinux,
|
||||
isWindows,
|
||||
linkIsInternal
|
||||
};
|
||||
|
72
app/src/helpers/inferFlash.js
Normal file
72
app/src/helpers/inferFlash.js
Normal file
@ -0,0 +1,72 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import helpers from './helpers';
|
||||
|
||||
const {isOSX, isWindows, isLinux} = helpers;
|
||||
|
||||
function inferFlash() {
|
||||
if (isOSX()) {
|
||||
return darwinMatch();
|
||||
}
|
||||
|
||||
if (isWindows()) {
|
||||
return windowsMatch();
|
||||
}
|
||||
|
||||
if (isLinux()) {
|
||||
return linuxMatch();
|
||||
}
|
||||
|
||||
console.warn('Unable to determine OS to infer flash player');
|
||||
}
|
||||
|
||||
/**
|
||||
* Synchronously find a file or directory
|
||||
* @param {RegExp} pattern regex
|
||||
* @param {string} base path
|
||||
* @param {boolean} [findDir] if true, search results will be limited to only directories
|
||||
* @returns {Array}
|
||||
*/
|
||||
function findSync(pattern, base, findDir) {
|
||||
const matches = [];
|
||||
(function findSyncRecurse(base) {
|
||||
const children = fs.readdirSync(base);
|
||||
children.forEach(child => {
|
||||
const childPath = path.join(base, child);
|
||||
const childIsDirectory = fs.lstatSync(childPath).isDirectory();
|
||||
const patternMatches = pattern.test(childPath);
|
||||
|
||||
if (!patternMatches) {
|
||||
if (!childIsDirectory) {
|
||||
return;
|
||||
}
|
||||
findSyncRecurse(childPath);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!findDir) {
|
||||
matches.push(childPath);
|
||||
return;
|
||||
}
|
||||
|
||||
if (childIsDirectory) {
|
||||
matches.push(childPath);
|
||||
}
|
||||
});
|
||||
})(base);
|
||||
return matches;
|
||||
}
|
||||
|
||||
function linuxMatch() {
|
||||
return findSync(/libpepflashplayer\.so/, '/opt/google/chrome')[0];
|
||||
}
|
||||
|
||||
function windowsMatch() {
|
||||
return findSync(/pepflashplayer\.dll/, 'C:\Program Files (x86)\Google\Chrome')[0];
|
||||
}
|
||||
|
||||
function darwinMatch() {
|
||||
return findSync(/PepperFlashPlayer.plugin/, '/Applications/Google Chrome.app/', true)[0];
|
||||
}
|
||||
|
||||
export default inferFlash;
|
@ -5,6 +5,7 @@ import electron from 'electron';
|
||||
import createLoginWindow from './components/login/loginWindow';
|
||||
import createMainWindow from './components/mainWindow/mainWindow';
|
||||
import helpers from './helpers/helpers';
|
||||
import inferFlash from './helpers/inferFlash';
|
||||
|
||||
const {app, ipcMain} = electron;
|
||||
const {isOSX} = helpers;
|
||||
@ -14,6 +15,13 @@ const appArgs = JSON.parse(fs.readFileSync(APP_ARGS_FILE_PATH, 'utf8'));
|
||||
|
||||
let mainWindow;
|
||||
|
||||
if (appArgs.flashPluginDir) {
|
||||
app.commandLine.appendSwitch('ppapi-flash-path', appArgs.flashPluginDir);
|
||||
} else {
|
||||
const flashPath = inferFlash();
|
||||
app.commandLine.appendSwitch('ppapi-flash-path', flashPath);
|
||||
}
|
||||
|
||||
if (appArgs.insecure) {
|
||||
app.commandLine.appendSwitch('ignore-certificate-errors');
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user