Title: [229390] trunk
Revision
229390
Author
you...@apple.com
Date
2018-03-07 18:06:39 -0800 (Wed, 07 Mar 2018)

Log Message

Match unsupported plugins based on domains and not origin
https://bugs.webkit.org/show_bug.cgi?id=183384

Reviewed by Chris Dumez.

Source/WebCore:

Move from an origin-keyed map to a vector of plugins.
We iterate through the vector and a match happens if the page host name ends with the provided matching domain.
This allows supporting rules for *.mydomain.com by passing 'mydomain.com'.
Covered by existing tests.
We are not testing subdomains like www.localhost since there is no support in our CI but this is tested through Unit tests.

* loader/EmptyClients.cpp:
* platform/URL.cpp:
(WebCore::URL::isMatchingDomain const):
* platform/URL.h:
* plugins/PluginData.h:
(WebCore::isSupportedPlugin):
(WebCore::SupportedPluginName::decode):
(WebCore::SupportedPluginName::encode const):
* plugins/PluginInfoProvider.h:

Source/WebKit:

Moved from a HashMap of plugins to a Vector of plugins since we cannot match exactly based on the origin.

* Scripts/webkit/messages.py:
* UIProcess/API/C/WKContext.cpp:
(WKContextAddSupportedPlugin):
* UIProcess/API/Cocoa/WKProcessPool.mm:
(-[WKProcessPool _addSupportedPlugin:named:withMimeTypes:withExtensions:]):
* UIProcess/Plugins/PluginInfoStore.cpp:
(WebKit::PluginInfoStore::isSupportedPlugin):
(WebKit::PluginInfoStore::supportedPluginNames):
(WebKit::PluginInfoStore::addSupportedPlugin):
* UIProcess/Plugins/PluginInfoStore.h:
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::addSupportedPlugin):
* UIProcess/WebProcessPool.h:
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::getPlugins):
* UIProcess/WebProcessProxy.h:
* UIProcess/WebProcessProxy.messages.in:
* WebProcess/Plugins/WebPluginInfoProvider.cpp:
(WebKit::WebPluginInfoProvider::getPluginInfo):
(WebKit::WebPluginInfoProvider::getWebVisiblePluginInfo):
* WebProcess/Plugins/WebPluginInfoProvider.h:

Source/WebKitLegacy/mac:

* WebCoreSupport/WebPluginInfoProvider.h:
* WebCoreSupport/WebPluginInfoProvider.mm:
(WebPluginInfoProvider::getPluginInfo):
(WebPluginInfoProvider::getWebVisiblePluginInfo):

Tools:

* TestWebKitAPI/Tests/WebCore/URL.cpp:
(TestWebKitAPI::TEST_F):
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::setPluginSupportedMode): Update to whitelist
localhost and not http://localhost:8080

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (229389 => 229390)


--- trunk/Source/WebCore/ChangeLog	2018-03-08 01:33:08 UTC (rev 229389)
+++ trunk/Source/WebCore/ChangeLog	2018-03-08 02:06:39 UTC (rev 229390)
@@ -1,3 +1,26 @@
+2018-03-07  Youenn Fablet  <you...@apple.com>
+
+        Match unsupported plugins based on domains and not origin
+        https://bugs.webkit.org/show_bug.cgi?id=183384
+
+        Reviewed by Chris Dumez.
+
+        Move from an origin-keyed map to a vector of plugins.
+        We iterate through the vector and a match happens if the page host name ends with the provided matching domain.
+        This allows supporting rules for *.mydomain.com by passing 'mydomain.com'.
+        Covered by existing tests.
+        We are not testing subdomains like www.localhost since there is no support in our CI but this is tested through Unit tests.
+
+        * loader/EmptyClients.cpp:
+        * platform/URL.cpp:
+        (WebCore::URL::isMatchingDomain const):
+        * platform/URL.h:
+        * plugins/PluginData.h:
+        (WebCore::isSupportedPlugin):
+        (WebCore::SupportedPluginName::decode):
+        (WebCore::SupportedPluginName::encode const):
+        * plugins/PluginInfoProvider.h:
+
 2017-12-18  Youenn Fablet  <you...@apple.com>
 
         Update to libwebrtc revision 4e70a72571dd26b85c2385e9c618e343428df5d3

Modified: trunk/Source/WebCore/loader/EmptyClients.cpp (229389 => 229390)


--- trunk/Source/WebCore/loader/EmptyClients.cpp	2018-03-08 01:33:08 UTC (rev 229389)
+++ trunk/Source/WebCore/loader/EmptyClients.cpp	2018-03-08 02:06:39 UTC (rev 229390)
@@ -325,7 +325,7 @@
 
 class EmptyPluginInfoProvider final : public PluginInfoProvider {
     void refreshPlugins() final { };
-    void getPluginInfo(Page&, Vector<PluginInfo>&, std::optional<SupportedPluginNames>&) final { }
+    void getPluginInfo(Page&, Vector<PluginInfo>&, std::optional<Vector<SupportedPluginName>>&) final { }
     void getWebVisiblePluginInfo(Page&, Vector<PluginInfo>&) final { }
 };
 

Modified: trunk/Source/WebCore/platform/URL.cpp (229389 => 229390)


--- trunk/Source/WebCore/platform/URL.cpp	2018-03-08 01:33:08 UTC (rev 229389)
+++ trunk/Source/WebCore/platform/URL.cpp	2018-03-08 02:06:39 UTC (rev 229390)
@@ -776,6 +776,22 @@
     return true;
 }
 
