Skip to content
Permalink
Browse files
Move allowPlugins to FrameLoader
https://bugs.webkit.org/show_bug.cgi?id=205876

Patch by Rob Buis <rbuis@igalia.com> on 2020-04-17
Reviewed by Darin Adler.

Source/WebCore:

Move allowPlugins to FrameLoader to reduce
pointer dereferences and lessen dependency
on SubframeLoader. Also rename to
arePluginsEnabled since the method is asking
the Setting with the same name.

* dom/DOMImplementation.cpp:
(WebCore::DOMImplementation::createDocument):
* html/HTMLElement.cpp:
(WebCore::HTMLElement::rendererIsEverNeeded):
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::arePluginsEnabled):
* loader/FrameLoader.h:
* loader/SubframeLoader.cpp:
(WebCore::SubframeLoader::createJavaAppletWidget):
(WebCore::SubframeLoader::allowPlugins): Deleted.
* loader/SubframeLoader.h:
* plugins/DOMMimeType.cpp:
(WebCore::DOMMimeType::enabledPlugin const):

Source/WebKit:

Adapt to API change.

* WebProcess/Plugins/WebPluginInfoProvider.cpp:
(WebKit::WebPluginInfoProvider::pluginInfo):
(WebKit::WebPluginInfoProvider::populatePluginCache):
* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::objectContentType):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::createPlugin):
(WebKit::WebPage::canPluginHandleResponse):
(WebKit::WebPage::canShowMIMEType const):

Source/WebKitLegacy/mac:

Adapt to API change.

* WebCoreSupport/WebPluginInfoProvider.mm:
(WebPluginInfoProvider::pluginInfo):
* WebView/WebFrame.mm:
(-[WebFrame _canProvideDocumentSource]):

Source/WebKitLegacy/win:

Adapt to API change.

* WebView.cpp:
(WebView::canShowMIMEType):

Canonical link: https://commits.webkit.org/223512@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@260239 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
rwlbuis authored and webkit-commit-queue committed Apr 17, 2020
1 parent e956af8 commit deb28152c6219f55fe5bb1f4ed5238150ad717e2
Showing 17 changed files with 94 additions and 29 deletions.
@@ -1,3 +1,30 @@
2020-04-17 Rob Buis <rbuis@igalia.com>

Move allowPlugins to FrameLoader
https://bugs.webkit.org/show_bug.cgi?id=205876

Reviewed by Darin Adler.

Move allowPlugins to FrameLoader to reduce
pointer dereferences and lessen dependency
on SubframeLoader. Also rename to
arePluginsEnabled since the method is asking
the Setting with the same name.

* dom/DOMImplementation.cpp:
(WebCore::DOMImplementation::createDocument):
* html/HTMLElement.cpp:
(WebCore::HTMLElement::rendererIsEverNeeded):
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::arePluginsEnabled):
* loader/FrameLoader.h:
* loader/SubframeLoader.cpp:
(WebCore::SubframeLoader::createJavaAppletWidget):
(WebCore::SubframeLoader::allowPlugins): Deleted.
* loader/SubframeLoader.h:
* plugins/DOMMimeType.cpp:
(WebCore::DOMMimeType::enabledPlugin const):

2020-04-17 Tomoki Imai <Tomoki.Imai@sony.com>

Fix an integer overflow in WebCrypto AES-CTR Mac implementation, which may detect a false loop
@@ -51,7 +51,6 @@
#include "SecurityOriginPolicy.h"
#include "Settings.h"
#include "StyleSheetContents.h"
#include "SubframeLoader.h"
#include "Text.h"
#include "TextDocument.h"
#include "XMLDocument.h"
@@ -173,7 +172,7 @@ Ref<Document> DOMImplementation::createDocument(const String& type, Frame* frame

// The following is the relatively costly lookup that requires initializing the plug-in database.
if (frame && frame->page()) {
auto allowedPluginTypes = frame->loader().subframeLoader().allowPlugins()
auto allowedPluginTypes = frame->loader().arePluginsEnabled()
? PluginData::AllPlugins : PluginData::OnlyApplicationPlugins;
if (frame->page()->pluginData().supportsWebVisibleMimeType(type, allowedPluginTypes))
return PluginDocument::create(*frame, url);
@@ -63,7 +63,6 @@
#include "ShadowRoot.h"
#include "SimulatedClick.h"
#include "StyleProperties.h"
#include "SubframeLoader.h"
#include "Text.h"
#include "XMLNames.h"
#include "markup.h"
@@ -741,7 +740,7 @@ bool HTMLElement::rendererIsEverNeeded()
return false;
} else if (hasTagName(noembedTag)) {
RefPtr<Frame> frame = document().frame();
if (frame && frame->loader().subframeLoader().allowPlugins())
if (frame && frame->loader().arePluginsEnabled())
return false;
}
return StyledElement::rendererIsEverNeeded();
@@ -4163,6 +4163,11 @@ bool FrameLoader::shouldSuppressTextInputFromEditing() const
return m_frame.settings().shouldSuppressTextInputFromEditingDuringProvisionalNavigation() && m_state == FrameStateProvisional;
}

