<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[204281] trunk/Source/WebKit2</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/204281">204281</a></dd>
<dt>Author</dt> <dd>andersca@apple.com</dd>
<dt>Date</dt> <dd>2016-08-09 09:26:28 -0700 (Tue, 09 Aug 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Move plug-in code from WebPlatformStrategies to WebPluginInfoProvider
https://bugs.webkit.org/show_bug.cgi?id=160679

Reviewed by Alex Christensen.

* WebProcess/Plugins/WebPluginInfoProvider.cpp:
(WebKit::WebPluginInfoProvider::setPluginLoadClientPolicy):
(WebKit::WebPluginInfoProvider::clearPluginClientPolicies):
(WebKit::WebPluginInfoProvider::refreshPlugins):
(WebKit::WebPluginInfoProvider::getPluginInfo):
(WebKit::WebPluginInfoProvider::getWebVisiblePluginInfo):
(WebKit::WebPluginInfoProvider::populatePluginCache):
(WebKit::WebPluginInfoProvider::pluginLoadClientPolicyForHost):
(WebKit::WebPluginInfoProvider::longestMatchedWildcardHostForHost):
(WebKit::WebPluginInfoProvider::replaceHostWithMatchedWildcardHost):
* WebProcess/Plugins/WebPluginInfoProvider.h:
* WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
(WebKit::WebPlatformStrategies::createPluginStrategy):
(WebKit::WebPlatformStrategies::WebPlatformStrategies): Deleted.
(WebKit::WebPlatformStrategies::refreshPlugins): Deleted.
(WebKit::WebPlatformStrategies::getPluginInfo): Deleted.
(WebKit::WebPlatformStrategies::getWebVisiblePluginInfo): Deleted.
(WebKit::WebPlatformStrategies::setPluginLoadClientPolicy): Deleted.
(WebKit::WebPlatformStrategies::clearPluginClientPolicies): Deleted.
(WebKit::WebPlatformStrategies::longestMatchedWildcardHostForHost): Deleted.
(WebKit::WebPlatformStrategies::replaceHostWithMatchedWildcardHost): Deleted.
(WebKit::WebPlatformStrategies::pluginLoadClientPolicyForHost): Deleted.
(WebKit::WebPlatformStrategies::populatePluginCache): Deleted.
* WebProcess/WebCoreSupport/WebPlatformStrategies.h:
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::initializeWebProcess):
(WebKit::WebProcess::setPluginLoadClientPolicy):
(WebKit::WebProcess::clearPluginClientPolicies):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2WebProcessPluginsWebPluginInfoProvidercpp">trunk/Source/WebKit2/WebProcess/Plugins/WebPluginInfoProvider.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessPluginsWebPluginInfoProviderh">trunk/Source/WebKit2/WebProcess/Plugins/WebPluginInfoProvider.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebCoreSupportWebPlatformStrategiescpp">trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebCoreSupportWebPlatformStrategiesh">trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebProcesscpp">trunk/Source/WebKit2/WebProcess/WebProcess.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (204280 => 204281)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2016-08-09 15:51:48 UTC (rev 204280)
+++ trunk/Source/WebKit2/ChangeLog        2016-08-09 16:26:28 UTC (rev 204281)
</span><span class="lines">@@ -1,5 +1,41 @@
</span><span class="cx"> 2016-08-08  Anders Carlsson  &lt;andersca@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Move plug-in code from WebPlatformStrategies to WebPluginInfoProvider
+        https://bugs.webkit.org/show_bug.cgi?id=160679
+
+        Reviewed by Alex Christensen.
+
+        * WebProcess/Plugins/WebPluginInfoProvider.cpp:
+        (WebKit::WebPluginInfoProvider::setPluginLoadClientPolicy):
+        (WebKit::WebPluginInfoProvider::clearPluginClientPolicies):
+        (WebKit::WebPluginInfoProvider::refreshPlugins):
+        (WebKit::WebPluginInfoProvider::getPluginInfo):
+        (WebKit::WebPluginInfoProvider::getWebVisiblePluginInfo):
+        (WebKit::WebPluginInfoProvider::populatePluginCache):
+        (WebKit::WebPluginInfoProvider::pluginLoadClientPolicyForHost):
+        (WebKit::WebPluginInfoProvider::longestMatchedWildcardHostForHost):
+        (WebKit::WebPluginInfoProvider::replaceHostWithMatchedWildcardHost):
+        * WebProcess/Plugins/WebPluginInfoProvider.h:
+        * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
+        (WebKit::WebPlatformStrategies::createPluginStrategy):
+        (WebKit::WebPlatformStrategies::WebPlatformStrategies): Deleted.
+        (WebKit::WebPlatformStrategies::refreshPlugins): Deleted.
+        (WebKit::WebPlatformStrategies::getPluginInfo): Deleted.
+        (WebKit::WebPlatformStrategies::getWebVisiblePluginInfo): Deleted.
+        (WebKit::WebPlatformStrategies::setPluginLoadClientPolicy): Deleted.
+        (WebKit::WebPlatformStrategies::clearPluginClientPolicies): Deleted.
+        (WebKit::WebPlatformStrategies::longestMatchedWildcardHostForHost): Deleted.
+        (WebKit::WebPlatformStrategies::replaceHostWithMatchedWildcardHost): Deleted.
+        (WebKit::WebPlatformStrategies::pluginLoadClientPolicyForHost): Deleted.
+        (WebKit::WebPlatformStrategies::populatePluginCache): Deleted.
+        * WebProcess/WebCoreSupport/WebPlatformStrategies.h:
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::initializeWebProcess):
+        (WebKit::WebProcess::setPluginLoadClientPolicy):
+        (WebKit::WebProcess::clearPluginClientPolicies):
+
+2016-08-08  Anders Carlsson  &lt;andersca@apple.com&gt;
+
</ins><span class="cx">         Add a new PluginInfoProvider class, to replace PluginStrategy
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=160670
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessPluginsWebPluginInfoProvidercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Plugins/WebPluginInfoProvider.cpp (204280 => 204281)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Plugins/WebPluginInfoProvider.cpp        2016-08-09 15:51:48 UTC (rev 204280)
+++ trunk/Source/WebKit2/WebProcess/Plugins/WebPluginInfoProvider.cpp        2016-08-09 16:26:28 UTC (rev 204281)
</span><span class="lines">@@ -26,10 +26,22 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;WebPluginInfoProvider.h&quot;
</span><span class="cx"> 
</span><del>-// FIXME: We shouldn't call out to the platform strategy for this.
-#include &quot;WebPlatformStrategies.h&quot;
-#include &lt;WebCore/PluginStrategy.h&gt;
</del><ins>+#include &quot;HangDetectionDisabler.h&quot;
+#include &quot;WebCoreArgumentCoders.h&quot;
+#include &quot;WebProcess.h&quot;
+#include &quot;WebProcessProxyMessages.h&quot;
+#include &lt;WebCore/Document.h&gt;
+#include &lt;WebCore/DocumentLoader.h&gt;
+#include &lt;WebCore/MainFrame.h&gt;
+#include &lt;WebCore/Page.h&gt;
+#include &lt;WebCore/SecurityOrigin.h&gt;
+#include &lt;WebCore/SubframeLoader.h&gt;
+#include &lt;wtf/text/StringHash.h&gt;
</ins><span class="cx"> 
</span><ins>+#if PLATFORM(MAC)
+#include &quot;StringUtilities.h&quot;
+#endif
+
</ins><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><span class="cx"> WebPluginInfoProvider&amp; WebPluginInfoProvider::singleton()
</span><span class="lines">@@ -47,31 +59,191 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if PLATFORM(MAC)
+void WebPluginInfoProvider::setPluginLoadClientPolicy(WebCore::PluginLoadClientPolicy clientPolicy, const String&amp; host, const String&amp; bundleIdentifier, const String&amp; versionString)
+{
+    String hostToSet = host.isNull() || !host.length() ? &quot;*&quot; : host;
+    String bundleIdentifierToSet = bundleIdentifier.isNull() || !bundleIdentifier.length() ? &quot;*&quot; : bundleIdentifier;
+    String versionStringToSet = versionString.isNull() || !versionString.length() ? &quot;*&quot; : versionString;
+
+    PluginPolicyMapsByIdentifier policiesByIdentifier;
+    if (m_hostsToPluginIdentifierData.contains(hostToSet))
+        policiesByIdentifier = m_hostsToPluginIdentifierData.get(hostToSet);
+
+    PluginLoadClientPoliciesByBundleVersion versionsToPolicies;
+    if (policiesByIdentifier.contains(bundleIdentifierToSet))
+        versionsToPolicies = policiesByIdentifier.get(bundleIdentifierToSet);
+
+    versionsToPolicies.set(versionStringToSet, clientPolicy);
+    policiesByIdentifier.set(bundleIdentifierToSet, versionsToPolicies);
+    m_hostsToPluginIdentifierData.set(hostToSet, policiesByIdentifier);
+}
+
+void WebPluginInfoProvider::clearPluginClientPolicies()
+{
+    m_hostsToPluginIdentifierData.clear();
+}
+#endif
+
</ins><span class="cx"> void WebPluginInfoProvider::refreshPlugins()
</span><span class="cx"> {
</span><del>-    WebCore::platformStrategies()-&gt;pluginStrategy()-&gt;refreshPlugins();
</del><ins>+#if ENABLE(NETSCAPE_PLUGIN_API)
+    m_cachedPlugins.clear();
+    m_pluginCacheIsPopulated = false;
+    m_shouldRefreshPlugins = true;
+#endif
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPluginInfoProvider::getPluginInfo(WebCore::Page&amp; page, Vector&lt;WebCore::PluginInfo&gt;&amp; plugins)
</span><span class="cx"> {
</span><del>-    WebCore::platformStrategies()-&gt;pluginStrategy()-&gt;getPluginInfo(&amp;page, plugins);
</del><ins>+#if ENABLE(NETSCAPE_PLUGIN_API)
+    populatePluginCache(page);
+
+    if (page.mainFrame().loader().subframeLoader().allowPlugins()) {
+        plugins = m_cachedPlugins;
+        return;
+    }
+
+    plugins = m_cachedApplicationPlugins;
+#else
+    UNUSED_PARAM(page);
+    UNUSED_PARAM(plugins);
+#endif // ENABLE(NETSCAPE_PLUGIN_API)
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPluginInfoProvider::getWebVisiblePluginInfo(WebCore::Page&amp; page, Vector&lt;WebCore::PluginInfo&gt;&amp; plugins)
</span><span class="cx"> {
</span><del>-    WebCore::platformStrategies()-&gt;pluginStrategy()-&gt;getWebVisiblePluginInfo(&amp;page, plugins);
</del><ins>+    ASSERT_ARG(plugins, plugins.isEmpty());
+
+    getPluginInfo(page, plugins);
+
+#if PLATFORM(MAC)
+    if (auto* document = page.mainFrame().document()) {
+        if (auto* securityOrigin = document-&gt;securityOrigin()) {
+            if (securityOrigin-&gt;isLocal())
+                return;
+        }
+    }
+
+    for (int32_t i = plugins.size() - 1; i &gt;= 0; --i) {
+        auto&amp; info = plugins.at(i);
+
+        // Allow built-in plugins. Also tentatively allow plugins that the client might later selectively permit.
+        if (info.isApplicationPlugin || info.clientLoadPolicy == WebCore::PluginLoadClientPolicyAsk)
+            continue;
+
+        if (info.clientLoadPolicy == WebCore::PluginLoadClientPolicyBlock)
+            plugins.remove(i);
+    }
+#endif
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if ENABLE(NETSCAPE_PLUGIN_API)
+void WebPluginInfoProvider::populatePluginCache(const WebCore::Page&amp; page)
+{
+    if (!m_pluginCacheIsPopulated) {
+        HangDetectionDisabler hangDetectionDisabler;
+
+        if (!WebProcess::singleton().parentProcessConnection()-&gt;sendSync(Messages::WebProcessProxy::GetPlugins(m_shouldRefreshPlugins), Messages::WebProcessProxy::GetPlugins::Reply(m_cachedPlugins, m_cachedApplicationPlugins), 0))
+            return;
+
+        m_shouldRefreshPlugins = false;
+        m_pluginCacheIsPopulated = true;
+    }
+
</ins><span class="cx"> #if PLATFORM(MAC)
</span><del>-void WebPluginInfoProvider::setPluginLoadClientPolicy(WebCore::PluginLoadClientPolicy pluginLoadClientPolicy, const String&amp; host, const String&amp; bundleIdentifier, const String&amp; versionString)
</del><ins>+    String pageHost = page.mainFrame().loader().documentLoader()-&gt;responseURL().host();
+    for (auto&amp; info : m_cachedPlugins) {
+        if (auto clientPolicy = pluginLoadClientPolicyForHost(pageHost, info))
+            info.clientLoadPolicy = *clientPolicy;
+    }
+#else
+    UNUSED_PARAM(page);
+#endif // not PLATFORM(MAC)
+}
+#endif
+
+#if PLATFORM(MAC)
+Optional&lt;WebCore::PluginLoadClientPolicy&gt; WebPluginInfoProvider::pluginLoadClientPolicyForHost(const String&amp; host, const WebCore::PluginInfo&amp; info) const
</ins><span class="cx"> {
</span><del>-    WebCore::platformStrategies()-&gt;pluginStrategy()-&gt;setPluginLoadClientPolicy(pluginLoadClientPolicy, host, bundleIdentifier, versionString);
</del><ins>+    String hostToLookUp = host;
+    String identifier = info.bundleIdentifier;
+
+    auto policiesByIdentifierIterator = m_hostsToPluginIdentifierData.find(hostToLookUp);
+
+    if (!identifier.isNull() &amp;&amp; policiesByIdentifierIterator == m_hostsToPluginIdentifierData.end()) {
+        if (!replaceHostWithMatchedWildcardHost(hostToLookUp, identifier))
+            hostToLookUp = &quot;*&quot;;
+        policiesByIdentifierIterator = m_hostsToPluginIdentifierData.find(hostToLookUp);
+        if (hostToLookUp != &quot;*&quot; &amp;&amp; policiesByIdentifierIterator == m_hostsToPluginIdentifierData.end()) {
+            hostToLookUp = &quot;*&quot;;
+            policiesByIdentifierIterator = m_hostsToPluginIdentifierData.find(hostToLookUp);
+        }
+    }
+    if (policiesByIdentifierIterator == m_hostsToPluginIdentifierData.end())
+        return Nullopt;
+
+    auto&amp; policiesByIdentifier = policiesByIdentifierIterator-&gt;value;
+
+    if (!identifier)
+        identifier = &quot;*&quot;;
+
+    auto identifierPolicyIterator = policiesByIdentifier.find(identifier);
+    if (identifier != &quot;*&quot; &amp;&amp; identifierPolicyIterator == policiesByIdentifier.end()) {
+        identifier = &quot;*&quot;;
+        identifierPolicyIterator = policiesByIdentifier.find(identifier);
+    }
+
+    if (identifierPolicyIterator == policiesByIdentifier.end())
+        return Nullopt;
+
+    auto&amp; versionsToPolicies = identifierPolicyIterator-&gt;value;
+
+    String version = info.versionString;
+    if (!version)
+        version = &quot;*&quot;;
+    auto policyIterator = versionsToPolicies.find(version);
+    if (version != &quot;*&quot; &amp;&amp; policyIterator == versionsToPolicies.end()) {
+        version = &quot;*&quot;;
+        policyIterator = versionsToPolicies.find(version);
+    }
+
+    if (policyIterator == versionsToPolicies.end())
+        return Nullopt;
+
+    return policyIterator-&gt;value;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPluginInfoProvider::clearPluginClientPolicies()
</del><ins>+String WebPluginInfoProvider::longestMatchedWildcardHostForHost(const String&amp; host) const
</ins><span class="cx"> {
</span><del>-    WebCore::platformStrategies()-&gt;pluginStrategy()-&gt;clearPluginClientPolicies();
</del><ins>+    String longestMatchedHost;
+
+    for (auto&amp; key : m_hostsToPluginIdentifierData.keys()) {
+        if (key.contains('*') &amp;&amp; key != &quot;*&quot; &amp;&amp; stringMatchesWildcardString(host, key)) {
+            if (key.length() &gt; longestMatchedHost.length())
+                longestMatchedHost = key;
+            else if (key.length() == longestMatchedHost.length() &amp;&amp; codePointCompareLessThan(key, longestMatchedHost))
+                longestMatchedHost = key;
+        }
+    }
+
+    return longestMatchedHost;
</ins><span class="cx"> }
</span><ins>+
+bool WebPluginInfoProvider::replaceHostWithMatchedWildcardHost(String&amp; host, const String&amp; identifier) const
+{
+    String matchedWildcardHost = longestMatchedWildcardHostForHost(host);
+
+    if (matchedWildcardHost.isNull())
+        return false;
+
+    auto plugInIdentifierData = m_hostsToPluginIdentifierData.find(matchedWildcardHost);
+    if (plugInIdentifierData == m_hostsToPluginIdentifierData.end() || !plugInIdentifierData-&gt;value.contains(identifier))
+        return false;
+
+    host = matchedWildcardHost;
+    return true;
+}
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessPluginsWebPluginInfoProviderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Plugins/WebPluginInfoProvider.h (204280 => 204281)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Plugins/WebPluginInfoProvider.h        2016-08-09 15:51:48 UTC (rev 204280)
+++ trunk/Source/WebKit2/WebProcess/Plugins/WebPluginInfoProvider.h        2016-08-09 16:26:28 UTC (rev 204281)
</span><span class="lines">@@ -26,6 +26,7 @@
</span><span class="cx"> #pragma once
</span><span class="cx"> 
</span><span class="cx"> #include &lt;WebCore/PluginInfoProvider.h&gt;
</span><ins>+#include &lt;wtf/HashMap.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><span class="lines">@@ -36,16 +37,38 @@
</span><span class="cx">     static WebPluginInfoProvider&amp; singleton();
</span><span class="cx">     virtual ~WebPluginInfoProvider();
</span><span class="cx"> 
</span><ins>+#if PLATFORM(MAC)
+    void setPluginLoadClientPolicy(WebCore::PluginLoadClientPolicy, const String&amp; host, const String&amp; bundleIdentifier, const String&amp; versionString) override;
+    void clearPluginClientPolicies() override;
+#endif
+
</ins><span class="cx"> private:
</span><ins>+    WebPluginInfoProvider();
+
</ins><span class="cx">     void refreshPlugins() override;
</span><span class="cx">     void getPluginInfo(WebCore::Page&amp;, Vector&lt;WebCore::PluginInfo&gt;&amp;) override;
</span><span class="cx">     void getWebVisiblePluginInfo(WebCore::Page&amp;, Vector&lt;WebCore::PluginInfo&gt;&amp;) override;
</span><ins>+
+#if ENABLE(NETSCAPE_PLUGIN_API)
+    void populatePluginCache(const WebCore::Page&amp;);
+#endif // ENABLE(NETSCAPE_PLUGIN_API)
+
</ins><span class="cx"> #if PLATFORM(MAC)
</span><del>-    void setPluginLoadClientPolicy(WebCore::PluginLoadClientPolicy, const String&amp; host, const String&amp; bundleIdentifier, const String&amp; versionString) override;
-    void clearPluginClientPolicies() override;
</del><ins>+    Optional&lt;WebCore::PluginLoadClientPolicy&gt; pluginLoadClientPolicyForHost(const String&amp;, const WebCore::PluginInfo&amp;) const;
+    String longestMatchedWildcardHostForHost(const String&amp; host) const;
+    bool replaceHostWithMatchedWildcardHost(String&amp; host, const String&amp; identifier) const;
+
+    typedef HashMap&lt;String, WebCore::PluginLoadClientPolicy&gt; PluginLoadClientPoliciesByBundleVersion;
+    typedef HashMap&lt;String, PluginLoadClientPoliciesByBundleVersion&gt; PluginPolicyMapsByIdentifier;
+    HashMap&lt;String, PluginPolicyMapsByIdentifier&gt; m_hostsToPluginIdentifierData;
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    WebPluginInfoProvider();
</del><ins>+#if ENABLE(NETSCAPE_PLUGIN_API)
+    bool m_pluginCacheIsPopulated { false };
+    bool m_shouldRefreshPlugins { false };
+    Vector&lt;WebCore::PluginInfo&gt; m_cachedPlugins;
+    Vector&lt;WebCore::PluginInfo&gt; m_cachedApplicationPlugins;
+#endif
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebCoreSupportWebPlatformStrategiescpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp (204280 => 204281)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp        2016-08-09 15:51:48 UTC (rev 204280)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp        2016-08-09 16:26:28 UTC (rev 204281)
</span><span class="lines">@@ -80,10 +80,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> WebPlatformStrategies::WebPlatformStrategies()
</span><del>-#if ENABLE(NETSCAPE_PLUGIN_API)
-    : m_pluginCacheIsPopulated(false)
-    , m_shouldRefreshPlugins(false)
-#endif // ENABLE(NETSCAPE_PLUGIN_API)
</del><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -104,7 +100,7 @@
</span><span class="cx"> 
</span><span class="cx"> PluginStrategy* WebPlatformStrategies::createPluginStrategy()
</span><span class="cx"> {
</span><del>-    return this;
</del><ins>+    return nullptr;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> BlobRegistry* WebPlatformStrategies::createBlobRegistry()
</span><span class="lines">@@ -165,200 +161,6 @@
</span><span class="cx">     WebProcess::singleton().networkConnection().connection().send(Messages::NetworkConnectionToWebProcess::AddCookie(SessionTracker::sessionID(session), url, cookie), 0);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-// PluginStrategy
-
-void WebPlatformStrategies::refreshPlugins()
-{
-#if ENABLE(NETSCAPE_PLUGIN_API)
-    m_cachedPlugins.clear();
-    m_pluginCacheIsPopulated = false;
-    m_shouldRefreshPlugins = true;
-#endif // ENABLE(NETSCAPE_PLUGIN_API)
-}
-
-void WebPlatformStrategies::getPluginInfo(const WebCore::Page* page, Vector&lt;WebCore::PluginInfo&gt;&amp; plugins)
-{
-#if ENABLE(NETSCAPE_PLUGIN_API)
-    ASSERT_ARG(page, page);
-    populatePluginCache(*page);
-
-    if (page-&gt;mainFrame().loader().subframeLoader().allowPlugins()) {
-        plugins = m_cachedPlugins;
-        return;
-    }
-
-    plugins = m_cachedApplicationPlugins;
-#else
-    UNUSED_PARAM(page);
-    UNUSED_PARAM(plugins);
-#endif // ENABLE(NETSCAPE_PLUGIN_API)
-}
-
-void WebPlatformStrategies::getWebVisiblePluginInfo(const Page* page, Vector&lt;PluginInfo&gt;&amp; plugins)
-{
-    ASSERT_ARG(page, page);
-    ASSERT_ARG(plugins, plugins.isEmpty());
-
-    getPluginInfo(page, plugins);
-
-#if PLATFORM(MAC)
-    if (Document* document = page-&gt;mainFrame().document()) {
-        if (SecurityOrigin* securityOrigin = document-&gt;securityOrigin()) {
-            if (securityOrigin-&gt;isLocal())
-                return;
-        }
-    }
-    
-    for (int32_t i = plugins.size() - 1; i &gt;= 0; --i) {
-        PluginInfo&amp; info = plugins.at(i);
-        PluginLoadClientPolicy clientPolicy = info.clientLoadPolicy;
-        // Allow built-in plugins. Also tentatively allow plugins that the client might later selectively permit.
-        if (info.isApplicationPlugin || clientPolicy == PluginLoadClientPolicyAsk)
-            continue;
-
-        if (clientPolicy == PluginLoadClientPolicyBlock)
-            plugins.remove(i);
-    }
-#endif
-}
-
-#if PLATFORM(MAC)
-void WebPlatformStrategies::setPluginLoadClientPolicy(PluginLoadClientPolicy clientPolicy, const String&amp; host, const String&amp; bundleIdentifier, const String&amp; versionString)
-{
-    String hostToSet = host.isNull() || !host.length() ? &quot;*&quot; : host;
-    String bundleIdentifierToSet = bundleIdentifier.isNull() || !bundleIdentifier.length() ? &quot;*&quot; : bundleIdentifier;
-    String versionStringToSet = versionString.isNull() || !versionString.length() ? &quot;*&quot; : versionString;
-
-    PluginPolicyMapsByIdentifier policiesByIdentifier;
-    if (m_hostsToPluginIdentifierData.contains(hostToSet))
-        policiesByIdentifier = m_hostsToPluginIdentifierData.get(hostToSet);
-
-    PluginLoadClientPoliciesByBundleVersion versionsToPolicies;
-    if (policiesByIdentifier.contains(bundleIdentifierToSet))
-        versionsToPolicies = policiesByIdentifier.get(bundleIdentifierToSet);
-
-    versionsToPolicies.set(versionStringToSet, clientPolicy);
-    policiesByIdentifier.set(bundleIdentifierToSet, versionsToPolicies);
-    m_hostsToPluginIdentifierData.set(hostToSet, policiesByIdentifier);
-}
-
-void WebPlatformStrategies::clearPluginClientPolicies()
-{
-    m_hostsToPluginIdentifierData.clear();
-}
-
-#endif
-
-#if ENABLE(NETSCAPE_PLUGIN_API)
-#if PLATFORM(MAC)
-
-String WebPlatformStrategies::longestMatchedWildcardHostForHost(const String&amp; host) const
-{
-    String longestMatchedHost;
-
-    for (auto&amp; key : m_hostsToPluginIdentifierData.keys()) {
-        if (key.contains('*') &amp;&amp; key != &quot;*&quot; &amp;&amp; stringMatchesWildcardString(host, key)) {
-            if (key.length() &gt; longestMatchedHost.length())
-                longestMatchedHost = key;
-            else if (key.length() == longestMatchedHost.length() &amp;&amp; codePointCompareLessThan(key, longestMatchedHost))
-                longestMatchedHost = key;
-        }
-    }
-
-    return longestMatchedHost;
-}
-
-bool WebPlatformStrategies::replaceHostWithMatchedWildcardHost(String&amp; host, const String&amp; identifier) const
-{
-    String matchedWildcardHost = longestMatchedWildcardHostForHost(host);
-
-    if (matchedWildcardHost.isNull())
-        return false;
-
-    auto plugInIdentifierData = m_hostsToPluginIdentifierData.find(matchedWildcardHost);
-    if (plugInIdentifierData == m_hostsToPluginIdentifierData.end() || !plugInIdentifierData-&gt;value.contains(identifier))
-        return false;
-
-    host = matchedWildcardHost;
-    return true;
-}
-
-bool WebPlatformStrategies::pluginLoadClientPolicyForHost(const String&amp; host, const PluginInfo&amp; info, PluginLoadClientPolicy&amp; policy) const
-{
-    String hostToLookUp = host;
-    String identifier = info.bundleIdentifier;
-
-    auto policiesByIdentifierIterator = m_hostsToPluginIdentifierData.find(hostToLookUp);
-
-    if (!identifier.isNull() &amp;&amp; policiesByIdentifierIterator == m_hostsToPluginIdentifierData.end()) {
-        if (!replaceHostWithMatchedWildcardHost(hostToLookUp, identifier))
-            hostToLookUp = &quot;*&quot;;
-        policiesByIdentifierIterator = m_hostsToPluginIdentifierData.find(hostToLookUp);
-        if (hostToLookUp != &quot;*&quot; &amp;&amp; policiesByIdentifierIterator == m_hostsToPluginIdentifierData.end()) {
-            hostToLookUp = &quot;*&quot;;
-            policiesByIdentifierIterator = m_hostsToPluginIdentifierData.find(hostToLookUp);
-        }
-    }
-    if (policiesByIdentifierIterator == m_hostsToPluginIdentifierData.end())
-        return false;
-
-    auto&amp; policiesByIdentifier = policiesByIdentifierIterator-&gt;value;
-
-    if (!identifier)
-        identifier = &quot;*&quot;;
-
-    auto identifierPolicyIterator = policiesByIdentifier.find(identifier);
-    if (identifier != &quot;*&quot; &amp;&amp; identifierPolicyIterator == policiesByIdentifier.end()) {
-        identifier = &quot;*&quot;;
-        identifierPolicyIterator = policiesByIdentifier.find(identifier);
-    }
-    if (identifierPolicyIterator == policiesByIdentifier.end())
-        return false;
-
-    auto&amp; versionsToPolicies = identifierPolicyIterator-&gt;value;
-
-    String version = info.versionString;
-    if (!version)
-        version = &quot;*&quot;;
-    auto policyIterator = versionsToPolicies.find(version);
-    if (version != &quot;*&quot; &amp;&amp; policyIterator == versionsToPolicies.end()) {
-        version = &quot;*&quot;;
-        policyIterator = versionsToPolicies.find(version);
-    }
-
-    if (policyIterator == versionsToPolicies.end())
-        return false;
-
-    policy = policyIterator-&gt;value;
-    return true;
-}
-#endif // PLATFORM(MAC)
-
-void WebPlatformStrategies::populatePluginCache(const WebCore::Page&amp; page)
-{
-    if (!m_pluginCacheIsPopulated) {
-        HangDetectionDisabler hangDetectionDisabler;
-
-        if (!WebProcess::singleton().parentProcessConnection()-&gt;sendSync(Messages::WebProcessProxy::GetPlugins(m_shouldRefreshPlugins), Messages::WebProcessProxy::GetPlugins::Reply(m_cachedPlugins, m_cachedApplicationPlugins), 0))
-            return;
-
-        m_shouldRefreshPlugins = false;
-        m_pluginCacheIsPopulated = true;
-    }
-
-#if PLATFORM(MAC)
-    String pageHost = page.mainFrame().loader().documentLoader()-&gt;responseURL().host();
-    for (PluginInfo&amp; info : m_cachedPlugins) {
-        PluginLoadClientPolicy clientPolicy;
-        if (pluginLoadClientPolicyForHost(pageHost, info, clientPolicy))
-            info.clientLoadPolicy = clientPolicy;
-    }
-#else
-    UNUSED_PARAM(page);
-#endif // not PLATFORM(MAC)
-}
-#endif // ENABLE(NETSCAPE_PLUGIN_API)
-
</del><span class="cx"> #if PLATFORM(COCOA)
</span><span class="cx"> // PasteboardStrategy
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebCoreSupportWebPlatformStrategiesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h (204280 => 204281)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h        2016-08-09 15:51:48 UTC (rev 204280)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h        2016-08-09 16:26:28 UTC (rev 204281)
</span><span class="lines">@@ -30,13 +30,12 @@
</span><span class="cx"> #include &lt;WebCore/LoaderStrategy.h&gt;
</span><span class="cx"> #include &lt;WebCore/PasteboardStrategy.h&gt;
</span><span class="cx"> #include &lt;WebCore/PlatformStrategies.h&gt;
</span><del>-#include &lt;WebCore/PluginStrategy.h&gt;
</del><span class="cx"> #include &lt;wtf/HashMap.h&gt;
</span><span class="cx"> #include &lt;wtf/NeverDestroyed.h&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><del>-class WebPlatformStrategies : public WebCore::PlatformStrategies, private WebCore::CookiesStrategy, private WebCore::PasteboardStrategy, private WebCore::PluginStrategy {
</del><ins>+class WebPlatformStrategies : public WebCore::PlatformStrategies, private WebCore::CookiesStrategy, private WebCore::PasteboardStrategy {
</ins><span class="cx">     friend class NeverDestroyed&lt;WebPlatformStrategies&gt;;
</span><span class="cx"> public:
</span><span class="cx">     static void initialize();
</span><span class="lines">@@ -61,19 +60,6 @@
</span><span class="cx">     void deleteCookie(const WebCore::NetworkStorageSession&amp;, const WebCore::URL&amp;, const String&amp;) override;
</span><span class="cx">     void addCookie(const WebCore::NetworkStorageSession&amp;, const WebCore::URL&amp;, const WebCore::Cookie&amp;) override;
</span><span class="cx"> 
</span><del>-    // WebCore::PluginStrategy
-    void refreshPlugins() override;
-    void getPluginInfo(const WebCore::Page*, Vector&lt;WebCore::PluginInfo&gt;&amp;) override;
-    void getWebVisiblePluginInfo(const WebCore::Page*, Vector&lt;WebCore::PluginInfo&gt;&amp;) override;
-
-#if PLATFORM(MAC)
-    typedef HashMap&lt;String, WebCore::PluginLoadClientPolicy&gt; PluginLoadClientPoliciesByBundleVersion;
-    typedef HashMap&lt;String, PluginLoadClientPoliciesByBundleVersion&gt; PluginPolicyMapsByIdentifier;
-
-    void setPluginLoadClientPolicy(WebCore::PluginLoadClientPolicy, const String&amp; host, const String&amp; bundleIdentifier, const String&amp; versionString) override;
-    void clearPluginClientPolicies() override;
-#endif
-
</del><span class="cx">     // WebCore::PasteboardStrategy
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     void writeToPasteboard(const WebCore::PasteboardWebContent&amp;) override;
</span><span class="lines">@@ -103,27 +89,8 @@
</span><span class="cx">     long setStringForType(const String&amp;, const String&amp; pasteboardType, const String&amp; pasteboardName) override;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-#if ENABLE(NETSCAPE_PLUGIN_API)
-    // WebCore::PluginStrategy implementation.
-    void populatePluginCache(const WebCore::Page&amp;);
-    bool m_pluginCacheIsPopulated;
-    bool m_shouldRefreshPlugins;
-    Vector&lt;WebCore::PluginInfo&gt; m_cachedPlugins;
-    Vector&lt;WebCore::PluginInfo&gt; m_cachedApplicationPlugins;
-
-#if PLATFORM(MAC)
-    HashMap&lt;String, PluginPolicyMapsByIdentifier&gt; m_hostsToPluginIdentifierData;
-    bool pluginLoadClientPolicyForHost(const String&amp;, const WebCore::PluginInfo&amp;, WebCore::PluginLoadClientPolicy&amp;) const;
-    String longestMatchedWildcardHostForHost(const String&amp; host) const;
-    bool replaceHostWithMatchedWildcardHost(String&amp; host, const String&amp; identifier) const;
-#endif // PLATFORM(MAC)
-#endif // ENABLE(NETSCAPE_PLUGIN_API)
</del><span class="cx"> };
</span><span class="cx"> 
</span><del>-#if ENABLE(NETSCAPE_PLUGIN_API)
-void handleDidGetPlugins(uint64_t requestID, const Vector&lt;WebCore::PluginInfo&gt;&amp;, const Vector&lt;WebCore::PluginInfo&gt;&amp; applicationPlugins);
-#endif // ENABLE(NETSCAPE_PLUGIN_API)
-
</del><span class="cx"> } // namespace WebKit
</span><span class="cx"> 
</span><span class="cx"> #endif // WebPlatformStrategies_h
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebProcesscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebProcess.cpp (204280 => 204281)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebProcess.cpp        2016-08-09 15:51:48 UTC (rev 204280)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.cpp        2016-08-09 16:26:28 UTC (rev 204281)
</span><span class="lines">@@ -56,6 +56,7 @@
</span><span class="cx"> #include &quot;WebPage.h&quot;
</span><span class="cx"> #include &quot;WebPageGroupProxy.h&quot;
</span><span class="cx"> #include &quot;WebPlatformStrategies.h&quot;
</span><ins>+#include &quot;WebPluginInfoProvider.h&quot;
</ins><span class="cx"> #include &quot;WebProcessCreationParameters.h&quot;
</span><span class="cx"> #include &quot;WebProcessMessages.h&quot;
</span><span class="cx"> #include &quot;WebProcessPoolMessages.h&quot;
</span><span class="lines">@@ -397,7 +398,7 @@
</span><span class="cx">     for (auto hostIter = parameters.pluginLoadClientPolicies.begin(); hostIter != parameters.pluginLoadClientPolicies.end(); ++hostIter) {
</span><span class="cx">         for (auto bundleIdentifierIter = hostIter-&gt;value.begin(); bundleIdentifierIter != hostIter-&gt;value.end(); ++bundleIdentifierIter) {
</span><span class="cx">             for (auto versionIter = bundleIdentifierIter-&gt;value.begin(); versionIter != bundleIdentifierIter-&gt;value.end(); ++versionIter)
</span><del>-                platformStrategies()-&gt;pluginStrategy()-&gt;setPluginLoadClientPolicy(static_cast&lt;PluginLoadClientPolicy&gt;(versionIter-&gt;value), hostIter-&gt;key, bundleIdentifierIter-&gt;key, versionIter-&gt;key);
</del><ins>+                WebPluginInfoProvider::singleton().setPluginLoadClientPolicy(static_cast&lt;PluginLoadClientPolicy&gt;(versionIter-&gt;value), hostIter-&gt;key, bundleIdentifierIter-&gt;key, versionIter-&gt;key);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> #endif
</span><span class="lines">@@ -915,7 +916,7 @@
</span><span class="cx"> void WebProcess::setPluginLoadClientPolicy(uint8_t policy, const String&amp; host, const String&amp; bundleIdentifier, const String&amp; versionString)
</span><span class="cx"> {
</span><span class="cx"> #if ENABLE(NETSCAPE_PLUGIN_API) &amp;&amp; PLATFORM(MAC)
</span><del>-    platformStrategies()-&gt;pluginStrategy()-&gt;setPluginLoadClientPolicy(static_cast&lt;PluginLoadClientPolicy&gt;(policy), host, bundleIdentifier, versionString);
</del><ins>+    WebPluginInfoProvider::singleton().setPluginLoadClientPolicy(static_cast&lt;PluginLoadClientPolicy&gt;(policy), host, bundleIdentifier, versionString);
</ins><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -922,7 +923,7 @@
</span><span class="cx"> void WebProcess::clearPluginClientPolicies()
</span><span class="cx"> {
</span><span class="cx"> #if ENABLE(NETSCAPE_PLUGIN_API) &amp;&amp; PLATFORM(MAC)
</span><del>-    platformStrategies()-&gt;pluginStrategy()-&gt;clearPluginClientPolicies();
</del><ins>+    WebPluginInfoProvider::singleton().clearPluginClientPolicies();
</ins><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>