+bool URL::isMatchingDomain(const String& domain) const
+{
+    // We restrict it to HTTP for simplicity since we do not want to match data, blob or file based URLs.
+    if (isNull() || !protocolIsInHTTPFamily())
+        return false;
+
+    if (domain.isEmpty())
+        return true;
+
+    auto host = this->host();
+    if (!host.endsWith(domain))
+        return false;
+
+    return host.length() == domain.length() || host.characterAt(host.length() - domain.length() - 1) == '.';
+}
+
 String encodeWithURLEscapeSequences(const String& input)
 {
     return percentEncodeCharacters(input, URLParser::isInUserInfoEncodeSet);

Modified: trunk/Source/WebCore/platform/URL.h (229389 => 229390)


--- trunk/Source/WebCore/platform/URL.h	2018-03-08 01:33:08 UTC (rev 229389)
+++ trunk/Source/WebCore/platform/URL.h	2018-03-08 02:06:39 UTC (rev 229390)
@@ -141,6 +141,8 @@
     WEBCORE_EXPORT bool isBlankURL() const;
     bool cannotBeABaseURL() const { return m_cannotBeABaseURL; }
 
+    WEBCORE_EXPORT bool isMatchingDomain(const String&) const;
+
     WEBCORE_EXPORT bool setProtocol(const String&);
     void setHost(const String&);
 

Modified: trunk/Source/WebCore/plugins/PluginData.h (229389 => 229390)


--- trunk/Source/WebCore/plugins/PluginData.h	2018-03-08 01:33:08 UTC (rev 229389)
+++ trunk/Source/WebCore/plugins/PluginData.h	2018-03-08 02:06:39 UTC (rev 229390)
@@ -20,7 +20,7 @@
 
 #pragma once
 
-#include "SecurityOriginData.h"
+#include "URL.h"
 #include <wtf/HashMap.h>
 #include <wtf/HashSet.h>
 #include <wtf/RefCounted.h>
@@ -88,12 +88,12 @@
     return result;
 }
 
-struct SupportedPluginNames {
-    HashSet<String> allOriginPlugins;
-    HashMap<SecurityOriginData, HashSet<String>> originSpecificPlugins;
+struct SupportedPluginName {
+    String matchingDomain;
+    String pluginName;
 
     template<class Encoder> void encode(Encoder&) const;
-    template<class Decoder> static std::optional<SupportedPluginNames> decode(Decoder&);
+    template<class Decoder> static std::optional<SupportedPluginName> decode(Decoder&);
 };
 
 // FIXME: merge with PluginDatabase in the future
@@ -126,39 +126,35 @@
 protected:
     Page& m_page;
     Vector<PluginInfo> m_plugins;
-    std::optional<SupportedPluginNames> m_supportedPluginNames;
+    std::optional<Vector<SupportedPluginName>> m_supportedPluginNames;
 };
 
-inline bool isSupportedPlugin(SupportedPluginNames& pluginNames, SecurityOriginData& origin, const String& pluginName)
+inline bool isSupportedPlugin(const Vector<SupportedPluginName>& pluginNames, const URL& pageURL, const String& pluginName)
 {
-    auto iterator = pluginNames.originSpecificPlugins.find(origin);
-    if (iterator != pluginNames.originSpecificPlugins.end()) {
-        if (iterator->value.contains(pluginName))
-            return true;
-    }
-
-    return pluginNames.allOriginPlugins.contains(pluginName);
+    return pluginNames.findMatching([&] (auto&& plugin) {
+        return pageURL.isMatchingDomain(plugin.matchingDomain) && plugin.pluginName == pluginName;
+    }) != notFound;
 }
 
-template<class Decoder> inline std::optional<SupportedPluginNames> SupportedPluginNames::decode(Decoder& decoder)
+template<class Decoder> inline std::optional<SupportedPluginName> SupportedPluginName::decode(Decoder& decoder)
 {
-    std::optional<HashSet<String>> allOriginPlugins;
-    decoder >> allOriginPlugins;
-    if (!allOriginPlugins)
+    std::optional<String> matchingDomain;
+    decoder >> matchingDomain;
+    if (!matchingDomain)
         return std::nullopt;
 
-    std::optional<HashMap<SecurityOriginData, HashSet<String>>> originSpecificPlugins;
-    decoder >> originSpecificPlugins;
-    if (!originSpecificPlugins)
+    std::optional<String> pluginName;
+    decoder >> pluginName;
+    if (!pluginName)
         return std::nullopt;
 
-    return SupportedPluginNames { WTFMove(allOriginPlugins.value()), WTFMove(originSpecificPlugins.value()) };
+    return SupportedPluginName { WTFMove(matchingDomain.value()), WTFMove(pluginName.value()) };
 }
 