bool FrameLoader::arePluginsEnabled()
{
return m_frame.settings().arePluginsEnabled();
}

} // namespace WebCore

#undef PAGE_ID
@@ -332,6 +332,8 @@ class FrameLoader final {
// For subresource requests the FrameLoadType parameter has no effect and can be skipped.
void addExtraFieldsToRequest(ResourceRequest&, IsMainResource, FrameLoadType = FrameLoadType::Standard);

WEBCORE_EXPORT bool arePluginsEnabled();

private:
enum FormSubmissionCacheLoadPolicy {
MayAttemptCacheOnlyLoadForFormSubmissionItem,
@@ -154,7 +154,7 @@ bool SubframeLoader::requestPlugin(HTMLPlugInImageElement& ownerElement, const U
// Application plug-ins are plug-ins implemented by the user agent, for example Qt plug-ins,
// as opposed to third-party code such as Flash. The user agent decides whether or not they are
// permitted, rather than WebKit.
if ((!allowPlugins() && !MIMETypeRegistry::isApplicationPluginMIMEType(mimeType)))
if (!(m_frame.settings().arePluginsEnabled() || MIMETypeRegistry::isApplicationPluginMIMEType(mimeType)))
return false;

if (!pluginIsLoadable(url, mimeType))
@@ -279,7 +279,7 @@ RefPtr<Widget> SubframeLoader::createJavaAppletWidget(const IntSize& size, HTMLA
URL baseURL = completeURL(baseURLString);

RefPtr<Widget> widget;
if (allowPlugins())
if (m_frame.settings().arePluginsEnabled())
widget = m_frame.loader().client().createJavaAppletWidget(size, element, baseURL, paramNames, paramValues);

logPluginRequest(m_frame.page(), element.serviceType(), String(), widget);
@@ -382,11 +382,6 @@ RefPtr<Frame> SubframeLoader::loadSubframe(HTMLFrameOwnerElement& ownerElement,
return frame;
}

bool SubframeLoader::allowPlugins()
{
return m_frame.settings().arePluginsEnabled();
}

bool SubframeLoader::shouldUsePlugin(const URL& url, const String& mimeType, bool hasFallback, bool& useFallback)
{
if (m_frame.loader().client().shouldAlwaysUsePluginDocument(mimeType)) {
@@ -61,8 +61,6 @@ class SubframeLoader {

RefPtr<Widget> createJavaAppletWidget(const IntSize&, HTMLAppletElement&, const Vector<String>& paramNames, const Vector<String>& paramValues);

WEBCORE_EXPORT bool allowPlugins();

bool containsPlugins() const { return m_containsPlugins; }

bool resourceWillUsePlugin(const String& url, const String& mimeType);
@@ -24,7 +24,6 @@
#include "FrameLoader.h"
#include "Page.h"
#include "PluginData.h"
#include "SubframeLoader.h"
#include <wtf/text/StringBuilder.h>

namespace WebCore {
@@ -67,7 +66,7 @@ String DOMMimeType::description() const

RefPtr<DOMPlugin> DOMMimeType::enabledPlugin() const
{
if (!m_frame || !m_frame->page() || !m_frame->page()->mainFrame().loader().subframeLoader().allowPlugins())
if (!m_frame || !m_frame->page() || !m_frame->page()->mainFrame().loader().arePluginsEnabled())
return nullptr;

Vector<MimeClassInfo> mimes;
@@ -1,3 +1,22 @@
2020-04-17 Rob Buis <rbuis@igalia.com>

Move allowPlugins to FrameLoader
https://bugs.webkit.org/show_bug.cgi?id=205876

Reviewed by Darin Adler.

Adapt to API change.

* WebProcess/Plugins/WebPluginInfoProvider.cpp:
(WebKit::WebPluginInfoProvider::pluginInfo):
(WebKit::WebPluginInfoProvider::populatePluginCache):
* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::objectContentType):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::createPlugin):
(WebKit::WebPage::canPluginHandleResponse):
(WebKit::WebPage::canShowMIMEType const):

2020-04-16 Peng Liu <peng.liu6@apple.com>

Cleanup the usage of ENABLE_FULLSCREEN_API
@@ -37,7 +37,6 @@
#include <WebCore/LegacySchemeRegistry.h>
#include <WebCore/Page.h>
#include <WebCore/Settings.h>
#include <WebCore/SubframeLoader.h>
#include <wtf/text/StringHash.h>

#if PLATFORM(MAC)
@@ -108,7 +107,7 @@ Vector<PluginInfo> WebPluginInfoProvider::pluginInfo(Page& page, Optional<Vector
if (m_cachedSupportedPluginIdentifiers)
supportedPluginIdentifiers = *m_cachedSupportedPluginIdentifiers;

return page.mainFrame().loader().subframeLoader().allowPlugins() ? m_cachedPlugins : m_cachedApplicationPlugins;
return page.mainFrame().loader().arePluginsEnabled() ? m_cachedPlugins : m_cachedApplicationPlugins;
#else
UNUSED_PARAM(page);
UNUSED_PARAM(supportedPluginIdentifiers);
@@ -151,7 +150,7 @@ void WebPluginInfoProvider::populatePluginCache(const WebCore::Page& page)
// Application plugins are not affected by enablePlugins setting, so we always need to scan plugins to get them.
bool shouldScanPlugins = true;
#else
bool shouldScanPlugins = page.mainFrame().loader().subframeLoader().allowPlugins();
bool shouldScanPlugins = page.mainFrame().loader().arePluginsEnabled();
#endif
if (shouldScanPlugins) {
HangDetectionDisabler hangDetectionDisabler;
@@ -87,7 +87,6 @@
#include <WebCore/ScriptController.h>
#include <WebCore/SecurityOriginData.h>
#include <WebCore/Settings.h>
#include <WebCore/SubframeLoader.h>
#include <WebCore/UIEventWithKeyState.h>
#include <WebCore/Widget.h>
#include <WebCore/WindowFeatures.h>
@@ -1713,7 +1712,7 @@ ObjectContentType WebFrameLoaderClient::objectContentType(const URL& url, const
return ObjectContentType::Image;

if (WebPage* webPage = m_frame->page()) {
auto allowedPluginTypes = webFrame().coreFrame()->loader().subframeLoader().allowPlugins()
auto allowedPluginTypes = webFrame().coreFrame()->loader().arePluginsEnabled()
? PluginData::AllPlugins : PluginData::OnlyApplicationPlugins;
if (webPage->corePage()->pluginData().supportsMimeType(mimeType, allowedPluginTypes))
return ObjectContentType::PlugIn;
@@ -996,7 +996,7 @@ RefPtr<Plugin> WebPage::createPlugin(WebFrame* frame, HTMLPlugInElement* pluginE
PluginProcessType processType = pluginElement->displayState() == HTMLPlugInElement::WaitingForSnapshot ? PluginProcessTypeSnapshot : PluginProcessTypeNormal;
#endif

bool allowOnlyApplicationPlugins = !frame->coreFrame()->loader().subframeLoader().allowPlugins();
bool allowOnlyApplicationPlugins = !frame->coreFrame()->loader().arePluginsEnabled();

uint64_t pluginProcessToken;
uint32_t pluginLoadPolicy;
@@ -5249,7 +5249,7 @@ bool WebPage::canPluginHandleResponse(const ResourceResponse& response)
{
#if ENABLE(NETSCAPE_PLUGIN_API)
uint32_t pluginLoadPolicy;
bool allowOnlyApplicationPlugins = !m_mainFrame->coreFrame()->loader().subframeLoader().allowPlugins();
bool allowOnlyApplicationPlugins = !m_mainFrame->coreFrame()->loader().arePluginsEnabled();

uint64_t pluginProcessToken;
String newMIMEType;
@@ -5797,7 +5797,7 @@ bool WebPage::canShowMIMEType(const String& mimeType, const Function<bool(const
if (!mimeType.isNull() && m_mimeTypesWithCustomContentProviders.contains(mimeType))
return true;

if (corePage()->mainFrame().loader().subframeLoader().allowPlugins() && pluginsSupport(mimeType, PluginData::AllPlugins))
if (corePage()->mainFrame().loader().arePluginsEnabled() && pluginsSupport(mimeType, PluginData::AllPlugins))
return true;

// We can use application plugins even if plugins aren't enabled.
@@ -1,3 +1,17 @@
2020-04-17 Rob Buis <rbuis@igalia.com>

Move allowPlugins to FrameLoader
https://bugs.webkit.org/show_bug.cgi?id=205876

Reviewed by Darin Adler.

Adapt to API change.

* WebCoreSupport/WebPluginInfoProvider.mm:
(WebPluginInfoProvider::pluginInfo):
* WebView/WebFrame.mm:
(-[WebFrame _canProvideDocumentSource]):

2020-04-13 Tim Horton <timothy_horton@apple.com>

REGRESSION (r259843): "Missing Plug-In" when dragging an image into Mail Compose
@@ -30,7 +30,6 @@
#import <WebCore/Frame.h>
#import <WebCore/FrameLoader.h>
#import <WebCore/Page.h>
#import <WebCore/SubframeLoader.h>
#import <wtf/BlockObjCExceptions.h>

using namespace WebCore;
@@ -63,7 +62,7 @@


// WebKit1 has no application plug-ins, so we don't need to add them here.
if (!page.mainFrame().loader().subframeLoader().allowPlugins())
if (!page.mainFrame().loader().arePluginsEnabled())
return plugins;

for (WebPluginPackage *plugin in [WebPluginDatabase sharedDatabase].plugins)
@@ -977,7 +977,7 @@ - (BOOL)_canProvideDocumentSource

if (WebCore::MIMETypeRegistry::isTextMIMEType(mimeType)
|| WebCore::Image::supportsType(mimeType)
|| (pluginData && pluginData->supportsWebVisibleMimeType(mimeType, WebCore::PluginData::AllPlugins) && frame->loader().subframeLoader().allowPlugins())
|| (pluginData && pluginData->supportsWebVisibleMimeType(mimeType, WebCore::PluginData::AllPlugins) && frame->loader().arePluginsEnabled())
|| (pluginData && pluginData->supportsWebVisibleMimeType(mimeType, WebCore::PluginData::OnlyApplicationPlugins)))
return NO;

@@ -1,3 +1,15 @@
2020-04-17 Rob Buis <rbuis@igalia.com>

Move allowPlugins to FrameLoader
https://bugs.webkit.org/show_bug.cgi?id=205876

Reviewed by Darin Adler.

Adapt to API change.

* WebView.cpp:
(WebView::canShowMIMEType):

2020-04-08 Daniel Bates <dabates@apple.com>

Should find touch-action elements inside non-composited iframes
@@ -162,7 +162,6 @@
#include <WebCore/Settings.h>
#include <WebCore/ShouldTreatAsContinuingLoad.h>
#include <WebCore/SocketProvider.h>
#include <WebCore/SubframeLoader.h>
#include <WebCore/SystemInfo.h>
#include <WebCore/TextIterator.h>
#include <WebCore/UserContentController.h>
@@ -2972,14 +2971,14 @@ HRESULT WebView::canShowMIMEType(_In_ BSTR mimeType, _Out_ BOOL* canShow)
bool WebView::canShowMIMEType(const String& mimeType)
{
Frame* coreFrame = core(m_mainFrame);
bool allowPlugins = coreFrame && coreFrame->loader().subframeLoader().allowPlugins();
bool arePluginsEnabled = coreFrame && coreFrame->loader().arePluginsEnabled();

bool canShow = MIMETypeRegistry::isSupportedImageMIMEType(mimeType)
|| MIMETypeRegistry::isSupportedNonImageMIMEType(mimeType)
|| MIMETypeRegistry::isSupportedMediaMIMEType(mimeType);

if (!canShow && m_page) {
canShow = (m_page->pluginData().supportsWebVisibleMimeType(mimeType, PluginData::AllPlugins) && allowPlugins)
canShow = (m_page->pluginData().supportsWebVisibleMimeType(mimeType, PluginData::AllPlugins) && arePluginsEnabled)
|| m_page->pluginData().supportsWebVisibleMimeType(mimeType, PluginData::OnlyApplicationPlugins);
}

0 comments on commit deb2815

Please sign in to comment.