Swapable Plugins?
I've been digging through this trying to see if this is possible,
What I am looking to do is have customizable plugins. So, in my Splash screen of my browser I'll have check boxes to enable / disable Java/Flash/Silverlight, etc. Also, drop down boxes to choose which version of Java I want. So, I can have a drop down of Java 7, 6.4, 6.3, 6.2, etc. Is something like that possible? Where I can specify multiple different versions of java and load a specific one when launched?
Can anybody point me in the right direction?
Thanks!
This question might be better asked on the Cef forum, we currently only have fairly limited plugin support (and there's a couple of glitches with what we do have).
Another option would be to dig through the cefclient sample application source code and see if there's anything plugin specific in there that might give you some clues.
Contributions to expand our plugin support would be most welcome :+1:
For reference API's located in cef_web_plugin.h maybe useful
https://bitbucket.org/chromiumembedded/branches-2062-cef3/src/a073e92426b3967f1fc2f1d3fd7711d809eeb03a/include/cef_web_plugin.h?at=master
We plugin methods have been implement see https://github.com/cefsharp/CefSharp/blob/master/CefSharp.Core/Cef.h#L455
I have same issue with @Beyondem, How to use CefAddWebPluginPath () work for CefSharp.WinForm? My plan is to get it work for Cef then package and apply to CefSharp. but I can not make it success.
After automate build and create project for VS (whole thing with cef.sln) I tried in cefclient. after CefInitialize(main_args, settings, app.get()); CefRemoveWebPluginPath(CefString("C:\JRE\jre8u31x86\bin\plugin2\npjp2.dll")); CefAddWebPluginDirectory(CefString("C:\JRE\jre7u71x86\bin")); CefAddWebPluginPath(CefString("C:\JRE\jre7u71x86\bin\plugin2\npjp2.dll")); CefRefreshWebPlugins(); It does not have any effect - Browser still load the Java that set in regedit (C:\JRE\jre8u31x86\bin\plugin2\npjp2.dll).
Anyone can guide how use CefAddWebPluginPath again that would be great appreciated.
Thanks
@amaitland : can you re open this issue?
CefRemoveWebPluginPath() --> seems NOT work / No effect
Using CefAddWebPluginPath( Path); --> Can add a specific plugin but when a new java added it might be conflict with the one (pre-set in Registry) --> Crash
Link: https://code.google.com/p/chromiumembedded/issues/detail?id=273 provides 2 patches to prevent loading Registry but I can not apply for CEF (any one know how?). I tried 2 patches with Chromium it worked.
Anyone can guide how use CefAddWebPluginPath again that would be great appreciated.
Thanks
Have you seen CEF 645?
It suggests you call Cef.RefreshWebPlugins() after Cef.AddWebPluginPath.
Additionally, the way to prevent plugins from loading appears to be via OnBeforePluginLoad as listed in CEF 645.
CEF also apparently has these APIs that might assist if OnBeforePluginLoad combined with RefreshWebPlugins isn't enough:
UnregisterInternalWebPluginCefForceWebPluginShutdown
I would note that CefForceWebPluginShutdown isn't currently exposed from CefSharp atm.
Bill
@Bill: Yes I did tried those unregister.....shutdown...refresh. It loads new plugin but still keep the preset plugin. Do i need to apply 2 patches (cef_web_plugin.h.diff , web_plugin_impl.cc.diff) in issue CEF 645?
CefUnregisterInternalWebPlugin(CefString("C:\\JRE\\jre8u31x86\\bin\\plugin2\\npjp2.dll"));
CefForceWebPluginShutdown(CefString("C:\\JRE\\jre8u31x86\\bin\\plugin2\\npjp2.dll"));
CefRemoveWebPluginPath(CefString("C:\\JRE\\jre8u31x86\\bin\\plugin2\\npjp2.dll"));
CefAddWebPluginPath(CefString("C:\\JRE\\jre7u71x86\\bin\\plugin2\\npjp2.dll"));
CefRefreshWebPlugins();
http://tests/plugin_info --> Show both Java version 7 and 8 loaded http://javatester.org/version.html --> Crash whatismybrowser.com --> Show Java Version 7 only.
Look like these fours: OnBeforePluginLoad / CefUnregisterInternalWebPlugin/ CefForceWebPluginShutdown / CefRemoveWebPluginPath not working or I don't know how to make them work?
I tried modified OnBeforePluginLoad in cef_request_handler.h and request_handler_cpptoc.cc to force it return true--> still no effect.
I am using automate CEF build for few recent brands, VS2013U4+ for cefclient.
In the bit you pasted you do realize that you didn't escape your backslashes properly?
Additionally, I don't know what the plugin paths look like. I think CEF has a plugin visitor class in C++ that will ensure you know what path to supply for the Java plugin you desire to forcefully shutdown.
I don't think you need the patches from CEF 645.
Don't forget you need to call CefUnregisterInternalWebPlugin after calling CefRefreshWebPlugins since the refresh can refind the Java you're trying to ignore.
I would have imagined something like this MIGHT do the trick: (presuming the supplied path strings are good)
- CefForceWebPluginShutdown(
) - CefAddWebPluginPath(
) - CefRefreshWebPlugins()
- CefUnregisterInternalWebPlugin(
)
Usual disclaimer: The above comments are just a wild guess about what might work, Bill
I added ForceWebPluginShutdown see https://github.com/cefsharp/CefSharp/commit/189c6c07fd6d4f2f53c6841971af9147a4694144
@shaunsphere I'd probably suggest posting on http://magpcss.org/ceforum/ for some clarification on how to use the API.
Careful with that @bill @shaunsphere. You meant @rassilon. :wink:
@Bill: I had double backslash, but one was removed when pasting here. A bug if I use:CefUnregisterInternalWebPlugin() --> Popup says: cefclient.exe has triggered a breakpoint. (Break / Conti..) Click Continue--> Run OK but still load Java 8, :-( . Thanks.
@amaitland: I found almost same post in magpcss and google cefsharp forums but still no specific solution, thanks. https://groups.google.com/forum/?nomobile=true#!searchin/cefsharp/java/cefsharp/Wkhyz-fKYP0/obQIIF4FJc4J
http://magpcss.org/ceforum/viewtopic.php?f=6&t=11150&p=18945&hilit=+patrick+jre#p18945
@shaunsphere I think you need to read https://github.com/cefsharp/CefSharp/issues/538#issuecomment-86322751 closely.
I found almost same post in magpcss and google cefsharp forums but still no specific solution, thanks.
There isn't much more that we can do. You'll have to followup with CEF
I made it work for cefclient, how to apply to CefSharp.Winform?
What code changes did you make to cefclient?
You need to call CefAddWebPluginDirectory and related methods after the context has been initialized. For example, from CefBrowserProcessHandler::OnContextInitialized(). Also, you may have better results specifying the full plugin path via CefAddWebPluginPath.
So that looks like the missing puzzle piece, with the follow up http://www.magpcss.org/ceforum/viewtopic.php?f=10&t=10736#p17080
CefSharp doesn't implement CefBrowserProcessHandler as yet.
http://magpcss.org/ceforum/apidocs3/projects/(default)/CefBrowserProcessHandler.html#OnContextInitialized()
Strictly speaking it might not be required to implement CefBrowserProcessHandler, just make sure the plugin calls happen after it's called.
@amaitland: For Cefclient to swap Java versions I changed file \src\content\common\plugin_list_win.cc 2 Keys are changed to my setup for Registry:
const base::char16 kRegistryApps[] = L"Software\\\Microsoft\\\Windows\\\CurrentVersion\\NewPaths";
const base::char16 kRegistryJava[] = L"Software\\\JavaSoft\\\NewJRE";
and modify:
bool PluginList::ShouldLoadPluginUsingPluginList(
const WebPluginInfo& info,
std::vector<WebPluginInfo>* plugins) \{
Code here is modified -> basically disable the loop to avoid update new version of Java
\}
And in file: \src\cef\tests\cefclient\cefclient_win.cc --> Only 3 lines added after CefInitialize(); No need to call remove/shutdown/unregister...
CefAddWebPluginDirectory(CefString("C:\\JRE\\jre7u71x86\\bin")); \\ "C:\\JRE\\jre8\\bin" --> load Java 8 as expected.
CefAddWebPluginPath(CefString("C:\\JRE\\jre7u71x86\\bin\\plugin2\\npjp2.dll"));
CefRefreshWebPlugins();
How to apply the above to CefSharp.Winform? Replace (copy) set of DLLs to Cefsharp (same version) --> crash. Does repackage work? How?
Thanks
Please markup your code, very hard to read.
If you need to build a custom version of cef then your somewhat on your own there.
Have implemented OnContextInitialized feel free to see if that makes any difference calling your plugin methods using the delegate. See code for example. PR #929
Closing due to lack of feedback.
For reference you can disable plugin discovery entirely and load plugins manually. See example of command line arg. https://github.com/cefsharp/CefSharp/commit/59ded0957d7eb383ad8c4593c37a4604a2aaa609
Example of adding a plugin
Cef.OnContextInitialized = delegate
{
Cef.AddWebPluginPath(@"C:\Program Files\Microsoft Silverlight\5.1.31211.0\npctrl.dll");
Cef.RefreshWebPlugins();
};
Requires version 39.0.1 or greater