-template<class Encoder> inline void SupportedPluginNames::encode(Encoder& encoder) const
+template<class Encoder> inline void SupportedPluginName::encode(Encoder& encoder) const
 {
-    encoder << allOriginPlugins;
-    encoder << originSpecificPlugins;
+    encoder << matchingDomain;
+    encoder << pluginName;
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/plugins/PluginInfoProvider.h (229389 => 229390)


--- trunk/Source/WebCore/plugins/PluginInfoProvider.h	2018-03-08 01:33:08 UTC (rev 229389)
+++ trunk/Source/WebCore/plugins/PluginInfoProvider.h	2018-03-08 02:06:39 UTC (rev 229390)
@@ -39,7 +39,7 @@
     void addPage(Page&);
     void removePage(Page&);
 
-    virtual void getPluginInfo(Page&, Vector<PluginInfo>&, std::optional<SupportedPluginNames>&) = 0;
+    virtual void getPluginInfo(Page&, Vector<PluginInfo>&, std::optional<Vector<SupportedPluginName>>&) = 0;
     virtual void getWebVisiblePluginInfo(Page&, Vector<PluginInfo>&) = 0;
 
 private:

Modified: trunk/Source/WebKit/ChangeLog (229389 => 229390)


--- trunk/Source/WebKit/ChangeLog	2018-03-08 01:33:08 UTC (rev 229389)
+++ trunk/Source/WebKit/ChangeLog	2018-03-08 02:06:39 UTC (rev 229390)
@@ -1,3 +1,34 @@
+2018-03-07  Youenn Fablet  <you...@apple.com>
+
+        Match unsupported plugins based on domains and not origin
+        https://bugs.webkit.org/show_bug.cgi?id=183384
+
+        Reviewed by Chris Dumez.
+
+        Moved from a HashMap of plugins to a Vector of plugins since we cannot match exactly based on the origin.
+
+        * Scripts/webkit/messages.py:
+        * UIProcess/API/C/WKContext.cpp:
+        (WKContextAddSupportedPlugin):
+        * UIProcess/API/Cocoa/WKProcessPool.mm:
+        (-[WKProcessPool _addSupportedPlugin:named:withMimeTypes:withExtensions:]):
+        * UIProcess/Plugins/PluginInfoStore.cpp:
+        (WebKit::PluginInfoStore::isSupportedPlugin):
+        (WebKit::PluginInfoStore::supportedPluginNames):
+        (WebKit::PluginInfoStore::addSupportedPlugin):
+        * UIProcess/Plugins/PluginInfoStore.h:
+        * UIProcess/WebProcessPool.cpp:
+        (WebKit::WebProcessPool::addSupportedPlugin):
+        * UIProcess/WebProcessPool.h:
+        * UIProcess/WebProcessProxy.cpp:
+        (WebKit::WebProcessProxy::getPlugins):
+        * UIProcess/WebProcessProxy.h:
+        * UIProcess/WebProcessProxy.messages.in:
+        * WebProcess/Plugins/WebPluginInfoProvider.cpp:
+        (WebKit::WebPluginInfoProvider::getPluginInfo):
+        (WebKit::WebPluginInfoProvider::getWebVisiblePluginInfo):
+        * WebProcess/Plugins/WebPluginInfoProvider.h:
+
 2018-03-07  Brent Fulgham  <bfulg...@apple.com>
 
         REGRESSION (r229093): Media playback on Facebook and Hulu require mDNSResponder access

Modified: trunk/Source/WebKit/Scripts/webkit/messages.py (229389 => 229390)


--- trunk/Source/WebKit/Scripts/webkit/messages.py	2018-03-08 01:33:08 UTC (rev 229389)
+++ trunk/Source/WebKit/Scripts/webkit/messages.py	2018-03-08 02:06:39 UTC (rev 229390)
@@ -398,7 +398,7 @@
         'WebCore::ShippingMethodUpdate': ['<WebCore/ApplePaySessionPaymentRequest.h>'],
         'WebCore::ShouldNotifyWhenResolved': ['<WebCore/ServiceWorkerTypes.h>'],
         'WebCore::ShouldSample': ['<WebCore/DiagnosticLoggingClient.h>'],
-        'WebCore::SupportedPluginNames': ['<WebCore/PluginData.h>'],
+        'WebCore::SupportedPluginName': ['<WebCore/PluginData.h>'],
         'WebCore::TextCheckingRequestData': ['<WebCore/TextChecking.h>'],
         'WebCore::TextCheckingResult': ['<WebCore/TextCheckerClient.h>'],
         'WebCore::TextIndicatorData': ['<WebCore/TextIndicator.h>'],

Modified: trunk/Source/WebKit/UIProcess/API/C/WKContext.cpp (229389 => 229390)


--- trunk/Source/WebKit/UIProcess/API/C/WKContext.cpp	2018-03-08 01:33:08 UTC (rev 229389)
+++ trunk/Source/WebKit/UIProcess/API/C/WKContext.cpp	2018-03-08 02:06:39 UTC (rev 229390)
@@ -621,7 +621,7 @@
     return toImpl(contextRef)->storageProcessIdentifier();
 }
 
-void WKContextAddSupportedPlugin(WKContextRef contextRef, WKStringRef originRef, WKStringRef nameRef, WKArrayRef mimeTypesRef, WKArrayRef extensionsRef)
+void WKContextAddSupportedPlugin(WKContextRef contextRef, WKStringRef domainRef, WKStringRef nameRef, WKArrayRef mimeTypesRef, WKArrayRef extensionsRef)
 {
 #if ENABLE(NETSCAPE_PLUGIN_API)
     HashSet<String> mimeTypes;
@@ -634,10 +634,7 @@
     for (size_t i = 0; i < count; ++i)
         extensions.add(toWTFString(static_cast<WKStringRef>(WKArrayGetItemAtIndex(extensionsRef, i))));
 
-    RefPtr<SecurityOrigin> origin;
-    if (!WKStringIsEmpty(originRef))
-        origin = SecurityOrigin::createFromString(toWTFString(originRef));
-    toImpl(contextRef)->addSupportedPlugin(origin.get(), toWTFString(nameRef), WTFMove(mimeTypes), WTFMove(extensions));
+    toImpl(contextRef)->addSupportedPlugin(toWTFString(domainRef), toWTFString(nameRef), WTFMove(mimeTypes), WTFMove(extensions));
 #endif
 }
 

Modified: trunk/Source/WebKit/UIProcess/API/C/WKContextPrivate.h (229389 => 229390)


--- trunk/Source/WebKit/UIProcess/API/C/WKContextPrivate.h	2018-03-08 01:33:08 UTC (rev 229389)
+++ trunk/Source/WebKit/UIProcess/API/C/WKContextPrivate.h	2018-03-08 02:06:39 UTC (rev 229390)
@@ -112,7 +112,7 @@
 WK_EXPORT WKProcessID WKContextGetNetworkProcessIdentifier(WKContextRef context);
 WK_EXPORT WKProcessID WKContextGetDatabaseProcessIdentifier(WKContextRef context);
 
