<!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>[167120] releases/WebKitGTK/webkit-2.4/Source/WebCore</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/167120">167120</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2014-04-11 03:22:25 -0700 (Fri, 11 Apr 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Unreviewed. [GTK] Plugin process crashes when loading totem plugin
https://bugs.webkit.org/show_bug.cgi?id=131357
Make Netscape browser functions static to avoid conflicts with
plugins defining those functions as well.
* GNUmakefile.list.am: Do not build npapi.cpp.
* plugins/PluginPackage.cpp:
(WebCore::pluginViewForInstance):
(WebCore::NPN_MemAlloc):
(WebCore::NPN_MemFree):
(WebCore::NPN_MemFlush):
(WebCore::NPN_ReloadPlugins):
(WebCore::NPN_RequestRead):
(WebCore::NPN_GetURLNotify):
(WebCore::NPN_GetURL):
(WebCore::NPN_PostURLNotify):
(WebCore::NPN_PostURL):
(WebCore::NPN_NewStream):
(WebCore::NPN_Write):
(WebCore::NPN_DestroyStream):
(WebCore::NPN_UserAgent):
(WebCore::NPN_Status):
(WebCore::NPN_InvalidateRect):
(WebCore::NPN_InvalidateRegion):
(WebCore::NPN_ForceRedraw):
(WebCore::NPN_GetValue):
(WebCore::NPN_SetValue):
(WebCore::NPN_GetJavaEnv):
(WebCore::NPN_GetJavaPeer):
(WebCore::NPN_PushPopupsEnabledState):
(WebCore::NPN_PopPopupsEnabledState):
(WebCore::NPN_PluginThreadAsyncCall):
(WebCore::NPN_GetValueForURL):
(WebCore::NPN_SetValueForURL):
(WebCore::NPN_GetAuthenticationInfo):
(WebCore::NPN_PopUpContextMenu):
* plugins/PluginPackage.h:
(WebCore::PluginPackage::browserFuncs): Add accessor to browser
function pointers.
* plugins/PluginView.cpp:
(WebCore::PluginView::stop): Use browser function pointers instead
of NPN wrappers that are now private.
(WebCore::PluginView::getValueForURL): Ditto.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#releasesWebKitGTKwebkit24SourceWebCoreChangeLog">releases/WebKitGTK/webkit-2.4/Source/WebCore/ChangeLog</a></li>
<li><a href="#releasesWebKitGTKwebkit24SourceWebCoreGNUmakefilelistam">releases/WebKitGTK/webkit-2.4/Source/WebCore/GNUmakefile.list.am</a></li>
<li><a href="#releasesWebKitGTKwebkit24SourceWebCorepluginsPluginPackagecpp">releases/WebKitGTK/webkit-2.4/Source/WebCore/plugins/PluginPackage.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit24SourceWebCorepluginsPluginPackageh">releases/WebKitGTK/webkit-2.4/Source/WebCore/plugins/PluginPackage.h</a></li>
<li><a href="#releasesWebKitGTKwebkit24SourceWebCorepluginsPluginViewcpp">releases/WebKitGTK/webkit-2.4/Source/WebCore/plugins/PluginView.cpp</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="releasesWebKitGTKwebkit24SourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.4/Source/WebCore/ChangeLog (167119 => 167120)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.4/Source/WebCore/ChangeLog        2014-04-11 09:23:01 UTC (rev 167119)
+++ releases/WebKitGTK/webkit-2.4/Source/WebCore/ChangeLog        2014-04-11 10:22:25 UTC (rev 167120)
</span><span class="lines">@@ -1,3 +1,50 @@
</span><ins>+2014-04-11 Carlos Garcia Campos <cgarcia@igalia.com>
+
+ Unreviewed. [GTK] Plugin process crashes when loading totem plugin
+ https://bugs.webkit.org/show_bug.cgi?id=131357
+
+ Make Netscape browser functions static to avoid conflicts with
+ plugins defining those functions as well.
+
+ * GNUmakefile.list.am: Do not build npapi.cpp.
+ * plugins/PluginPackage.cpp:
+ (WebCore::pluginViewForInstance):
+ (WebCore::NPN_MemAlloc):
+ (WebCore::NPN_MemFree):
+ (WebCore::NPN_MemFlush):
+ (WebCore::NPN_ReloadPlugins):
+ (WebCore::NPN_RequestRead):
+ (WebCore::NPN_GetURLNotify):
+ (WebCore::NPN_GetURL):
+ (WebCore::NPN_PostURLNotify):
+ (WebCore::NPN_PostURL):
+ (WebCore::NPN_NewStream):
+ (WebCore::NPN_Write):
+ (WebCore::NPN_DestroyStream):
+ (WebCore::NPN_UserAgent):
+ (WebCore::NPN_Status):
+ (WebCore::NPN_InvalidateRect):
+ (WebCore::NPN_InvalidateRegion):
+ (WebCore::NPN_ForceRedraw):
+ (WebCore::NPN_GetValue):
+ (WebCore::NPN_SetValue):
+ (WebCore::NPN_GetJavaEnv):
+ (WebCore::NPN_GetJavaPeer):
+ (WebCore::NPN_PushPopupsEnabledState):
+ (WebCore::NPN_PopPopupsEnabledState):
+ (WebCore::NPN_PluginThreadAsyncCall):
+ (WebCore::NPN_GetValueForURL):
+ (WebCore::NPN_SetValueForURL):
+ (WebCore::NPN_GetAuthenticationInfo):
+ (WebCore::NPN_PopUpContextMenu):
+ * plugins/PluginPackage.h:
+ (WebCore::PluginPackage::browserFuncs): Add accessor to browser
+ function pointers.
+ * plugins/PluginView.cpp:
+ (WebCore::PluginView::stop): Use browser function pointers instead
+ of NPN wrappers that are now private.
+ (WebCore::PluginView::getValueForURL): Ditto.
+
</ins><span class="cx"> 2014-04-01 Martin Robinson <mrobinson@igalia.com>
</span><span class="cx">
</span><span class="cx"> [GTK] Readonly attributes installed as readwrite in GObject DOM bindings
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit24SourceWebCoreGNUmakefilelistam"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.4/Source/WebCore/GNUmakefile.list.am (167119 => 167120)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.4/Source/WebCore/GNUmakefile.list.am        2014-04-11 09:23:01 UTC (rev 167119)
+++ releases/WebKitGTK/webkit-2.4/Source/WebCore/GNUmakefile.list.am        2014-04-11 10:22:25 UTC (rev 167120)
</span><span class="lines">@@ -4266,7 +4266,6 @@
</span><span class="cx">         Source/WebCore/plugins/PluginViewBase.h \
</span><span class="cx">         Source/WebCore/plugins/PluginView.cpp \
</span><span class="cx">         Source/WebCore/plugins/PluginView.h \
</span><del>-        Source/WebCore/plugins/npapi.cpp \
</del><span class="cx">         Source/WebCore/plugins/npapi.h \
</span><span class="cx">         Source/WebCore/plugins/npfunctions.h \
</span><span class="cx">         Source/WebCore/plugins/npruntime.h \
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit24SourceWebCorepluginsPluginPackagecpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.4/Source/WebCore/plugins/PluginPackage.cpp (167119 => 167120)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.4/Source/WebCore/plugins/PluginPackage.cpp        2014-04-11 09:23:01 UTC (rev 167119)
+++ releases/WebKitGTK/webkit-2.4/Source/WebCore/plugins/PluginPackage.cpp        2014-04-11 10:22:25 UTC (rev 167120)
</span><span class="lines">@@ -29,8 +29,11 @@
</span><span class="cx"> #include "PluginPackage.h"
</span><span class="cx">
</span><span class="cx"> #include "MIMETypeRegistry.h"
</span><ins>+#include "Page.h"
</ins><span class="cx"> #include "PluginDatabase.h"
</span><span class="cx"> #include "PluginDebug.h"
</span><ins>+#include "PluginMainThreadScheduler.h"
+#include "PluginView.h"
</ins><span class="cx"> #include "Timer.h"
</span><span class="cx"> #include "npruntime_impl.h"
</span><span class="cx"> #include <string.h>
</span><span class="lines">@@ -265,6 +268,177 @@
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> #if ENABLE(NETSCAPE_PLUGIN_API)
</span><ins>+static PluginView* pluginViewForInstance(NPP instance)
+{
+ if (instance && instance->ndata)
+ return static_cast<PluginView*>(instance->ndata);
+ return PluginView::currentPluginView();
+}
+
+static void* NPN_MemAlloc(uint32_t size)
+{
+ return malloc(size);
+}
+
+static void NPN_MemFree(void* ptr)
+{
+ free(ptr);
+}
+
+static uint32_t NPN_MemFlush(uint32_t)
+{
+ // Do nothing
+ return 0;
+}
+
+static void NPN_ReloadPlugins(NPBool reloadPages)
+{
+ Page::refreshPlugins(reloadPages);
+}
+
+static NPError NPN_RequestRead(NPStream*, NPByteRange*)
+{
+ return NPERR_STREAM_NOT_SEEKABLE;
+}
+
+static NPError NPN_GetURLNotify(NPP instance, const char* url, const char* target, void* notifyData)
+{
+ return pluginViewForInstance(instance)->getURLNotify(url, target, notifyData);
+}
+
+static NPError NPN_GetURL(NPP instance, const char* url, const char* target)
+{
+ return pluginViewForInstance(instance)->getURL(url, target);
+}
+
+static NPError NPN_PostURLNotify(NPP instance, const char* url, const char* target, uint32_t len, const char* buf, NPBool file, void* notifyData)
+{
+ return pluginViewForInstance(instance)->postURLNotify(url, target, len, buf, file, notifyData);
+}
+
+static NPError NPN_PostURL(NPP instance, const char* url, const char* target, uint32_t len, const char* buf, NPBool file)
+{
+ return pluginViewForInstance(instance)->postURL(url, target, len, buf, file);
+}
+
+static NPError NPN_NewStream(NPP instance, NPMIMEType type, const char* target, NPStream** stream)
+{
+ return pluginViewForInstance(instance)->newStream(type, target, stream);
+}
+
+static int32_t NPN_Write(NPP instance, NPStream* stream, int32_t len, void* buffer)
+{
+ return pluginViewForInstance(instance)->write(stream, len, buffer);
+}
+
+static NPError NPN_DestroyStream(NPP instance, NPStream* stream, NPReason reason)
+{
+ return pluginViewForInstance(instance)->destroyStream(stream, reason);
+}
+
+static const char* NPN_UserAgent(NPP instance)
+{
+ PluginView* view = pluginViewForInstance(instance);
+
+ if (!view)
+ return PluginView::userAgentStatic();
+
+ return view->userAgent();
+}
+
+static void NPN_Status(NPP instance, const char* message)
+{
+ pluginViewForInstance(instance)->status(message);
+}
+
+static void NPN_InvalidateRect(NPP instance, NPRect* invalidRect)
+{
+ PluginView* view = pluginViewForInstance(instance);
+#if defined(XP_UNIX)
+ // NSPluginWrapper, a plugin wrapper binary that allows running 32-bit plugins
+ // on 64-bit architectures typically used in X11, will sometimes give us a null NPP here.
+ if (!view)
+ return;
+#endif
+ view->invalidateRect(invalidRect);
+}
+
+static void NPN_InvalidateRegion(NPP instance, NPRegion invalidRegion)
+{
+ pluginViewForInstance(instance)->invalidateRegion(invalidRegion);
+}
+
+static void NPN_ForceRedraw(NPP instance)
+{
+ pluginViewForInstance(instance)->forceRedraw();
+}
+
+static NPError NPN_GetValue(NPP instance, NPNVariable variable, void* value)
+{
+ PluginView* view = pluginViewForInstance(instance);
+
+ if (!view)
+ return PluginView::getValueStatic(variable, value);
+
+ return pluginViewForInstance(instance)->getValue(variable, value);
+}
+
+static NPError NPN_SetValue(NPP instance, NPPVariable variable, void* value)
+{
+ return pluginViewForInstance(instance)->setValue(variable, value);
+}
+
+static void* NPN_GetJavaEnv()
+{
+ // Unsupported
+ return 0;
+}
+
+static void* NPN_GetJavaPeer(NPP)
+{
+ // Unsupported
+ return 0;
+}
+
+static void NPN_PushPopupsEnabledState(NPP instance, NPBool enabled)
+{
+ pluginViewForInstance(instance)->pushPopupsEnabledState(enabled);
+}
+
+static void NPN_PopPopupsEnabledState(NPP instance)
+{
+ pluginViewForInstance(instance)->popPopupsEnabledState();
+}
+
+extern "C" typedef void PluginThreadAsyncCallFunction(void*);
+static void NPN_PluginThreadAsyncCall(NPP instance, PluginThreadAsyncCallFunction func, void* userData)
+{
+ // Callback function type only differs from MainThreadFunction by being extern "C", which doesn't affect calling convention on any compilers we use.
+ PluginMainThreadScheduler::scheduler().scheduleCall(instance, reinterpret_cast<PluginMainThreadScheduler::MainThreadFunction*>(func), userData);
+}
+
+static NPError NPN_GetValueForURL(NPP instance, NPNURLVariable variable, const char* url, char** value, uint32_t* len)
+{
+ return pluginViewForInstance(instance)->getValueForURL(variable, url, value, len);
+}
+
+static NPError NPN_SetValueForURL(NPP instance, NPNURLVariable variable, const char* url, const char* value, uint32_t len)
+{
+ return pluginViewForInstance(instance)->setValueForURL(variable, url, value, len);
+}
+
+static NPError NPN_GetAuthenticationInfo(NPP instance, const char* protocol, const char* host, int32_t port, const char* scheme, const char* realm, char** username, uint32_t* ulen, char** password, uint32_t* plen)
+{
+ return pluginViewForInstance(instance)->getAuthenticationInfo(protocol, host, port, scheme, realm, username, ulen, password, plen);
+}
+
+static NPError NPN_PopUpContextMenu(NPP instance, NPMenu* menu)
+{
+ UNUSED_PARAM(instance);
+ UNUSED_PARAM(menu);
+ return NPERR_NO_ERROR;
+}
+
</ins><span class="cx"> void PluginPackage::initializeBrowserFuncs()
</span><span class="cx"> {
</span><span class="cx"> memset(&m_browserFuncs, 0, sizeof(m_browserFuncs));
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit24SourceWebCorepluginsPluginPackageh"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.4/Source/WebCore/plugins/PluginPackage.h (167119 => 167120)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.4/Source/WebCore/plugins/PluginPackage.h        2014-04-11 09:23:01 UTC (rev 167119)
+++ releases/WebKitGTK/webkit-2.4/Source/WebCore/plugins/PluginPackage.h        2014-04-11 10:22:25 UTC (rev 167120)
</span><span class="lines">@@ -74,6 +74,7 @@
</span><span class="cx">
</span><span class="cx"> #if ENABLE(NETSCAPE_PLUGIN_API)
</span><span class="cx"> const NPPluginFuncs* pluginFuncs() const { return &m_pluginFuncs; }
</span><ins>+ const NPNetscapeFuncs* browserFuncs() const { return &m_browserFuncs; }
</ins><span class="cx"> #endif
</span><span class="cx"> int compareFileVersion(const PlatformModuleVersion&) const;
</span><span class="cx"> int compare(const PluginPackage&) const;
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit24SourceWebCorepluginsPluginViewcpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.4/Source/WebCore/plugins/PluginView.cpp (167119 => 167120)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.4/Source/WebCore/plugins/PluginView.cpp        2014-04-11 09:23:01 UTC (rev 167119)
+++ releases/WebKitGTK/webkit-2.4/Source/WebCore/plugins/PluginView.cpp        2014-04-11 10:22:25 UTC (rev 167120)
</span><span class="lines">@@ -387,8 +387,8 @@
</span><span class="cx"> if (savedData) {
</span><span class="cx"> // TODO: Actually save this data instead of just discarding it
</span><span class="cx"> if (savedData->buf)
</span><del>- NPN_MemFree(savedData->buf);
- NPN_MemFree(savedData);
</del><ins>+ m_plugin->browserFuncs()->memfree(savedData->buf);
+ m_plugin->browserFuncs()->memfree(savedData);
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="lines">@@ -1386,7 +1386,7 @@
</span><span class="cx"> const CString cookieStr = cookies(frame->document(), u).utf8();
</span><span class="cx"> if (!cookieStr.isNull()) {
</span><span class="cx"> const int size = cookieStr.length();
</span><del>- *value = static_cast<char*>(NPN_MemAlloc(size+1));
</del><ins>+ *value = static_cast<char*>(m_plugin->browserFuncs()->memalloc(size+1));
</ins><span class="cx"> if (*value) {
</span><span class="cx"> memset(*value, 0, size+1);
</span><span class="cx"> memcpy(*value, cookieStr.data(), size+1);
</span><span class="lines">@@ -1409,7 +1409,7 @@
</span><span class="cx"> const CString proxyStr = toString(proxyServersForURL(u, context)).utf8();
</span><span class="cx"> if (!proxyStr.isNull()) {
</span><span class="cx"> const int size = proxyStr.length();
</span><del>- *value = static_cast<char*>(NPN_MemAlloc(size+1));
</del><ins>+ *value = static_cast<char*>(m_plugin->browserFuncs()->memalloc(size+1));
</ins><span class="cx"> if (*value) {
</span><span class="cx"> memset(*value, 0, size+1);
</span><span class="cx"> memcpy(*value, proxyStr.data(), size+1);
</span></span></pre>
</div>
</div>
</body>
</html>