From dba32fdaddc1a5fa684cc1a459c98655c71f362a Mon Sep 17 00:00:00 2001 From: "achristensen@apple.com" Date: Fri, 16 Oct 2015 23:21:14 +0000 Subject: [PATCH] Disabled content blockers should not block any loads https://bugs.webkit.org/show_bug.cgi?id=150261 Reviewed by Brady Eidson. This fix was tested manually by reloading without content blockers on websites with iframes and content blockers that block the contents of the iframes. * page/UserContentController.cpp: (WebCore::UserContentController::removeAllUserContentExtensions): (WebCore::contentExtensionsEnabled): (WebCore::UserContentController::processContentExtensionRulesForLoad): (WebCore::UserContentController::actionsForResourceLoad): Check the DocumentLoader of the main frame when checking if content extensions are disabled, because that is the DocumentLoader that has the flag from reloading without content blockers. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@191223 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Source/WebCore/ChangeLog | 18 ++++++++++++++++++ Source/WebCore/page/UserContentController.cpp | 16 ++++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 90aa712..356531b 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,21 @@ +2015-10-16 Alex Christensen + + Disabled content blockers should not block any loads + https://bugs.webkit.org/show_bug.cgi?id=150261 + + Reviewed by Brady Eidson. + + This fix was tested manually by reloading without content blockers + on websites with iframes and content blockers that block the contents of the iframes. + + * page/UserContentController.cpp: + (WebCore::UserContentController::removeAllUserContentExtensions): + (WebCore::contentExtensionsEnabled): + (WebCore::UserContentController::processContentExtensionRulesForLoad): + (WebCore::UserContentController::actionsForResourceLoad): + Check the DocumentLoader of the main frame when checking if content extensions are disabled, + because that is the DocumentLoader that has the flag from reloading without content blockers. + 2015-10-16 Simon Fraser Make TextStream the canonical way to log classes in WebCore diff --git a/Source/WebCore/page/UserContentController.cpp b/Source/WebCore/page/UserContentController.cpp index 88b6350b..ff9e2da 100644 --- a/Source/WebCore/page/UserContentController.cpp +++ b/Source/WebCore/page/UserContentController.cpp @@ -208,12 +208,24 @@ void UserContentController::removeAllUserContentExtensions() m_contentExtensionBackend->removeAllContentExtensions(); } +static bool contentExtensionsEnabled(const DocumentLoader& documentLoader) +{ + if (auto frame = documentLoader.frame()) { + if (frame->isMainFrame()) + return documentLoader.userContentExtensionsEnabled(); + if (auto mainDocumentLoader = frame->mainFrame().loader().documentLoader()) + return mainDocumentLoader->userContentExtensionsEnabled(); + } + + return true; +} + ContentExtensions::BlockedStatus UserContentController::processContentExtensionRulesForLoad(ResourceRequest& request, ResourceType resourceType, DocumentLoader& initiatingDocumentLoader) { if (!m_contentExtensionBackend) return ContentExtensions::BlockedStatus::NotBlocked; - if (!initiatingDocumentLoader.userContentExtensionsEnabled()) + if (!contentExtensionsEnabled(initiatingDocumentLoader)) return ContentExtensions::BlockedStatus::NotBlocked; return m_contentExtensionBackend->processContentExtensionRulesForLoad(request, resourceType, initiatingDocumentLoader); @@ -224,7 +236,7 @@ Vector UserContentController::actionsForResourceLoad( if (!m_contentExtensionBackend) return Vector(); - if (!initiatingDocumentLoader.userContentExtensionsEnabled()) + if (!contentExtensionsEnabled(initiatingDocumentLoader)) return Vector(); return m_contentExtensionBackend->actionsForResourceLoad(resourceLoadInfo); -- 1.8.3.1