-WK_EXPORT void WKContextAddSupportedPlugin(WKContextRef context, WKStringRef origin, WKStringRef name, WKArrayRef mimeTypes, WKArrayRef extensions);
+WK_EXPORT void WKContextAddSupportedPlugin(WKContextRef context, WKStringRef domain, WKStringRef name, WKArrayRef mimeTypes, WKArrayRef extensions);
 WK_EXPORT void WKContextClearSupportedPlugins(WKContextRef context);
 
 #ifdef __cplusplus

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm (229389 => 229390)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm	2018-03-08 01:33:08 UTC (rev 229389)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm	2018-03-08 02:06:39 UTC (rev 229390)
@@ -397,7 +397,7 @@
     _processPool->setAutomationSession(automationSession ? automationSession->_session.get() : nullptr);
 }
 
-- (void)_addSupportedPlugin:(NSString *) origin named:(NSString *) name withMimeTypes: (NSSet<NSString *> *) nsMimeTypes withExtensions: (NSSet<NSString *> *) nsExtensions
+- (void)_addSupportedPlugin:(NSString *) domain named:(NSString *) name withMimeTypes: (NSSet<NSString *> *) nsMimeTypes withExtensions: (NSSet<NSString *> *) nsExtensions
 {
     HashSet<String> mimeTypes;
     for (NSString *mimeType in nsMimeTypes)
@@ -406,7 +406,7 @@
     for (NSString *extension in nsExtensions)
         extensions.add(extension);
 
-    _processPool->addSupportedPlugin([origin length] ? WebCore::SecurityOrigin::createFromString(origin).ptr() : nullptr, name, WTFMove(mimeTypes), WTFMove(extensions));
+    _processPool->addSupportedPlugin(domain, name, WTFMove(mimeTypes), WTFMove(extensions));
 }
 
 - (void)_clearSupportedPlugins

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKProcessPoolPrivate.h (229389 => 229390)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKProcessPoolPrivate.h	2018-03-08 01:33:08 UTC (rev 229389)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKProcessPoolPrivate.h	2018-03-08 02:06:39 UTC (rev 229390)
@@ -72,7 +72,7 @@
 - (void)_automationCapabilitiesDidChange WK_API_AVAILABLE(macosx(10.12), ios(10.0));
 - (void)_setAutomationSession:(_WKAutomationSession *)automationSession WK_API_AVAILABLE(macosx(10.12), ios(10.0));
 
-- (void)_addSupportedPlugin:(NSString *) origin named:(NSString *) name withMimeTypes: (NSSet<NSString *> *) mimeTypes withExtensions: (NSSet<NSString *> *) extensions WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
+- (void)_addSupportedPlugin:(NSString *) domain named:(NSString *) name withMimeTypes: (NSSet<NSString *> *) mimeTypes withExtensions: (NSSet<NSString *> *) extensions WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
 - (void)_clearSupportedPlugins WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
 
 // Test only. Should be called only while no web content processes are running.

Modified: trunk/Source/WebKit/UIProcess/Plugins/PluginInfoStore.cpp (229389 => 229390)


--- trunk/Source/WebKit/UIProcess/Plugins/PluginInfoStore.cpp	2018-03-08 01:33:08 UTC (rev 229389)
+++ trunk/Source/WebKit/UIProcess/Plugins/PluginInfoStore.cpp	2018-03-08 02:06:39 UTC (rev 229390)
@@ -29,8 +29,9 @@
 #if ENABLE(NETSCAPE_PLUGIN_API)
 
 #include "PluginModuleInfo.h"
+#include <WebCore/MIMETypeRegistry.h>
+#include <WebCore/SecurityOrigin.h>
 #include <WebCore/URL.h>
-#include <WebCore/MIMETypeRegistry.h>
 #include <algorithm>
 #include <wtf/ListHashSet.h>
 #include <wtf/StdLibExtras.h>
@@ -214,53 +215,31 @@
 
 bool PluginInfoStore::isSupportedPlugin(const String& mimeType, const URL& pluginURL, const String&, const URL& pageURL)
 {
-    // We check only pageURLString for consistency with WebProcess visible plugins.
+    // We check only pageURL for consistency with WebProcess visible plugins.
     if (!m_supportedPlugins)
         return true;
 
-    for (auto& plugin : m_supportedPlugins->originSpecificPlugins.get(SecurityOriginData { pageURL.protocol().toString(), pageURL.host(), pageURL.port() })) {
-        if (isSupportedPlugin(plugin, mimeType, pluginURL))
-            return true;
-    }
-    for (auto& plugin : m_supportedPlugins->allOriginPlugins) {
-        if (isSupportedPlugin(plugin, mimeType, pluginURL))
-            return true;
-    }
-    return false;
+    return m_supportedPlugins->findMatching([&] (auto&& plugin) {
+        return pageURL.isMatchingDomain(plugin.matchingDomain) && isSupportedPlugin(plugin, mimeType, pluginURL);
+    }) != notFound;
 }
 
-std::optional<SupportedPluginNames> PluginInfoStore::supportedPluginNames()
+std::optional<Vector<SupportedPluginName>> PluginInfoStore::supportedPluginNames()
 {
     if (!m_supportedPlugins)
         return std::nullopt;
 
-    HashSet<String> allOriginPlugins;
-    for (auto& plugin : m_supportedPlugins->allOriginPlugins)
-        allOriginPlugins.add(plugin.name);
-
-    HashMap<SecurityOriginData, HashSet<String>> originSpecificPlugins;
-    for (auto& keyValue : m_supportedPlugins->originSpecificPlugins) {
-        HashSet<String> names;
-        for (auto& plugin : keyValue.value)
-            names.add(plugin.name);
-        originSpecificPlugins.add(keyValue.key, WTFMove(names));
-    }
-    return SupportedPluginNames { WTFMove(allOriginPlugins), WTFMove(originSpecificPlugins) };
+    return WTF::map(*m_supportedPlugins, [] (auto&& item) {
+        return SupportedPluginName { item.matchingDomain, item.name };
+    });
 }
 
