Allow clients to selectively disable plug-ins
https://bugs.webkit.org/show_bug.cgi?id=142506
Reviewed by Anders Carlsson.
Source/WebCore:
Add new functionality allow clients to declaratively disable individual plug-ins (in a manner that conceals them
from the page). As part of this:
1) Introduce the concept of web-visible plug-ins and related concepts, as distinct from the real underlying
set of plug-ins.
2) Where applicable, plumb additional information about plug-ins (specifically, bundle identification) deeper
down the stack.
3) Add generic functionality to PluginStrategy to support filtering plug-ins for visibility and introduce
a concrete implementation thereof in WebPlatformStrategies in WebKit2.
4) Add messaging infrastructure to allow clients to set and clear plug-in policies.
While currently only used in a very limited manner, the new declarative plug-in policies are written generically
so that they could be easily used in the future to reduce synchronous messaging to the client when loading plug-ins.
* dom/DOMImplementation.cpp:
(WebCore::DOMImplementation::createDocument):
Update to reflect function rename.
* loader/SubframeLoader.cpp:
(WebCore::findPluginMIMETypeFromURL):
Adopt getWebVisibleMimesAndPluginIndices().
(WebCore::logPluginRequest):
Update to reflect function rename.
(WebCore::SubframeLoader::shouldUsePlugin):
Ditto.
* platform/PlatformStrategies.h:
Export platformStrategies(), since it is now used in WebProcess.cpp.
* plugins/DOMMimeType.cpp:
(WebCore::DOMMimeType::type):
(WebCore::DOMMimeType::description):
(WebCore::DOMMimeType::mimeClassInfo):
Adopt getWebVisibleMimesAndPluginIndices().
(WebCore::DOMMimeType::enabledPlugin):
Ditto.
* plugins/DOMMimeType.h:
Don't return references in a few places where it is no longer safe to do so.
(WebCore::DOMMimeType::mimeClassInfo): Deleted.
* plugins/DOMMimeTypeArray.cpp:
(WebCore::DOMMimeTypeArray::length):
Adopt getWebVisibleMimesAndPluginIndices().
(WebCore::DOMMimeTypeArray::item):
Ditto.
(WebCore::DOMMimeTypeArray::canGetItemsForName):
Ditto.
(WebCore::DOMMimeTypeArray::namedItem):
Ditto.
* plugins/DOMPlugin.cpp:
(WebCore::DOMPlugin::pluginInfo):
Adopt getWebVisiblePlugins().
(WebCore::DOMPlugin::item):
Adopt getWebVisibleMimesAndPluginIndices().
(WebCore::DOMPlugin::canGetItemsForName):
Ditto.
(WebCore::DOMPlugin::namedItem):
Ditto.
* plugins/DOMPlugin.h:
(WebCore::DOMPlugin::pluginInfo): Deleted.
* plugins/DOMPluginArray.cpp:
(WebCore::DOMPluginArray::length):
Adopt getWebVisiblePlugins().
(WebCore::DOMPluginArray::item):
Ditto.
(WebCore::DOMPluginArray::canGetItemsForName):
Ditto.
(WebCore::DOMPluginArray::namedItem):
Ditto.
* plugins/PluginData.cpp:
(WebCore::PluginData::PluginData):
Stash the passed-in Page and call initPlugins().
(WebCore::PluginData::getWebVisiblePlugins):
New member function; call through to PluginStrategy::getWebVisiblePluginInfo().
(WebCore::PluginData::getWebVisibleMimesAndPluginIndices):
New member function; build up the mimes and mimePluginIndices vectors in the same manner as before, but
limited to the web-visible plug-ins.
(WebCore::PluginData::supportsWebVisibleMimeType):
Renamed from supportsMimeType(); update to work in terms of web-visible plug-ins.
(WebCore::PluginData::pluginInfoForWebVisibleMimeType):
Renamed from pluginInfoForMimeType(); ditto.
(WebCore::PluginData::pluginNameForWebVisibleMimeType):
Renamed from pluginNameForMimeType(); ditto.
(WebCore::PluginData::pluginFileForWebVisibleMimeType):
Renamed from pluginFileForMimeType(); ditto.
(WebCore::PluginData::initPlugins):
(WebCore::PluginData::supportsMimeType): Deleted.
(WebCore::PluginData::pluginInfoForMimeType): Deleted.
(WebCore::PluginData::pluginNameForMimeType): Deleted.
(WebCore::PluginData::pluginFileForMimeType): Deleted.
* plugins/PluginData.h:
Add a member variable for the associate Page; declare the PluginLoadClientPolicy enumeration; add
new members to PluginInfo for the clientLoadPolicy and bundle information.
(WebCore::PluginData::PluginData):
Replace some member functions with new ones that will hide plug-ins upon request from the client;
(WebCore::PluginData::mimes): Deleted.
(WebCore::PluginData::mimePluginIndices): Deleted.
* plugins/PluginStrategy.h:
Declare new member functions for retrieving web-visible plug-ins and setting/clearing plug-in policies.
* replay/SerializationMethods.cpp:
(JSC::EncodingTraits<PluginData>::encodeValue):
Remove now-obsolete code for handling MIME types and add a FIXME.
(JSC::DeserializedPluginData::DeserializedPluginData):
(JSC::EncodingTraits<PluginData>::decodeValue):
Ditto.
(JSC::EncodingTraits<PluginInfo>::encodeValue):
Handle the new members in PluginInfo.
(JSC::EncodingTraits<PluginInfo>::decodeValue):
Ditto.
* replay/WebInputs.json:
Teach Replay about PluginLoadClientPolicy.
Source/WebKit/mac:
Add new functionality allow clients to declaratively disable individual plug-ins (in a manner that conceals them
from the page). As part of this:
1) Introduce the concept of web-visible plug-ins and related concepts, as distinct from the real underlying
set of plug-ins.
2) Where applicable, plumb additional information about plug-ins (specifically, bundle identification) deeper
down the stack.
3) Add generic functionality to PluginStrategy to support filtering plug-ins for visibility and introduce
a concrete implementation thereof in WebPlatformStrategies in WebKit2.
4) Add messaging infrastructure to allow clients to set and clear plug-in policies.
While currently only used in a very limited manner, the new declarative plug-in policies are written generically
so that they could be easily used in the future to reduce synchronous messaging to the client when loading plug-ins.
* Plugins/WebBasePluginPackage.mm:
(-[WebBasePluginPackage getPluginInfoFromPLists]):
Set new members in PluginInfo.
* Plugins/WebNetscapePluginPackage.mm:
(-[WebNetscapePluginPackage getPluginInfoFromResources]):
Set new members in PluginInfo.
* WebCoreSupport/WebPlatformStrategies.h:
* WebCoreSupport/WebPlatformStrategies.mm:
(WebPlatformStrategies::getWebVisiblePluginInfo):
Override to wrap getPluginInfo().
(WebPlatformStrategies::setPluginLoadClientPolicy):
Override to do nothing.
(WebPlatformStrategies::clearPluginClientPolicies):
Ditto.
* WebView/WebFrame.mm:
(-[WebFrame _canProvideDocumentSource]):
Update to reflect function rename.
Source/WebKit/win:
* WebCoreSupport/WebPlatformStrategies.h:
* WebCoreSupport/WebPlatformStrategies.cpp:
(WebPlatformStrategies::getWebVisiblePluginInfo):
Wrap getPluginInfo();
* WebView.cpp:
(WebView::canShowMIMEType):
Update to reflect function rename.
Source/WebKit2:
Add new functionality allow clients to declaratively disable individual plug-ins (in a manner that conceals them
from the page). As part of this:
1) Introduce the concept of web-visible plug-ins and related concepts, as distinct from the real underlying
set of plug-ins.
2) Where applicable, plumb additional information about plug-ins (specifically, bundle identification) deeper
down the stack.
3) Add generic functionality to PluginStrategy to support filtering plug-ins for visibility and introduce
a concrete implementation thereof in WebPlatformStrategies in WebKit2.
4) Add messaging infrastructure to allow clients to set and clear plug-in policies.
While currently only used in a very limited manner, the new declarative plug-in policies are written generically
so that they could be easily used in the future to reduce synchronous messaging to the client when loading plug-ins.
* Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm:
(WebKit::NetscapePluginModule::getPluginInfo):
Set new PluginInfo members.
* Shared/WebCoreArgumentCoders.cpp:
(IPC::ArgumentCoder<PluginInfo>::encode):
Handle new PluginInfo members.
(IPC::ArgumentCoder<PluginInfo>::decode):
Ditto.
* Shared/WebProcessCreationParameters.h:
Declare a member to store client plug-in policies.
* Shared/WebProcessCreationParameters.cpp:
(WebKit::WebProcessCreationParameters::encode):
Encode the policies.
(WebKit::WebProcessCreationParameters::decode):
Decode the policies.
* UIProcess/API/C/WKAPICast.h:
(WebKit::toWKPluginLoadClientPolicy):
Teach how to cast between WebCore and WebKit2 policy definitions.
(WebKit::toPluginLoadClientPolicy):
Ditto.
* UIProcess/API/C/WKPluginLoadPolicy.h:
Declare WKPluginLoadClientPolicy, matching PluginLoadClientPolicy in WebCore.
* UIProcess/API/C/mac/WKContextPrivateMac.h:
* UIProcess/API/C/mac/WKContextPrivateMac.mm:
(WKContextSetPluginLoadClientPolicy):
New function; wrap WebProcessPool::setPluginLoadClientPolicy().
(WKContextClearPluginClientPolicies):
New function; wrap WebProcessPool::clearPluginClientPolicies().
* UIProcess/WebProcessPool.h:
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::createNewWebProcess):
Copy any client plug-in policies to the new process' creation parameters.
(WebKit::WebProcessPool::setPluginLoadClientPolicy):
Send SetPluginLoadClientPolicy to all processes and stash the passed-in policy info.
(WebKit::WebProcessPool::clearPluginClientPolicies):
Send ClearPluginClientPolicies to all processes and clear any stashed policy info.
* WebProcess/Plugins/PDF/PDFPlugin.mm:
(WebKit::PDFPlugin::pluginInfo):
Set new PluginInfo member.
* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::pluginSupportsExtension):
Adopt getWebVisibleMimesAndPluginIndices().
(WebKit::WebFrameLoaderClient::objectContentType):
Update to reflect reflect function rename.
* WebProcess/WebCoreSupport/WebPlatformStrategies.h:
* WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
(WebKit::WebPlatformStrategies::getPluginInfo):
Pass the Page to populatePluginCache().
(WebKit::WebPlatformStrategies::getWebVisiblePluginInfo):
New member function; wrap getPluginInfo(); if appropriate, filter out plug-ins the client has asked
to block on the current page.
(WebKit::WebPlatformStrategies::setPluginLoadClientPolicy):
New member function; map empty inputs to a wildcard character and insert the new policy into the nested map.
(WebKit::WebPlatformStrategies::clearPluginClientPolicies):
New member function; empty m_hostsToPluginIdentifierData.
(WebKit::WebPlatformStrategies::pluginLoadClientPolicyForHost):
New member function; look up the most specific policy for the given plug-in and host.
(WebKit::WebPlatformStrategies::populatePluginCache):
If appropriate, set the client load policy on the plug-ins; do this irrespective of whether the cache has
been populated since the Page, and therefore host, may change.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::canShowMIMEType):
Update to reflect function rename.
* WebProcess/WebProcess.h:
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::initializeWebProcess):
Enumerate and process the client plug-in policies in the creation parameters.
(WebKit::WebProcess::setPluginLoadClientPolicy):
New member function; wrap PluginStrategy::setPluginLoadClientPolicy.
(WebKit::WebProcess::clearPluginClientPolicies):
New member function; wrap PluginStrategy::clearPluginClientPolicies().
* WebProcess/WebProcess.messages.in:
Add messages for setting and clearing policies.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@181483 268f45cc-cd09-0410-ab3c-d52691b4dbfc
44 files changed