electron / electron

:electron: Build cross-platform desktop apps with JavaScript, HTML, and CSS
https://electronjs.org
MIT License
113.82k stars 15.33k forks source link

app.getPath('pepperFlashSystemPlugin') exception !!!! #17603

Closed StringKe closed 5 years ago

StringKe commented 5 years ago

Preflight Checklist

Issue Details

Expected Behavior

load flash plugin and no exception

Actual Behavior

image

To Reproduce

in win7

const flashPath = app.getPath('pepperFlashSystemPlugin'); // error
if (flashPath && ['dll', 'so', 'plugin'].forEach(item => flashPath.endsWith(item))) {
      app.commandLine.appendSwitch('ppapi-flash-path', flashPath);
}

Screenshots

image

Additional Information

none

StringKe commented 5 years ago

index.js

import { app, BrowserWindow, ipcMain } from 'electron';
import fs from 'fs';

if (process.env.NODE_ENV !== 'development') {
  global.__static = require('path').join(__dirname, '/static').replace(/\\/g, '\\\\');
}

let mainWindow;
const winURL = process.env.NODE_ENV === 'development'
  ? 'http://localhost:9080/index.html'
  : `file://${__dirname}/index.html`;

process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = true;

class Browser {
  createWindow() {
    mainWindow = new BrowserWindow({
      show: false,
      height: 620,
      width: 1240,
      minHeight: 430,
      minWidth: 800,
      useContentSize: true,
      frame: false,
      webSecurity: false,
      allowRunningInsecureContent: true,
      fullscreenWindowTitle: false,
      webPreferences: {
        plugins: true,
      },
    });
    mainWindow.loadURL(winURL);
    mainWindow.once('ready-to-show', () => {
      mainWindow.show();
    });
  }

  start() {
    const flashPath = app.getPath('pepperFlashSystemPlugin');
    if (flashPath && ['dll', 'so', 'plugin'].forEach(item => flashPath.endsWith(item))) {
      app.commandLine.appendSwitch('ppapi-flash-path', flashPath);
    }
    app.on('ready', this.createWindow);
    app.on('window-all-closed', () => {
      if (process.platform !== 'darwin') {
        app.quit();
      }
    });
    app.on('activate', () => {
      if (mainWindow === null) {
        this.createWindow();
      }
    });
    this.listenRender();
  }

  listenRender() {
    ipcMain.on('fun-minWindow', (event, obj) => {
      mainWindow.minimize();
    });
    ipcMain.on('fun-closeWindow', (event, obj) => {
      app.quit();
      app.exit(0);
    });
    ipcMain.on('fun-reStart', (event, obj) => {
      app.relaunch({ args: process.argv.slice(1).concat(['--relaunch']) });
      app.exit(0);
    });
    ipcMain.on('fun-maxWindow', (event, obj) => {
      if (mainWindow.isMaximized()) {
        mainWindow.unmaximize();
        mainWindow.setSize(1000, 560);
      } else {
        mainWindow.maximize();
      }
    });
  }
}

new Browser().start();
Galunid commented 5 years ago

Perhaps https://github.com/electron/electron/issues/8469#issuecomment-277086664 explains this behavior.

StringKe commented 5 years ago

Perhaps #8469 (comment) explains this behavior.

I use electron to make a browser. In theory, I should read the flash that the user has installed. Otherwise, I will update my program every time the flash is updated.

miniak commented 5 years ago

Duplicate of https://github.com/electron/electron/issues/8469

miniak commented 5 years ago

Electron does not implement this directly, it just calls https://cs.chromium.org/chromium/src/chrome/common/chrome_paths.cc?type=cs&q=FILE_PEPPER_FLASH_SYSTEM_PLUGIN&sq=package:chromium&g=0&l=308