-void PluginInfoStore::addSupportedPlugin(const SecurityOrigin* origin, String&& name, HashSet<String>&& mimeTypes, HashSet<String> extensions)
+void PluginInfoStore::addSupportedPlugin(String&& domainName, String&& name, HashSet<String>&& mimeTypes, HashSet<String> extensions)
 {
     if (!m_supportedPlugins)
-        m_supportedPlugins = SupportedPlugins { };
+        m_supportedPlugins = Vector<SupportedPlugin> { };
 
-    SupportedPlugin plugin { WTFMove(name), WTFMove(mimeTypes), WTFMove(extensions) };
-    if (!origin) {
-        m_supportedPlugins->allOriginPlugins.append(WTFMove(plugin));
-        return;
-    }
-    m_supportedPlugins->originSpecificPlugins.ensure(SecurityOriginData::fromSecurityOrigin(*origin), [] {
-        return Vector<SupportedPlugin> { };
-    }).iterator->value.append(WTFMove(plugin));
+    m_supportedPlugins->append(SupportedPlugin { WTFMove(domainName), WTFMove(name), WTFMove(mimeTypes), WTFMove(extensions) });
 }
 
 PluginModuleInfo PluginInfoStore::infoForPluginWithPath(const String& pluginPath) const

Modified: trunk/Source/WebKit/UIProcess/Plugins/PluginInfoStore.h (229389 => 229390)


--- trunk/Source/WebKit/UIProcess/Plugins/PluginInfoStore.h	2018-03-08 01:33:08 UTC (rev 229389)
+++ trunk/Source/WebKit/UIProcess/Plugins/PluginInfoStore.h	2018-03-08 02:06:39 UTC (rev 229390)
@@ -64,8 +64,8 @@
     static PluginModuleLoadPolicy defaultLoadPolicyForPlugin(const PluginModuleInfo&);
 
     bool isSupportedPlugin(const String& mimeType, const WebCore::URL& pluginURL, const String& frameURLString, const WebCore::URL& pageURL);
-    std::optional<WebCore::SupportedPluginNames> supportedPluginNames();
-    void addSupportedPlugin(const WebCore::SecurityOrigin*, String&& name, HashSet<String>&& mimeTypes, HashSet<String> extensions);
+    std::optional<Vector<WebCore::SupportedPluginName>> supportedPluginNames();
+    void addSupportedPlugin(String&& matchingDomain, String&& name, HashSet<String>&& mimeTypes, HashSet<String> extensions);
     void clearSupportedPlugins() { m_supportedPlugins = std::nullopt; }
 
 private:
@@ -97,17 +97,14 @@
     bool m_pluginListIsUpToDate;
 
     struct SupportedPlugin {
+        String matchingDomain;
         String name;
         HashSet<String> mimeTypes;
         HashSet<String> extensions;
     };
-    struct SupportedPlugins {
-        Vector<SupportedPlugin> allOriginPlugins;
-        HashMap<WebCore::SecurityOriginData, Vector<SupportedPlugin>> originSpecificPlugins;
-    };
     static bool isSupportedPlugin(const SupportedPlugin&, const String& mimeType, const WebCore::URL& pluginURL);
 
-    std::optional<SupportedPlugins> m_supportedPlugins;
+    std::optional<Vector<SupportedPlugin>> m_supportedPlugins;
 };
     
 } // namespace WebKit

Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.cpp (229389 => 229390)


--- trunk/Source/WebKit/UIProcess/WebProcessPool.cpp	2018-03-08 01:33:08 UTC (rev 229389)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.cpp	2018-03-08 02:06:39 UTC (rev 229390)
@@ -1793,12 +1793,12 @@
 }
 #endif
 
-void WebProcessPool::addSupportedPlugin(SecurityOrigin* origin, String&& name, HashSet<String>&& mimeTypes, HashSet<String> extensions)
+void WebProcessPool::addSupportedPlugin(String&& matchingDomain, String&& name, HashSet<String>&& mimeTypes, HashSet<String> extensions)
 {
 #if ENABLE(NETSCAPE_PLUGIN_API)
-    m_pluginInfoStore.addSupportedPlugin(origin, WTFMove(name), WTFMove(mimeTypes), WTFMove(extensions));
+    m_pluginInfoStore.addSupportedPlugin(WTFMove(matchingDomain), WTFMove(name), WTFMove(mimeTypes), WTFMove(extensions));
 #else
-    UNUSED_PARAM(origin);
+    UNUSED_PARAM(matchingDomain);
     UNUSED_PARAM(name);
     UNUSED_PARAM(mimeTypes);
     UNUSED_PARAM(extensions);

Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.h (229389 => 229390)


--- trunk/Source/WebKit/UIProcess/WebProcessPool.h	2018-03-08 01:33:08 UTC (rev 229389)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.h	2018-03-08 02:06:39 UTC (rev 229390)
@@ -202,7 +202,7 @@
     const HashMap<String, HashMap<String, HashMap<String, uint8_t>>>& pluginLoadClientPolicies() const { return m_pluginLoadClientPolicies; }
 #endif
 
-    void addSupportedPlugin(WebCore::SecurityOrigin*, String&& name, HashSet<String>&& mimeTypes, HashSet<String> extensions);
+    void addSupportedPlugin(String&& matchingDomain, String&& name, HashSet<String>&& mimeTypes, HashSet<String> extensions);
     void clearSupportedPlugins();
 
     ProcessID networkProcessIdentifier();

Modified: trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp (229389 => 229390)


--- trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp	2018-03-08 01:33:08 UTC (rev 229389)
+++ trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp	2018-03-08 02:06:39 UTC (rev 229390)
@@ -570,7 +570,7 @@
 }
 
 #if ENABLE(NETSCAPE_PLUGIN_API)
