OS X: How to change the search path of WebKit plugins?

I have a Mac Desktop browser application that uses WebKit to render web content.

My application links are against the standard WebKit system (it does not bind the private WebKit infrastructure).

However, I would like to link a private Flash plugin in my application suite. When my application starts, I would like WebKit to prefer the private Flash plugin in my bundle over any other Flash plugin on the system.

How can I change the search path of the WebKit plugin so that my application downloads my private Flash plugin bundled with my application?

+4
source share
1 answer

I do not believe that there is a publicly available, documented method for this.

Take a look at the source code of WebView, in particular in the source file "WebPluginDatabase.mm", to get an idea of ​​how the plugin paths are evaluated and what priority is given to plugins found in different places. By default, it seems that the search path goes in the following order:

  • ~ / Library / Internet modules
  • / Library / Internet Modules
  • Application Plugins Folder

Thus, any plug-in that you include in your application package will be replaced by default with the version located in the user’s folder or the system library.

If using an undocumented SPI is an option, I see that there is a method in WebView.mm that essentially redefines the list of plugin paths, going to the appropriate configuration in WebPluginDatabase single mode:

- (void)_setAdditionalWebPlugInPaths:(NSArray *)newPaths { if (!_private->pluginDatabase) _private->pluginDatabase = [[WebPluginDatabase alloc] init]; [_private->pluginDatabase setPlugInPaths:newPaths]; [_private->pluginDatabase refresh]; } 

In the SPI-based solutions section, another stack overflow question has an answer that describes overriding a private WebView method to provide a specific plugin based on the MIME type:

Flash Prevention in Cocoa WebView

This gives me another idea that may be suitable for your purposes. Since you are responsible for the entire viewing, you can consider changing the entire HTML code that is presented in your browser, scanning and changing any content that is usually associated with the Flash plugin, and changing it to call a custom MIME type or something else, to instead load "DitchenFlash";)

+3
source

All Articles