From e1beeb95e3f7fbb9441a9c3dbb3195143ec304bc Mon Sep 17 00:00:00 2001 From: Magica Date: Tue, 12 May 2015 06:02:42 +0800 Subject: [PATCH 1/3] Fix PPAPI flash plugin description Fix https://github.com/atom/electron/issues/1637 --- atom/app/atom_content_client.cc | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/atom/app/atom_content_client.cc b/atom/app/atom_content_client.cc index c8a591a59c..74f88db0b9 100644 --- a/atom/app/atom_content_client.cc +++ b/atom/app/atom_content_client.cc @@ -10,6 +10,8 @@ #include "atom/common/chrome_version.h" #include "atom/common/options_switches.h" #include "base/command_line.h" +#include "base/strings/string_split.h" +#include "base/strings/string_util.h" #include "content/public/common/content_constants.h" #include "content/public/common/pepper_plugin_info.h" #include "ppapi/shared_impl/ppapi_permissions.h" @@ -26,8 +28,24 @@ content::PepperPluginInfo CreatePepperFlashInfo(const base::FilePath& path, plugin.name = content::kFlashPluginName; plugin.path = path; plugin.permissions = ppapi::PERMISSION_ALL_BITS; - plugin.version = version; + std::vector flash_version_numbers; + base::SplitString(version, '.', &flash_version_numbers); + if (flash_version_numbers.size() < 1) + flash_version_numbers.push_back("11"); + // |SplitString()| puts in an empty string given an empty string. :( + else if (flash_version_numbers[0].empty()) + flash_version_numbers[0] = "11"; + if (flash_version_numbers.size() < 2) + flash_version_numbers.push_back("2"); + if (flash_version_numbers.size() < 3) + flash_version_numbers.push_back("999"); + if (flash_version_numbers.size() < 4) + flash_version_numbers.push_back("999"); + // E.g., "Shockwave Flash 10.2 r154": + plugin.description = plugin.name + " " + flash_version_numbers[0] + "." + + flash_version_numbers[1] + " r" + flash_version_numbers[2]; + plugin.version = JoinString(flash_version_numbers, '.'); content::WebPluginMimeType swf_mime_type( content::kFlashPluginSwfMimeType, content::kFlashPluginSwfExtension, From 6980982e32017f28e38fd80e970f0edfa2fe6946 Mon Sep 17 00:00:00 2001 From: Magica Date: Tue, 19 May 2015 20:27:12 +0800 Subject: [PATCH 2/3] ppapi: Add pepper flash tutorial Fix https://github.com/atom/electron/issues/1674 --- docs/tutorial/using-pepper-flash-plugin.md | 55 ++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 docs/tutorial/using-pepper-flash-plugin.md diff --git a/docs/tutorial/using-pepper-flash-plugin.md b/docs/tutorial/using-pepper-flash-plugin.md new file mode 100644 index 0000000000..7a542e0003 --- /dev/null +++ b/docs/tutorial/using-pepper-flash-plugin.md @@ -0,0 +1,55 @@ +# Using Pepper Flash Plugin + +Pepper flash plugin is now supported. To use pepper flash plugin in Electron, you should manually specify the location of pepper flash plugin and then enable it in your application. + +## Prepare a copy of flash plugin + +On OS X and Linux, the detail of pepper flash plugin can be found by navigating `chrome://plugins` in Chrome browser. Its location and version are useful for electron's pepper flash support. You can also copy it to anywhere else. + +## Add Electron switch + +You can directly add `--ppapi-flash-path` and `ppapi-flash-version` to electron commandline or by `app.commandLine.appendSwitch` method before app ready event. Also, add the `plugins` switch of `browser-window`. For example, + +```javascript +var app = require('app'); +var BrowserWindow = require('browser-window'); + +// Report crashes to our server. +require('crash-reporter').start(); + +// Keep a global reference of the window object, if you don't, the window will +// be closed automatically when the javascript object is GCed. +var mainWindow = null; + +// Quit when all windows are closed. +app.on('window-all-closed', function() { + if (process.platform != 'darwin') + app.quit(); +}); + +// Specify flash path. +// On Windows, it might be /path/to/pepflashplayer.dll +// On Mac, /path/to/PepperFlashPlayer.plugin +// On Linux, /path/to/libpepflashplayer.so +app.commandLine.appendSwitch('ppapi-flash-path', '/path/to/libpepflashplayer.so'); + +// Specify flash version, for example, v17.0.0.169 +app.commandLine.appendSwitch('ppapi-flash-version', '17.0.0.169'); + +app.on('ready', function() { + mainWindow = new BrowserWindow({ + 'width': 800, + 'height': 600, + 'web-preferences': + 'plugins': true + }); + mainWindow.loadUrl('file://' + __dirname + '/index.html'); + // Something else +}); +``` + +## Enable flash plugin in a `` tag +Add `plugins` attribute to `` tag. +```html + +``` From 1a8c0230a713a10d3f07d6109bf7b925927a57a9 Mon Sep 17 00:00:00 2001 From: Magica Date: Tue, 19 May 2015 20:29:04 +0800 Subject: [PATCH 3/3] doc: Add pepper flash tutorial link in README. --- docs/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/README.md b/docs/README.md index 34688848b3..98b4219d34 100644 --- a/docs/README.md +++ b/docs/README.md @@ -6,6 +6,7 @@ * [Debugging main process](tutorial/debugging-main-process.md) * [Using Selenium and WebDriver](tutorial/using-selenium-and-webdriver.md) * [DevTools extension](tutorial/devtools-extension.md) +* [Using pepper flash plugin](tutorial/using-pepper-flash-plugin.md) ## Tutorials