-void WebProcessProxy::getPlugins(bool refresh, Vector<PluginInfo>& plugins, Vector<PluginInfo>& applicationPlugins, std::optional<WebCore::SupportedPluginNames>& supportedPluginNames)
+void WebProcessProxy::getPlugins(bool refresh, Vector<PluginInfo>& plugins, Vector<PluginInfo>& applicationPlugins, std::optional<Vector<WebCore::SupportedPluginName>>& supportedPluginNames)
 {
     if (refresh)
         m_processPool->pluginInfoStore().refresh();

Modified: trunk/Source/WebKit/UIProcess/WebProcessProxy.h (229389 => 229390)


--- trunk/Source/WebKit/UIProcess/WebProcessProxy.h	2018-03-08 01:33:08 UTC (rev 229389)
+++ trunk/Source/WebKit/UIProcess/WebProcessProxy.h	2018-03-08 02:06:39 UTC (rev 229390)
@@ -238,7 +238,7 @@
 
     // Plugins
 #if ENABLE(NETSCAPE_PLUGIN_API)
-    void getPlugins(bool refresh, Vector<WebCore::PluginInfo>& plugins, Vector<WebCore::PluginInfo>& applicationPlugins, std::optional<WebCore::SupportedPluginNames>&);
+    void getPlugins(bool refresh, Vector<WebCore::PluginInfo>& plugins, Vector<WebCore::PluginInfo>& applicationPlugins, std::optional<Vector<WebCore::SupportedPluginName>>&);
 #endif // ENABLE(NETSCAPE_PLUGIN_API)
 #if ENABLE(NETSCAPE_PLUGIN_API)
     void getPluginProcessConnection(uint64_t pluginProcessToken, Ref<Messages::WebProcessProxy::GetPluginProcessConnection::DelayedReply>&&);

Modified: trunk/Source/WebKit/UIProcess/WebProcessProxy.messages.in (229389 => 229390)


--- trunk/Source/WebKit/UIProcess/WebProcessProxy.messages.in	2018-03-08 01:33:08 UTC (rev 229389)
+++ trunk/Source/WebKit/UIProcess/WebProcessProxy.messages.in	2018-03-08 02:06:39 UTC (rev 229390)
@@ -33,7 +33,7 @@
 
     # Plugin messages.
 #if ENABLE(NETSCAPE_PLUGIN_API)
-    GetPlugins(bool refresh) -> (Vector<WebCore::PluginInfo> plugins, Vector<WebCore::PluginInfo> applicationPlugins, struct std::optional<WebCore::SupportedPluginNames> supportedPluginNames)
+    GetPlugins(bool refresh) -> (Vector<WebCore::PluginInfo> plugins, Vector<WebCore::PluginInfo> applicationPlugins, struct std::optional<Vector<WebCore::SupportedPluginName>> supportedPluginNames)
     GetPluginProcessConnection(uint64_t pluginProcessToken) -> (IPC::Attachment connectionHandle, bool supportsAsynchronousInitialization) Delayed
 #endif
     GetNetworkProcessConnection() -> (IPC::Attachment connectionHandle) Delayed

Modified: trunk/Source/WebKit/WebProcess/Plugins/WebPluginInfoProvider.cpp (229389 => 229390)


--- trunk/Source/WebKit/WebProcess/Plugins/WebPluginInfoProvider.cpp	2018-03-08 01:33:08 UTC (rev 229389)
+++ trunk/Source/WebKit/WebProcess/Plugins/WebPluginInfoProvider.cpp	2018-03-08 02:06:39 UTC (rev 229390)
@@ -35,7 +35,6 @@
 #include <WebCore/FrameLoader.h>
 #include <WebCore/MainFrame.h>
 #include <WebCore/Page.h>
-#include <WebCore/SecurityOriginData.h>
 #include <WebCore/SubframeLoader.h>
 #include <wtf/text/StringHash.h>
 
@@ -97,7 +96,7 @@
 #endif
 }
 
