<!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 <andersca@apple.com>
</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 <andersca@apple.com>
+
</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 "config.h"
</span><span class="cx"> #include "WebPluginInfoProvider.h"
</span><span class="cx">
</span><del>-// FIXME: We shouldn't call out to the platform strategy for this.
-#include "WebPlatformStrategies.h"
-#include <WebCore/PluginStrategy.h>
</del><ins>+#include "HangDetectionDisabler.h"
+#include "WebCoreArgumentCoders.h"
+#include "WebProcess.h"
+#include "WebProcessProxyMessages.h"
+#include <WebCore/Document.h>
+#include <WebCore/DocumentLoader.h>
+#include <WebCore/MainFrame.h>
+#include <WebCore/Page.h>
+#include <WebCore/SecurityOrigin.h>
+#include <WebCore/SubframeLoader.h>
+#include <wtf/text/StringHash.h>
</ins><span class="cx">
</span><ins>+#if PLATFORM(MAC)
+#include "StringUtilities.h"
+#endif
+
</ins><span class="cx"> namespace WebKit {
</span><span class="cx">
</span><span class="cx"> WebPluginInfoProvider& 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& host, const String& bundleIdentifier, const String& versionString)
+{
+ String hostToSet = host.isNull() || !host.length() ? "*" : host;
+ String bundleIdentifierToSet = bundleIdentifier.isNull() || !bundleIdentifier.length() ? "*" : bundleIdentifier;
+ String versionStringToSet = versionString.isNull() || !versionString.length() ? "*" : 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()->pluginStrategy()->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& page, Vector<WebCore::PluginInfo>& plugins)
</span><span class="cx"> {
</span><del>- WebCore::platformStrategies()->pluginStrategy()->getPluginInfo(&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& page, Vector<WebCore::PluginInfo>& plugins)
</span><span class="cx"> {
</span><del>- WebCore::platformStrategies()->pluginStrategy()->getWebVisiblePluginInfo(&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->securityOrigin()) {
+ if (securityOrigin->isLocal())
+ return;
+ }
+ }
+
+ for (int32_t i = plugins.size() - 1; i >= 0; --i) {
+ auto& 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& page)
+{
+ if (!m_pluginCacheIsPopulated) {
+ HangDetectionDisabler hangDetectionDisabler;
+
+ if (!WebProcess::singleton().parentProcessConnection()->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& host, const String& bundleIdentifier, const String& versionString)
</del><ins>+ String pageHost = page.mainFrame().loader().documentLoader()->responseURL().host();
+ for (auto& 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<WebCore::PluginLoadClientPolicy> WebPluginInfoProvider::pluginLoadClientPolicyForHost(const String& host, const WebCore::PluginInfo& info) const
</ins><span class="cx"> {
</span><del>- WebCore::platformStrategies()->pluginStrategy()->setPluginLoadClientPolicy(pluginLoadClientPolicy, host, bundleIdentifier, versionString);
</del><ins>+ String hostToLookUp = host;
+ String identifier = info.bundleIdentifier;
+
+ auto policiesByIdentifierIterator = m_hostsToPluginIdentifierData.find(hostToLookUp);
+
+ if (!identifier.isNull() && policiesByIdentifierIterator == m_hostsToPluginIdentifierData.end()) {
+ if (!replaceHostWithMatchedWildcardHost(hostToLookUp, identifier))
+ hostToLookUp = "*";
+ policiesByIdentifierIterator = m_hostsToPluginIdentifierData.find(hostToLookUp);
+ if (hostToLookUp != "*" && policiesByIdentifierIterator == m_hostsToPluginIdentifierData.end()) {
+ hostToLookUp = "*";
+ policiesByIdentifierIterator = m_hostsToPluginIdentifierData.find(hostToLookUp);
+ }
+ }
+ if (policiesByIdentifierIterator == m_hostsToPluginIdentifierData.end())
+ return Nullopt;
+
+ auto& policiesByIdentifier = policiesByIdentifierIterator->value;
+
+ if (!identifier)
+ identifier = "*";
+
+ auto identifierPolicyIterator = policiesByIdentifier.find(identifier);
+ if (identifier != "*" && identifierPolicyIterator == policiesByIdentifier.end()) {
+ identifier = "*";
+ identifierPolicyIterator = policiesByIdentifier.find(identifier);
+ }
+
+ if (identifierPolicyIterator == policiesByIdentifier.end())
+ return Nullopt;
+
+ auto& versionsToPolicies = identifierPolicyIterator->value;
+
+ String version = info.versionString;
+ if (!version)
+ version = "*";
+ auto policyIterator = versionsToPolicies.find(version);
+ if (version != "*" && policyIterator == versionsToPolicies.end()) {
+ version = "*";
+ policyIterator = versionsToPolicies.find(version);
+ }
+
+ if (policyIterator == versionsToPolicies.end())
+ return Nullopt;
+
+ return policyIterator->value;
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-void WebPluginInfoProvider::clearPluginClientPolicies()
</del><ins>+String WebPluginInfoProvider::longestMatchedWildcardHostForHost(const String& host) const
</ins><span class="cx"> {
</span><del>- WebCore::platformStrategies()->pluginStrategy()->clearPluginClientPolicies();
</del><ins>+ String longestMatchedHost;
+
+ for (auto& key : m_hostsToPluginIdentifierData.keys()) {
+ if (key.contains('*') && key != "*" && stringMatchesWildcardString(host, key)) {
+ if (key.length() > longestMatchedHost.length())
+ longestMatchedHost = key;
+ else if (key.length() == longestMatchedHost.length() && codePointCompareLessThan(key, longestMatchedHost))
+ longestMatchedHost = key;
+ }
+ }
+
+ return longestMatchedHost;
</ins><span class="cx"> }
</span><ins>+
+bool WebPluginInfoProvider::replaceHostWithMatchedWildcardHost(String& host, const String& identifier) const
+{
+ String matchedWildcardHost = longestMatchedWildcardHostForHost(host);
+
+ if (matchedWildcardHost.isNull())
+ return false;
+
+ auto plugInIdentifierData = m_hostsToPluginIdentifierData.find(matchedWildcardHost);
+ if (plugInIdentifierData == m_hostsToPluginIdentifierData.end() || !plugInIdentifierData->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 <WebCore/PluginInfoProvider.h>
</span><ins>+#include <wtf/HashMap.h>
</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& singleton();
</span><span class="cx"> virtual ~WebPluginInfoProvider();
</span><span class="cx">
</span><ins>+#if PLATFORM(MAC)
+ void setPluginLoadClientPolicy(WebCore::PluginLoadClientPolicy, const String& host, const String& bundleIdentifier, const String& 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&, Vector<WebCore::PluginInfo>&) override;
</span><span class="cx"> void getWebVisiblePluginInfo(WebCore::Page&, Vector<WebCore::PluginInfo>&) override;
</span><ins>+
+#if ENABLE(NETSCAPE_PLUGIN_API)
+ void populatePluginCache(const WebCore::Page&);
+#endif // ENABLE(NETSCAPE_PLUGIN_API)
+
</ins><span class="cx"> #if PLATFORM(MAC)
</span><del>- void setPluginLoadClientPolicy(WebCore::PluginLoadClientPolicy, const String& host, const String& bundleIdentifier, const String& versionString) override;
- void clearPluginClientPolicies() override;
</del><ins>+ Optional<WebCore::PluginLoadClientPolicy> pluginLoadClientPolicyForHost(const String&, const WebCore::PluginInfo&) const;
+ String longestMatchedWildcardHostForHost(const String& host) const;
+ bool replaceHostWithMatchedWildcardHost(String& host, const String& identifier) const;
+
+ typedef HashMap<String, WebCore::PluginLoadClientPolicy> PluginLoadClientPoliciesByBundleVersion;
+ typedef HashMap<String, PluginLoadClientPoliciesByBundleVersion> PluginPolicyMapsByIdentifier;
+ HashMap<String, PluginPolicyMapsByIdentifier> 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<WebCore::PluginInfo> m_cachedPlugins;
+ Vector<WebCore::PluginInfo> 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<WebCore::PluginInfo>& plugins)
-{
-#if ENABLE(NETSCAPE_PLUGIN_API)
- ASSERT_ARG(page, page);
- 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)
-}
-
-void WebPlatformStrategies::getWebVisiblePluginInfo(const Page* page, Vector<PluginInfo>& plugins)
-{
- ASSERT_ARG(page, page);
- ASSERT_ARG(plugins, plugins.isEmpty());
-
- getPluginInfo(page, plugins);
-
-#if PLATFORM(MAC)
- if (Document* document = page->mainFrame().document()) {
- if (SecurityOrigin* securityOrigin = document->securityOrigin()) {
- if (securityOrigin->isLocal())
- return;
- }
- }
-
- for (int32_t i = plugins.size() - 1; i >= 0; --i) {
- PluginInfo& 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& host, const String& bundleIdentifier, const String& versionString)
-{
- String hostToSet = host.isNull() || !host.length() ? "*" : host;
- String bundleIdentifierToSet = bundleIdentifier.isNull() || !bundleIdentifier.length() ? "*" : bundleIdentifier;
- String versionStringToSet = versionString.isNull() || !versionString.length() ? "*" : 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& host) const
-{
- String longestMatchedHost;
-
- for (auto& key : m_hostsToPluginIdentifierData.keys()) {
- if (key.contains('*') && key != "*" && stringMatchesWildcardString(host, key)) {
- if (key.length() > longestMatchedHost.length())
- longestMatchedHost = key;
- else if (key.length() == longestMatchedHost.length() && codePointCompareLessThan(key, longestMatchedHost))
- longestMatchedHost = key;
- }
- }
-
- return longestMatchedHost;
-}
-
-bool WebPlatformStrategies::replaceHostWithMatchedWildcardHost(String& host, const String& identifier) const
-{
- String matchedWildcardHost = longestMatchedWildcardHostForHost(host);
-
- if (matchedWildcardHost.isNull())
- return false;
-
- auto plugInIdentifierData = m_hostsToPluginIdentifierData.find(matchedWildcardHost);
- if (plugInIdentifierData == m_hostsToPluginIdentifierData.end() || !plugInIdentifierData->value.contains(identifier))
- return false;
-
- host = matchedWildcardHost;
- return true;
-}
-
-bool WebPlatformStrategies::pluginLoadClientPolicyForHost(const String& host, const PluginInfo& info, PluginLoadClientPolicy& policy) const
-{
- String hostToLookUp = host;
- String identifier = info.bundleIdentifier;
-
- auto policiesByIdentifierIterator = m_hostsToPluginIdentifierData.find(hostToLookUp);
-
- if (!identifier.isNull() && policiesByIdentifierIterator == m_hostsToPluginIdentifierData.end()) {
- if (!replaceHostWithMatchedWildcardHost(hostToLookUp, identifier))
- hostToLookUp = "*";
- policiesByIdentifierIterator = m_hostsToPluginIdentifierData.find(hostToLookUp);
- if (hostToLookUp != "*" && policiesByIdentifierIterator == m_hostsToPluginIdentifierData.end()) {
- hostToLookUp = "*";
- policiesByIdentifierIterator = m_hostsToPluginIdentifierData.find(hostToLookUp);
- }
- }
- if (policiesByIdentifierIterator == m_hostsToPluginIdentifierData.end())
- return false;
-
- auto& policiesByIdentifier = policiesByIdentifierIterator->value;
-
- if (!identifier)
- identifier = "*";
-
- auto identifierPolicyIterator = policiesByIdentifier.find(identifier);
- if (identifier != "*" && identifierPolicyIterator == policiesByIdentifier.end()) {
- identifier = "*";
- identifierPolicyIterator = policiesByIdentifier.find(identifier);
- }
- if (identifierPolicyIterator == policiesByIdentifier.end())
- return false;
-
- auto& versionsToPolicies = identifierPolicyIterator->value;
-
- String version = info.versionString;
- if (!version)
- version = "*";
- auto policyIterator = versionsToPolicies.find(version);
- if (version != "*" && policyIterator == versionsToPolicies.end()) {
- version = "*";
- policyIterator = versionsToPolicies.find(version);
- }
-
- if (policyIterator == versionsToPolicies.end())
- return false;
-
- policy = policyIterator->value;
- return true;
-}
-#endif // PLATFORM(MAC)
-
-void WebPlatformStrategies::populatePluginCache(const WebCore::Page& page)
-{
- if (!m_pluginCacheIsPopulated) {
- HangDetectionDisabler hangDetectionDisabler;
-
- if (!WebProcess::singleton().parentProcessConnection()->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()->responseURL().host();
- for (PluginInfo& 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 <WebCore/LoaderStrategy.h>
</span><span class="cx"> #include <WebCore/PasteboardStrategy.h>
</span><span class="cx"> #include <WebCore/PlatformStrategies.h>
</span><del>-#include <WebCore/PluginStrategy.h>
</del><span class="cx"> #include <wtf/HashMap.h>
</span><span class="cx"> #include <wtf/NeverDestroyed.h>
</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<WebPlatformStrategies>;
</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&, const WebCore::URL&, const String&) override;
</span><span class="cx"> void addCookie(const WebCore::NetworkStorageSession&, const WebCore::URL&, const WebCore::Cookie&) override;
</span><span class="cx">
</span><del>- // WebCore::PluginStrategy
- void refreshPlugins() override;
- void getPluginInfo(const WebCore::Page*, Vector<WebCore::PluginInfo>&) override;
- void getWebVisiblePluginInfo(const WebCore::Page*, Vector<WebCore::PluginInfo>&) override;
-
-#if PLATFORM(MAC)
- typedef HashMap<String, WebCore::PluginLoadClientPolicy> PluginLoadClientPoliciesByBundleVersion;
- typedef HashMap<String, PluginLoadClientPoliciesByBundleVersion> PluginPolicyMapsByIdentifier;
-
- void setPluginLoadClientPolicy(WebCore::PluginLoadClientPolicy, const String& host, const String& bundleIdentifier, const String& 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&) override;
</span><span class="lines">@@ -103,27 +89,8 @@
</span><span class="cx"> long setStringForType(const String&, const String& pasteboardType, const String& 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&);
- bool m_pluginCacheIsPopulated;
- bool m_shouldRefreshPlugins;
- Vector<WebCore::PluginInfo> m_cachedPlugins;
- Vector<WebCore::PluginInfo> m_cachedApplicationPlugins;
-
-#if PLATFORM(MAC)
- HashMap<String, PluginPolicyMapsByIdentifier> m_hostsToPluginIdentifierData;
- bool pluginLoadClientPolicyForHost(const String&, const WebCore::PluginInfo&, WebCore::PluginLoadClientPolicy&) const;
- String longestMatchedWildcardHostForHost(const String& host) const;
- bool replaceHostWithMatchedWildcardHost(String& host, const String& 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<WebCore::PluginInfo>&, const Vector<WebCore::PluginInfo>& 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 "WebPage.h"
</span><span class="cx"> #include "WebPageGroupProxy.h"
</span><span class="cx"> #include "WebPlatformStrategies.h"
</span><ins>+#include "WebPluginInfoProvider.h"
</ins><span class="cx"> #include "WebProcessCreationParameters.h"
</span><span class="cx"> #include "WebProcessMessages.h"
</span><span class="cx"> #include "WebProcessPoolMessages.h"
</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->value.begin(); bundleIdentifierIter != hostIter->value.end(); ++bundleIdentifierIter) {
</span><span class="cx"> for (auto versionIter = bundleIdentifierIter->value.begin(); versionIter != bundleIdentifierIter->value.end(); ++versionIter)
</span><del>- platformStrategies()->pluginStrategy()->setPluginLoadClientPolicy(static_cast<PluginLoadClientPolicy>(versionIter->value), hostIter->key, bundleIdentifierIter->key, versionIter->key);
</del><ins>+ WebPluginInfoProvider::singleton().setPluginLoadClientPolicy(static_cast<PluginLoadClientPolicy>(versionIter->value), hostIter->key, bundleIdentifierIter->key, versionIter->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& host, const String& bundleIdentifier, const String& versionString)
</span><span class="cx"> {
</span><span class="cx"> #if ENABLE(NETSCAPE_PLUGIN_API) && PLATFORM(MAC)
</span><del>- platformStrategies()->pluginStrategy()->setPluginLoadClientPolicy(static_cast<PluginLoadClientPolicy>(policy), host, bundleIdentifier, versionString);
</del><ins>+ WebPluginInfoProvider::singleton().setPluginLoadClientPolicy(static_cast<PluginLoadClientPolicy>(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) && PLATFORM(MAC)
</span><del>- platformStrategies()->pluginStrategy()->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>