-void WebPluginInfoProvider::getPluginInfo(Page& page, Vector<PluginInfo>& plugins, std::optional<SupportedPluginNames>& supportedPluginNames)
+void WebPluginInfoProvider::getPluginInfo(Page& page, Vector<PluginInfo>& plugins, std::optional<Vector<SupportedPluginName>>& supportedPluginNames)
 {
 #if ENABLE(NETSCAPE_PLUGIN_API)
     populatePluginCache(page);
@@ -121,20 +120,19 @@
 {
     ASSERT_ARG(plugins, plugins.isEmpty());
 
-    std::optional<WebCore::SupportedPluginNames> supportedPluginNames;
+    std::optional<Vector<WebCore::SupportedPluginName>> supportedPluginNames;
     getPluginInfo(page, plugins, supportedPluginNames);
 
     auto* document = page.mainFrame().document();
-    auto* origin = document ? &document->securityOrigin(): nullptr;
 
-    if (origin && supportedPluginNames) {
-        auto originData = SecurityOriginData::fromSecurityOrigin(*origin);
+    if (document && supportedPluginNames) {
         plugins.removeAllMatching([&] (auto& plugin) {
-            return !isSupportedPlugin(*supportedPluginNames, originData, plugin.name);
+            return !isSupportedPlugin(*supportedPluginNames, document->url(), plugin.name);
         });
     }
 
 #if PLATFORM(MAC)
+    auto* origin = document ? &document->securityOrigin(): nullptr;
     if (origin && origin->isLocal())
         return;
 

Modified: trunk/Source/WebKit/WebProcess/Plugins/WebPluginInfoProvider.h (229389 => 229390)


--- trunk/Source/WebKit/WebProcess/Plugins/WebPluginInfoProvider.h	2018-03-08 01:33:08 UTC (rev 229389)
+++ trunk/Source/WebKit/WebProcess/Plugins/WebPluginInfoProvider.h	2018-03-08 02:06:39 UTC (rev 229390)
@@ -45,7 +45,7 @@
 private:
     WebPluginInfoProvider();
 
-    void getPluginInfo(WebCore::Page&, Vector<WebCore::PluginInfo>&, std::optional<WebCore::SupportedPluginNames>&) final;
+    void getPluginInfo(WebCore::Page&, Vector<WebCore::PluginInfo>&, std::optional<Vector<WebCore::SupportedPluginName>>&) final;
     void getWebVisiblePluginInfo(WebCore::Page&, Vector<WebCore::PluginInfo>&) final;
     void refreshPlugins() override;
 
@@ -68,7 +68,7 @@
     bool m_shouldRefreshPlugins { false };
     Vector<WebCore::PluginInfo> m_cachedPlugins;
     Vector<WebCore::PluginInfo> m_cachedApplicationPlugins;
-    std::optional<WebCore::SupportedPluginNames> m_cachedSupportedPluginNames;
+    std::optional<Vector<WebCore::SupportedPluginName>> m_cachedSupportedPluginNames;
 #endif
 };
 

Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (229389 => 229390)


--- trunk/Source/WebKitLegacy/mac/ChangeLog	2018-03-08 01:33:08 UTC (rev 229389)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog	2018-03-08 02:06:39 UTC (rev 229390)
@@ -1,3 +1,15 @@
+2018-03-07  Youenn Fablet  <you...@apple.com>
+
+        Match unsupported plugins based on domains and not origin
+        https://bugs.webkit.org/show_bug.cgi?id=183384
+
+        Reviewed by Chris Dumez.
+
+        * WebCoreSupport/WebPluginInfoProvider.h:
+        * WebCoreSupport/WebPluginInfoProvider.mm:
+        (WebPluginInfoProvider::getPluginInfo):
+        (WebPluginInfoProvider::getWebVisiblePluginInfo):
+
 2018-03-05  Andy Estes  <aes...@apple.com>
 
         [Mac] Teach WebCore::Pasteboard about file promise drags

Modified: trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebPluginInfoProvider.h (229389 => 229390)


--- trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebPluginInfoProvider.h	2018-03-08 01:33:08 UTC (rev 229389)
+++ trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebPluginInfoProvider.h	2018-03-08 02:06:39 UTC (rev 229390)
@@ -34,7 +34,7 @@
 
 private:
     void refreshPlugins() override;
-    void getPluginInfo(WebCore::Page&, Vector<WebCore::PluginInfo>&, std::optional<WebCore::SupportedPluginNames>&) final;
+    void getPluginInfo(WebCore::Page&, Vector<WebCore::PluginInfo>&, std::optional<Vector<WebCore::SupportedPluginName>>&) final;
     void getWebVisiblePluginInfo(WebCore::Page&, Vector<WebCore::PluginInfo>&) final;
 
     WebPluginInfoProvider();

Modified: trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebPluginInfoProvider.mm (229389 => 229390)


--- trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebPluginInfoProvider.mm	2018-03-08 01:33:08 UTC (rev 229389)
+++ trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebPluginInfoProvider.mm	2018-03-08 02:06:39 UTC (rev 229390)
@@ -55,7 +55,7 @@
     [[WebPluginDatabase sharedDatabaseIfExists] refresh];
 }
 
-void WebPluginInfoProvider::getPluginInfo(WebCore::Page& page, Vector<WebCore::PluginInfo>& plugins, std::optional<SupportedPluginNames>&)
+void WebPluginInfoProvider::getPluginInfo(WebCore::Page& page, Vector<WebCore::PluginInfo>& plugins, std::optional<Vector<SupportedPluginName>>&)
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
 
@@ -71,6 +71,6 @@
 
 void WebPluginInfoProvider::getWebVisiblePluginInfo(WebCore::Page& page, Vector<WebCore::PluginInfo>& plugins)
 {
-    std::optional<SupportedPluginNames> supportedPluginNames;
+    std::optional<Vector<SupportedPluginName>> supportedPluginNames;
     getPluginInfo(page, plugins, supportedPluginNames);
 }

Modified: trunk/Source/WebKitLegacy/win/WebCoreSupport/WebPluginInfoProvider.cpp (229389 => 229390)


--- trunk/Source/WebKitLegacy/win/WebCoreSupport/WebPluginInfoProvider.cpp	2018-03-08 01:33:08 UTC (rev 229389)
+++ trunk/Source/WebKitLegacy/win/WebCoreSupport/WebPluginInfoProvider.cpp	2018-03-08 02:06:39 UTC (rev 229390)
@@ -49,7 +49,7 @@
     PluginDatabase::installedPlugins()->refresh();
 }
 
-void WebPluginInfoProvider::getPluginInfo(WebCore::Page& page, Vector<WebCore::PluginInfo>& outPlugins, std::optional<WebCore::SupportedPluginNames>&)
+void WebPluginInfoProvider::getPluginInfo(WebCore::Page& page, Vector<WebCore::PluginInfo>& outPlugins, std::optional<Vector<WebCore::SupportedPluginName>>&)
 {
     const Vector<PluginPackage*>& plugins = PluginDatabase::installedPlugins()->plugins();
 
@@ -84,6 +84,6 @@
 
 void WebPluginInfoProvider::getWebVisiblePluginInfo(WebCore::Page& page, Vector<WebCore::PluginInfo>& plugins)
 {
-    std::optional<WebCore::SupportedPluginNames> supportedPluginNames;
+    std::optional<Vector<WebCore::SupportedPluginName>> supportedPluginNames;
     getPluginInfo(page, plugins, supportedPluginNames);
 }

Modified: trunk/Source/WebKitLegacy/win/WebCoreSupport/WebPluginInfoProvider.h (229389 => 229390)


--- trunk/Source/WebKitLegacy/win/WebCoreSupport/WebPluginInfoProvider.h	2018-03-08 01:33:08 UTC (rev 229389)
+++ trunk/Source/WebKitLegacy/win/WebCoreSupport/WebPluginInfoProvider.h	2018-03-08 02:06:39 UTC (rev 229390)
@@ -36,7 +36,7 @@
 
 private:
     void refreshPlugins() final;
-    void getPluginInfo(WebCore::Page&, Vector<WebCore::PluginInfo>&, std::optional<WebCore::SupportedPluginNames>&) final;
+    void getPluginInfo(WebCore::Page&, Vector<WebCore::PluginInfo>&, std::optional<Vector<WebCore::SupportedPluginName>>&) final;
     void getWebVisiblePluginInfo(WebCore::Page&, Vector<WebCore::PluginInfo>&) final;
 #if PLATFORM(MAC)
     void setPluginLoadClientPolicy(WebCore::PluginLoadClientPolicy, const String& host, const String& bundleIdentifier, const String& versionString) final;

Modified: trunk/Tools/ChangeLog (229389 => 229390)


--- trunk/Tools/ChangeLog	2018-03-08 01:33:08 UTC (rev 229389)
+++ trunk/Tools/ChangeLog	2018-03-08 02:06:39 UTC (rev 229390)
@@ -1,3 +1,16 @@
+2018-03-07  Youenn Fablet  <you...@apple.com>
+
+        Match unsupported plugins based on domains and not origin
+        https://bugs.webkit.org/show_bug.cgi?id=183384
+
+        Reviewed by Chris Dumez.
+
+        * TestWebKitAPI/Tests/WebCore/URL.cpp:
+        (TestWebKitAPI::TEST_F):
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::setPluginSupportedMode): Update to whitelist
+        localhost and not http://localhost:8080
+
 2018-03-07  Jonathan Bedard  <jbed...@apple.com>
 
         webkitpy: Allow apple_additions() to define additional ports

Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/URL.cpp (229389 => 229390)


--- trunk/Tools/TestWebKitAPI/Tests/WebCore/URL.cpp	2018-03-08 01:33:08 UTC (rev 229389)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/URL.cpp	2018-03-08 02:06:39 UTC (rev 229390)
@@ -264,4 +264,32 @@
     EXPECT_TRUE(URL::hostIsIPAddress("::123.45.67.89"));
 }
 
+TEST_F(URLTest, HostIsMatchingDomain)
+{
+    URL url = ""
+
+    EXPECT_TRUE(url.isMatchingDomain(String { }));
+    EXPECT_TRUE(url.isMatchingDomain(emptyString()));
+    EXPECT_TRUE(url.isMatchingDomain(ASCIILiteral("org")));
+    EXPECT_TRUE(url.isMatchingDomain(ASCIILiteral("webkit.org")));
+    EXPECT_TRUE(url.isMatchingDomain(ASCIILiteral("www.webkit.org")));
+
+    EXPECT_FALSE(url.isMatchingDomain(ASCIILiteral("rg")));
+    EXPECT_FALSE(url.isMatchingDomain(ASCIILiteral(".org")));
+    EXPECT_FALSE(url.isMatchingDomain(ASCIILiteral("ww.webkit.org")));
+    EXPECT_FALSE(url.isMatchingDomain(ASCIILiteral("http://www.webkit.org")));
+
+    url = ""
+
+    EXPECT_FALSE(url.isMatchingDomain(String { }));
+    EXPECT_FALSE(url.isMatchingDomain(emptyString()));
+    EXPECT_FALSE(url.isMatchingDomain(ASCIILiteral("org")));
+    EXPECT_FALSE(url.isMatchingDomain(ASCIILiteral("webkit.org")));
+    EXPECT_FALSE(url.isMatchingDomain(ASCIILiteral("www.webkit.org")));
+
+    URL emptyURL;
+    EXPECT_FALSE(emptyURL.isMatchingDomain(String { }));
+    EXPECT_FALSE(emptyURL.isMatchingDomain(emptyString()));
+}
+
 } // namespace TestWebKitAPI

Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (229389 => 229390)


--- trunk/Tools/WebKitTestRunner/TestController.cpp	2018-03-08 01:33:08 UTC (rev 229389)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp	2018-03-08 02:06:39 UTC (rev 229390)
@@ -1703,7 +1703,7 @@
 
     WKRetainPtr<WKMutableArrayRef> emptyArray = adoptWK(WKMutableArrayCreate());
     WKRetainPtr<WKStringRef> allOrigins = adoptWK(WKStringCreateWithUTF8CString(""));
-    WKRetainPtr<WKStringRef> specificOrigin = adoptWK(WKStringCreateWithUTF8CString("http://localhost:8080"));
+    WKRetainPtr<WKStringRef> specificOrigin = adoptWK(WKStringCreateWithUTF8CString("localhost"));
 
     WKRetainPtr<WKStringRef> pdfName = adoptWK(WKStringCreateWithUTF8CString("My personal PDF"));
     WKContextAddSupportedPlugin(m_context.get(), allOrigins.get(), pdfName.get(), emptyArray.get(), emptyArray.get());
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to