<!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>[178219] trunk/Source</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/178219">178219</a></dd>
<dt>Author</dt> <dd>andersca@apple.com</dd>
<dt>Date</dt> <dd>2015-01-09 16:16:52 -0800 (Fri, 09 Jan 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Move the Windows only plug-in code to WebKit/win
https://bugs.webkit.org/show_bug.cgi?id=140133
Reviewed by Darin Adler.
Source/WebCore:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
Source/WebKit:
* WebKit.vcxproj/WebKit/WebKit.vcxproj:
* WebKit.vcxproj/WebKit/WebKit.vcxproj.filters:
Source/WebKit/win:
* Plugins/PaintHooks.asm: Renamed from Source/WebCore/plugins/win/PaintHooks.asm.
* Plugins/PluginDatabase.cpp: Renamed from Source/WebCore/plugins/PluginDatabase.cpp.
(WebCore::persistentPluginMetadataCachePath):
(WebCore::PluginDatabase::PluginDatabase):
(WebCore::PluginDatabase::installedPlugins):
(WebCore::PluginDatabase::isMIMETypeRegistered):
(WebCore::PluginDatabase::addExtraPluginDirectory):
(WebCore::PluginDatabase::refresh):
(WebCore::PluginDatabase::plugins):
(WebCore::PluginDatabase::preferredPluginCompare):
(WebCore::PluginDatabase::pluginForMIMEType):
(WebCore::PluginDatabase::MIMETypeForExtension):
(WebCore::PluginDatabase::findPlugin):
(WebCore::PluginDatabase::setPreferredPluginForMIMEType):
(WebCore::PluginDatabase::fileExistsAndIsNotDisabled):
(WebCore::PluginDatabase::getDeletedPlugins):
(WebCore::PluginDatabase::add):
(WebCore::PluginDatabase::remove):
(WebCore::PluginDatabase::clear):
(WebCore::PluginDatabase::removeDisabledPluginFile):
(WebCore::PluginDatabase::addDisabledPluginFile):
(WebCore::PluginDatabase::defaultPluginDirectories):
(WebCore::PluginDatabase::isPreferredPluginDirectory):
(WebCore::PluginDatabase::getPluginPathsInDirectories):
(WebCore::fillBufferWithContentsOfFile):
(WebCore::readUTF8String):
(WebCore::readTime):
(WebCore::PluginDatabase::loadPersistentMetadataCache):
(WebCore::writeUTF8String):
(WebCore::writeTime):
(WebCore::PluginDatabase::updatePersistentMetadataCache):
(WebCore::PluginDatabase::isPersistentMetadataCacheEnabled):
(WebCore::PluginDatabase::setPersistentMetadataCacheEnabled):
(WebCore::PluginDatabase::persistentMetadataCachePath):
(WebCore::PluginDatabase::setPersistentMetadataCachePath):
* Plugins/PluginDatabase.h: Renamed from Source/WebCore/plugins/PluginDatabase.h.
(WebCore::PluginDatabase::setPluginDirectories):
(WebCore::PluginDatabase::pluginDirectories):
* Plugins/PluginDatabaseWin.cpp: Renamed from Source/WebCore/plugins/win/PluginDatabaseWin.cpp.
(WebCore::addPluginPathsFromRegistry):
(WebCore::PluginDatabase::getPluginPathsInDirectories):
(WebCore::parseVersionString):
(WebCore::compareVersions):
(WebCore::addMozillaPluginDirectories):
(WebCore::addWindowsMediaPlayerPluginDirectory):
(WebCore::addAdobeAcrobatPluginDirectory):
(WebCore::addJavaPluginDirectory):
(WebCore::safariPluginsDirectory):
(WebCore::addMacromediaPluginDirectories):
(WebCore::PluginDatabase::defaultPluginDirectories):
(WebCore::PluginDatabase::isPreferredPluginDirectory):
* Plugins/PluginDebug.cpp: Renamed from Source/WebCore/plugins/PluginDebug.cpp.
(WebCore::prettyNameForNPError):
(WebCore::prettyNameForDrawingModel):
(WebCore::prettyNameForEventModel):
(WebCore::prettyNameForNPNVariable):
(WebCore::prettyNameForNPPVariable):
(WebCore::prettyNameForNPNURLVariable):
* Plugins/PluginDebug.h: Renamed from Source/WebCore/plugins/PluginDebug.h.
* Plugins/PluginMessageThrottlerWin.cpp: Renamed from Source/WebCore/plugins/win/PluginMessageThrottlerWin.cpp.
(WebCore::PluginMessageThrottlerWin::PluginMessageThrottlerWin):
(WebCore::PluginMessageThrottlerWin::~PluginMessageThrottlerWin):
(WebCore::PluginMessageThrottlerWin::appendMessage):
(WebCore::PluginMessageThrottlerWin::processQueuedMessage):
(WebCore::PluginMessageThrottlerWin::messageThrottleTimerFired):
(WebCore::PluginMessageThrottlerWin::allocateMessage):
(WebCore::PluginMessageThrottlerWin::isInlineMessage):
(WebCore::PluginMessageThrottlerWin::freeMessage):
* Plugins/PluginMessageThrottlerWin.h: Renamed from Source/WebCore/plugins/win/PluginMessageThrottlerWin.h.
* Plugins/PluginPackage.cpp: Renamed from Source/WebCore/plugins/PluginPackage.cpp.
(WebCore::PluginPackage::~PluginPackage):
(WebCore::PluginPackage::freeLibrarySoon):
(WebCore::PluginPackage::freeLibraryTimerFired):
(WebCore::PluginPackage::compare):
(WebCore::PluginPackage::PluginPackage):
(WebCore::PluginPackage::unload):
(WebCore::PluginPackage::unloadWithoutShutdown):
(WebCore::PluginPackage::setEnabled):
(WebCore::PluginPackage::createPackage):
(WebCore::PluginPackage::createPackageFromCache):
(WebCore::PluginPackage::determineQuirks):
(WebCore::PluginPackage::determineModuleVersionFromDescription):
(WebCore::getListFromVariantArgs):
(WebCore::makeSource):
(WebCore::NPN_Evaluate):
(WebCore::NPN_Invoke):
(WebCore::PluginPackage::initializeBrowserFuncs):
(WebCore::PluginPackage::hash):
(WebCore::PluginPackage::equal):
(WebCore::PluginPackage::compareFileVersion):
(WebCore::PluginPackage::ensurePluginLoaded):
* Plugins/PluginPackage.h: Renamed from Source/WebCore/plugins/PluginPackage.h.
(WebCore::PluginPackage::name):
(WebCore::PluginPackage::description):
(WebCore::PluginPackage::path):
(WebCore::PluginPackage::fileName):
(WebCore::PluginPackage::parentDirectory):
(WebCore::PluginPackage::module):
(WebCore::PluginPackage::lastModified):
(WebCore::PluginPackage::mimeToDescriptions):
(WebCore::PluginPackage::mimeToExtensions):
(WebCore::PluginPackage::isEnabled):
(WebCore::PluginPackage::pluginFuncs):
(WebCore::PluginPackage::quirks):
(WebCore::PluginPackage::version):
(WebCore::PluginPackage::fullMIMEDescription):
(WebCore::PluginPackageHash::hash):
(WebCore::PluginPackageHash::equal):
* Plugins/PluginPackageWin.cpp: Renamed from Source/WebCore/plugins/win/PluginPackageWin.cpp.
(WebCore::getVersionInfo):
(WebCore::PluginPackage::isPluginBlacklisted):
(WebCore::PluginPackage::determineQuirks):
(WebCore::PluginPackage::fetchInfo):
(WebCore::PluginPackage::load):
(WebCore::PluginPackage::hash):
(WebCore::PluginPackage::equal):
(WebCore::PluginPackage::NPVersion):
* Plugins/PluginQuirkSet.h: Renamed from Source/WebCore/plugins/PluginQuirkSet.h.
(WebCore::PluginQuirkSet::PluginQuirkSet):
(WebCore::PluginQuirkSet::add):
(WebCore::PluginQuirkSet::contains):
* Plugins/PluginStream.cpp: Renamed from Source/WebCore/plugins/PluginStream.cpp.
(WebCore::streams):
(WebCore::PluginStream::PluginStream):
(WebCore::PluginStream::~PluginStream):
(WebCore::PluginStream::start):
(WebCore::PluginStream::stop):
(WebCore::lastModifiedDate):
(WebCore::PluginStream::startStream):
(WebCore::PluginStream::ownerForStream):
(WebCore::PluginStream::cancelAndDestroyStream):
(WebCore::PluginStream::destroyStream):
(WebCore::PluginStream::delayDeliveryTimerFired):
(WebCore::PluginStream::deliverData):
(WebCore::PluginStream::sendJavaScriptStream):
(WebCore::PluginStream::didReceiveResponse):
(WebCore::PluginStream::didReceiveData):
(WebCore::PluginStream::didFail):
(WebCore::PluginStream::didFinishLoading):
(WebCore::PluginStream::wantsAllStreams):
* Plugins/PluginStream.h: Renamed from Source/WebCore/plugins/PluginStream.h.
(WebCore::PluginStreamClient::~PluginStreamClient):
(WebCore::PluginStreamClient::streamDidFinishLoading):
(WebCore::PluginStream::create):
(WebCore::PluginStream::setLoadManually):
* Plugins/PluginView.cpp: Renamed from Source/WebCore/plugins/PluginView.cpp.
(WebCore::instanceMap):
(WebCore::scriptStringIfJavaScriptURL):
(WebCore::PluginView::popPopupsStateTimerFired):
(WebCore::PluginView::windowClipRect):
(WebCore::PluginView::setFrameRect):
(WebCore::PluginView::frameRectsChanged):
(WebCore::PluginView::clipRectChanged):
(WebCore::PluginView::handleEvent):
(WebCore::PluginView::init):
(WebCore::PluginView::startOrAddToUnstartedList):
(WebCore::PluginView::start):
(WebCore::PluginView::mediaCanStart):
(WebCore::PluginView::~PluginView):
(WebCore::PluginView::stop):
(WebCore::PluginView::setCurrentPluginView):
(WebCore::PluginView::currentPluginView):
(WebCore::createUTF8String):
(WebCore::PluginView::performRequest):
(WebCore::PluginView::requestTimerFired):
(WebCore::PluginView::scheduleRequest):
(WebCore::PluginView::load):
(WebCore::makeURL):
(WebCore::PluginView::getURLNotify):
(WebCore::PluginView::getURL):
(WebCore::PluginView::postURLNotify):
(WebCore::PluginView::postURL):
(WebCore::PluginView::newStream):
(WebCore::PluginView::write):
(WebCore::PluginView::destroyStream):
(WebCore::PluginView::status):
(WebCore::PluginView::setValue):
(WebCore::PluginView::invalidateTimerFired):
(WebCore::PluginView::pushPopupsEnabledState):
(WebCore::PluginView::popPopupsEnabledState):
(WebCore::PluginView::arePopupsAllowed):
(WebCore::PluginView::setJavaScriptPaused):
(WebCore::PluginView::npObject):
(WebCore::PluginView::bindingInstance):
(WebCore::PluginView::disconnectStream):
(WebCore::PluginView::setParameters):
(WebCore::PluginView::PluginView):
(WebCore::PluginView::focusPluginElement):
(WebCore::PluginView::didReceiveResponse):
(WebCore::PluginView::didReceiveData):
(WebCore::PluginView::didFinishLoading):
(WebCore::PluginView::didFail):
(WebCore::PluginView::setCallingPlugin):
(WebCore::PluginView::isCallingPlugin):
(WebCore::PluginView::create):
(WebCore::PluginView::freeStringArray):
(WebCore::startsWithBlankLine):
(WebCore::locationAfterFirstBlankLine):
(WebCore::findEOL):
(WebCore::capitalizeRFC822HeaderFieldName):
(WebCore::parseRFC822HeaderFields):
(WebCore::PluginView::handlePost):
(WebCore::PluginView::invalidateWindowlessPluginRect):
(WebCore::PluginView::paintMissingPluginIcon):
(WebCore::PluginView::userAgent):
(WebCore::PluginView::userAgentStatic):
(WebCore::PluginView::lifeSupportTimerFired):
(WebCore::PluginView::keepAlive):
(WebCore::PluginView::getValueStatic):
(WebCore::PluginView::getValue):
(WebCore::getFrame):
(WebCore::PluginView::getValueForURL):
(WebCore::PluginView::setValueForURL):
(WebCore::PluginView::getAuthenticationInfo):
(WebCore::PluginView::privateBrowsingStateChanged):
* Plugins/PluginView.h: Renamed from Source/WebCore/plugins/PluginView.h.
(WebCore::PluginRequest::PluginRequest):
(WebCore::PluginRequest::frameLoadRequest):
(WebCore::PluginRequest::notifyData):
(WebCore::PluginRequest::sendNotification):
(WebCore::PluginRequest::shouldAllowPopups):
(WebCore::PluginManualLoader::~PluginManualLoader):
(WebCore::PluginView::plugin):
(WebCore::PluginView::instance):
(WebCore::PluginView::status):
(WebCore::PluginView::streamDidFinishLoading):
(WebCore::PluginView::parentFrame):
(WebCore::PluginView::pluginsPage):
(WebCore::PluginView::mimeType):
(WebCore::PluginView::url):
(WebCore::PluginView::pluginWndProc):
(WebCore::PluginView::platformPluginWidget):
(WebCore::PluginView::setPlatformPluginWidget):
(WebCore::toPluginView):
* Plugins/PluginViewWin.cpp: Renamed from Source/WebCore/plugins/win/PluginViewWin.cpp.
(windowHandleForPageClient):
(WebCore::PluginView::hookedBeginPaint):
(WebCore::PluginView::hookedEndPaint):
(WebCore::hook):
(WebCore::setUpOffscreenPaintingHooks):
(WebCore::registerPluginView):
(WebCore::PluginView::PluginViewWndProc):
(WebCore::isWindowsMessageUserGesture):
(WebCore::contentsToNativeWindow):
(WebCore::PluginView::wndProc):
(WebCore::PluginView::updatePluginWidget):
(WebCore::PluginView::setFocus):
(WebCore::PluginView::show):
(WebCore::PluginView::hide):
(WebCore::PluginView::dispatchNPEvent):
(WebCore::PluginView::paintIntoTransformedContext):
(WebCore::PluginView::paintWindowedPluginIntoContext):
(WebCore::PluginView::paint):
(WebCore::PluginView::handleKeyboardEvent):
(WebCore::PluginView::handleMouseEvent):
(WebCore::PluginView::setParent):
(WebCore::PluginView::setParentVisible):
(WebCore::PluginView::setNPWindowRect):
(WebCore::PluginView::handlePostReadFile):
(WebCore::PluginView::platformGetValueStatic):
(WebCore::PluginView::platformGetValue):
(WebCore::PluginView::invalidateRect):
(WebCore::PluginView::invalidateRegion):
(WebCore::PluginView::forceRedraw):
(WebCore::PluginView::platformStart):
(WebCore::PluginView::platformDestroy):
(WebCore::PluginView::snapshot):
* Plugins/npapi.cpp: Renamed from Source/WebCore/plugins/npapi.cpp.
(pluginViewForInstance):
(NPN_MemAlloc):
(NPN_MemFree):
(NPN_MemFlush):
(NPN_ReloadPlugins):
(NPN_RequestRead):
(NPN_GetURLNotify):
(NPN_GetURL):
(NPN_PostURLNotify):
(NPN_PostURL):
(NPN_NewStream):
(NPN_Write):
(NPN_DestroyStream):
(NPN_UserAgent):
(NPN_Status):
(NPN_InvalidateRect):
(NPN_InvalidateRegion):
(NPN_ForceRedraw):
(NPN_GetValue):
(NPN_SetValue):
(NPN_GetJavaEnv):
(NPN_GetJavaPeer):
(NPN_PushPopupsEnabledState):
(NPN_PopPopupsEnabledState):
(NPN_PluginThreadAsyncCall):
(NPN_GetValueForURL):
(NPN_SetValueForURL):
(NPN_GetAuthenticationInfo):
(NPN_PopUpContextMenu):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreCMakeListstxt">trunk/Source/WebCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCorevcxprojWebCorevcxproj">trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj</a></li>
<li><a href="#trunkSourceWebCoreWebCorevcxprojWebCorevcxprojfilters">trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters</a></li>
<li><a href="#trunkSourceWebCoreWebCorevcxprojcopyForwardingHeaderscmd">trunk/Source/WebCore/WebCore.vcxproj/copyForwardingHeaders.cmd</a></li>
<li><a href="#trunkSourceWebCoreloaderFrameLoadercpp">trunk/Source/WebCore/loader/FrameLoader.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformeflTemporaryLinkStubscpp">trunk/Source/WebCore/platform/efl/TemporaryLinkStubs.cpp</a></li>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitWebKitvcxprojWebKitWebKitvcxproj">trunk/Source/WebKit/WebKit.vcxproj/WebKit/WebKit.vcxproj</a></li>
<li><a href="#trunkSourceWebKitWebKitvcxprojWebKitWebKitvcxprojfilters">trunk/Source/WebKit/WebKit.vcxproj/WebKit/WebKit.vcxproj.filters</a></li>
<li><a href="#trunkSourceWebKitWebKitvcxprojWebKitWebKitCommonprops">trunk/Source/WebKit/WebKit.vcxproj/WebKit/WebKitCommon.props</a></li>
<li><a href="#trunkSourceWebKitwinChangeLog">trunk/Source/WebKit/win/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitwinWebCoreSupportEmbeddedWidgeth">trunk/Source/WebKit/win/WebCoreSupport/EmbeddedWidget.h</a></li>
<li><a href="#trunkSourceWebKitwinWebCoreSupportWebFrameLoaderClientcpp">trunk/Source/WebKit/win/WebCoreSupport/WebFrameLoaderClient.cpp</a></li>
<li><a href="#trunkSourceWebKitwinWebCoreSupportWebPlatformStrategiescpp">trunk/Source/WebKit/win/WebCoreSupport/WebPlatformStrategies.cpp</a></li>
<li><a href="#trunkSourceWebKitwinWebFramecpp">trunk/Source/WebKit/win/WebFrame.cpp</a></li>
<li><a href="#trunkSourceWebKitwinWebViewcpp">trunk/Source/WebKit/win/WebView.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessPluginsunixPluginInfoStoreUnixcpp">trunk/Source/WebKit2/UIProcess/Plugins/unix/PluginInfoStoreUnix.cpp</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li>trunk/Source/WebKit/win/Plugins/</li>
<li><a href="#trunkSourceWebKitwinPluginsPaintHooksasm">trunk/Source/WebKit/win/Plugins/PaintHooks.asm</a></li>
<li><a href="#trunkSourceWebKitwinPluginsPluginDatabasecpp">trunk/Source/WebKit/win/Plugins/PluginDatabase.cpp</a></li>
<li><a href="#trunkSourceWebKitwinPluginsPluginDatabaseh">trunk/Source/WebKit/win/Plugins/PluginDatabase.h</a></li>
<li><a href="#trunkSourceWebKitwinPluginsPluginDatabaseWincpp">trunk/Source/WebKit/win/Plugins/PluginDatabaseWin.cpp</a></li>
<li><a href="#trunkSourceWebKitwinPluginsPluginDebugcpp">trunk/Source/WebKit/win/Plugins/PluginDebug.cpp</a></li>
<li><a href="#trunkSourceWebKitwinPluginsPluginDebugh">trunk/Source/WebKit/win/Plugins/PluginDebug.h</a></li>
<li><a href="#trunkSourceWebKitwinPluginsPluginMessageThrottlerWincpp">trunk/Source/WebKit/win/Plugins/PluginMessageThrottlerWin.cpp</a></li>
<li><a href="#trunkSourceWebKitwinPluginsPluginMessageThrottlerWinh">trunk/Source/WebKit/win/Plugins/PluginMessageThrottlerWin.h</a></li>
<li><a href="#trunkSourceWebKitwinPluginsPluginPackagecpp">trunk/Source/WebKit/win/Plugins/PluginPackage.cpp</a></li>
<li><a href="#trunkSourceWebKitwinPluginsPluginPackageh">trunk/Source/WebKit/win/Plugins/PluginPackage.h</a></li>
<li><a href="#trunkSourceWebKitwinPluginsPluginPackageWincpp">trunk/Source/WebKit/win/Plugins/PluginPackageWin.cpp</a></li>
<li><a href="#trunkSourceWebKitwinPluginsPluginQuirkSeth">trunk/Source/WebKit/win/Plugins/PluginQuirkSet.h</a></li>
<li><a href="#trunkSourceWebKitwinPluginsPluginStreamcpp">trunk/Source/WebKit/win/Plugins/PluginStream.cpp</a></li>
<li><a href="#trunkSourceWebKitwinPluginsPluginStreamh">trunk/Source/WebKit/win/Plugins/PluginStream.h</a></li>
<li><a href="#trunkSourceWebKitwinPluginsPluginViewcpp">trunk/Source/WebKit/win/Plugins/PluginView.cpp</a></li>
<li><a href="#trunkSourceWebKitwinPluginsPluginViewh">trunk/Source/WebKit/win/Plugins/PluginView.h</a></li>
<li><a href="#trunkSourceWebKitwinPluginsPluginViewWincpp">trunk/Source/WebKit/win/Plugins/PluginViewWin.cpp</a></li>
<li><a href="#trunkSourceWebKitwinPluginsnpapicpp">trunk/Source/WebKit/win/Plugins/npapi.cpp</a></li>
</ul>
<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkSourceWebCorepluginsPluginDatabasecpp">trunk/Source/WebCore/plugins/PluginDatabase.cpp</a></li>
<li><a href="#trunkSourceWebCorepluginsPluginDatabaseh">trunk/Source/WebCore/plugins/PluginDatabase.h</a></li>
<li><a href="#trunkSourceWebCorepluginsPluginDebugcpp">trunk/Source/WebCore/plugins/PluginDebug.cpp</a></li>
<li><a href="#trunkSourceWebCorepluginsPluginDebugh">trunk/Source/WebCore/plugins/PluginDebug.h</a></li>
<li><a href="#trunkSourceWebCorepluginsPluginPackagecpp">trunk/Source/WebCore/plugins/PluginPackage.cpp</a></li>
<li><a href="#trunkSourceWebCorepluginsPluginPackageh">trunk/Source/WebCore/plugins/PluginPackage.h</a></li>
<li><a href="#trunkSourceWebCorepluginsPluginQuirkSeth">trunk/Source/WebCore/plugins/PluginQuirkSet.h</a></li>
<li><a href="#trunkSourceWebCorepluginsPluginStreamcpp">trunk/Source/WebCore/plugins/PluginStream.cpp</a></li>
<li><a href="#trunkSourceWebCorepluginsPluginStreamh">trunk/Source/WebCore/plugins/PluginStream.h</a></li>
<li><a href="#trunkSourceWebCorepluginsPluginViewcpp">trunk/Source/WebCore/plugins/PluginView.cpp</a></li>
<li><a href="#trunkSourceWebCorepluginsPluginViewh">trunk/Source/WebCore/plugins/PluginView.h</a></li>
<li><a href="#trunkSourceWebCorepluginsnpapicpp">trunk/Source/WebCore/plugins/npapi.cpp</a></li>
<li>trunk/Source/WebCore/plugins/win/</li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/CMakeLists.txt (178218 => 178219)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/CMakeLists.txt        2015-01-10 00:09:59 UTC (rev 178218)
+++ trunk/Source/WebCore/CMakeLists.txt        2015-01-10 00:16:52 UTC (rev 178219)
</span><span class="lines">@@ -2231,9 +2231,7 @@
</span><span class="cx"> plugins/DOMPlugin.cpp
</span><span class="cx"> plugins/DOMPluginArray.cpp
</span><span class="cx"> plugins/PluginData.cpp
</span><del>- plugins/PluginDebug.cpp
</del><span class="cx"> plugins/PluginMainThreadScheduler.cpp
</span><del>- plugins/PluginStream.cpp
</del><span class="cx">
</span><span class="cx"> rendering/AutoTableLayout.cpp
</span><span class="cx"> rendering/BidiRun.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (178218 => 178219)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-01-10 00:09:59 UTC (rev 178218)
+++ trunk/Source/WebCore/ChangeLog        2015-01-10 00:16:52 UTC (rev 178219)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2015-01-06 Anders Carlsson <andersca@apple.com>
+
+ Move the Windows only plug-in code to WebKit/win
+ https://bugs.webkit.org/show_bug.cgi?id=140133
+
+ Reviewed by Darin Adler.
+
+ * WebCore.vcxproj/WebCore.vcxproj:
+ * WebCore.vcxproj/WebCore.vcxproj.filters:
+
</ins><span class="cx"> 2015-01-09 Anders Carlsson <andersca@apple.com>
</span><span class="cx">
</span><span class="cx"> Another Windows build fix.
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorevcxprojWebCorevcxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj (178218 => 178219)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj        2015-01-10 00:09:59 UTC (rev 178218)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj        2015-01-10 00:16:52 UTC (rev 178219)
</span><span class="lines">@@ -17704,18 +17704,8 @@
</span><span class="cx"> <ClCompile Include="..\plugins\DOMMimeTypeArray.cpp" />
</span><span class="cx"> <ClCompile Include="..\plugins\DOMPlugin.cpp" />
</span><span class="cx"> <ClCompile Include="..\plugins\DOMPluginArray.cpp" />
</span><del>- <ClCompile Include="..\plugins\npapi.cpp" />
</del><span class="cx"> <ClCompile Include="..\plugins\PluginData.cpp" />
</span><del>- <ClCompile Include="..\plugins\PluginDatabase.cpp" />
- <ClCompile Include="..\plugins\PluginDebug.cpp" />
</del><span class="cx"> <ClCompile Include="..\plugins\PluginMainThreadScheduler.cpp" />
</span><del>- <ClCompile Include="..\plugins\PluginPackage.cpp" />
- <ClCompile Include="..\plugins\PluginStream.cpp" />
- <ClCompile Include="..\plugins\PluginView.cpp" />
- <ClCompile Include="..\plugins\win\PluginDatabaseWin.cpp" />
- <ClCompile Include="..\plugins\win\PluginMessageThrottlerWin.cpp" />
- <ClCompile Include="..\plugins\win\PluginPackageWin.cpp" />
- <ClCompile Include="..\plugins\win\PluginViewWin.cpp" />
</del><span class="cx"> <ClCompile Include="..\svg\SVGAllInOne.cpp" />
</span><span class="cx"> <ClCompile Include="..\svg\SVGFontFaceElement.cpp">
</span><span class="cx"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
</span><span class="lines">@@ -20972,15 +20962,7 @@
</span><span class="cx"> <ClInclude Include="..\plugins\npfunctions.h" />
</span><span class="cx"> <ClInclude Include="..\plugins\npruntime.h" />
</span><span class="cx"> <ClInclude Include="..\plugins\PluginData.h" />
</span><del>- <ClInclude Include="..\plugins\PluginDatabase.h" />
- <ClInclude Include="..\plugins\PluginDebug.h" />
</del><span class="cx"> <ClInclude Include="..\plugins\PluginMainThreadScheduler.h" />
</span><del>- <ClInclude Include="..\plugins\PluginPackage.h" />
- <ClInclude Include="..\plugins\PluginQuirkSet.h" />
- <ClInclude Include="..\plugins\PluginStrategy.h" />
- <ClInclude Include="..\plugins\PluginStream.h" />
- <ClInclude Include="..\plugins\PluginView.h" />
- <ClInclude Include="..\plugins\win\PluginMessageThrottlerWin.h" />
</del><span class="cx"> <ClInclude Include="..\svg\ColorDistance.h" />
</span><span class="cx"> <ClInclude Include="..\svg\SVGAElement.h" />
</span><span class="cx"> <ClInclude Include="..\svg\SVGAltGlyphDefElement.h" />
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorevcxprojWebCorevcxprojfilters"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters (178218 => 178219)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters        2015-01-10 00:09:59 UTC (rev 178218)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters        2015-01-10 00:16:52 UTC (rev 178219)
</span><span class="lines">@@ -4542,42 +4542,12 @@
</span><span class="cx"> <ClCompile Include="..\plugins\DOMPluginArray.cpp">
</span><span class="cx"> <Filter>plugins</Filter>
</span><span class="cx"> </ClCompile>
</span><del>- <ClCompile Include="..\plugins\npapi.cpp">
- <Filter>plugins</Filter>
- </ClCompile>
</del><span class="cx"> <ClCompile Include="..\plugins\PluginData.cpp">
</span><span class="cx"> <Filter>plugins</Filter>
</span><span class="cx"> </ClCompile>
</span><del>- <ClCompile Include="..\plugins\PluginDatabase.cpp">
- <Filter>plugins</Filter>
- </ClCompile>
- <ClCompile Include="..\plugins\PluginDebug.cpp">
- <Filter>plugins</Filter>
- </ClCompile>
</del><span class="cx"> <ClCompile Include="..\plugins\PluginMainThreadScheduler.cpp">
</span><span class="cx"> <Filter>plugins</Filter>
</span><span class="cx"> </ClCompile>
</span><del>- <ClCompile Include="..\plugins\PluginPackage.cpp">
- <Filter>plugins</Filter>
- </ClCompile>
- <ClCompile Include="..\plugins\PluginStream.cpp">
- <Filter>plugins</Filter>
- </ClCompile>
- <ClCompile Include="..\plugins\PluginView.cpp">
- <Filter>plugins</Filter>
- </ClCompile>
- <ClCompile Include="..\plugins\win\PluginDatabaseWin.cpp">
- <Filter>plugins\win</Filter>
- </ClCompile>
- <ClCompile Include="..\plugins\win\PluginMessageThrottlerWin.cpp">
- <Filter>plugins\win</Filter>
- </ClCompile>
- <ClCompile Include="..\plugins\win\PluginPackageWin.cpp">
- <Filter>plugins\win</Filter>
- </ClCompile>
- <ClCompile Include="..\plugins\win\PluginViewWin.cpp">
- <Filter>plugins\win</Filter>
- </ClCompile>
</del><span class="cx"> <ClCompile Include="..\svg\SVGAllInOne.cpp">
</span><span class="cx"> <Filter>rendering\svg</Filter>
</span><span class="cx"> </ClCompile>
</span><span class="lines">@@ -11550,33 +11520,12 @@
</span><span class="cx"> <ClInclude Include="..\plugins\PluginData.h">
</span><span class="cx"> <Filter>plugins</Filter>
</span><span class="cx"> </ClInclude>
</span><del>- <ClInclude Include="..\plugins\PluginDatabase.h">
- <Filter>plugins</Filter>
- </ClInclude>
- <ClInclude Include="..\plugins\PluginDebug.h">
- <Filter>plugins</Filter>
- </ClInclude>
</del><span class="cx"> <ClInclude Include="..\plugins\PluginMainThreadScheduler.h">
</span><span class="cx"> <Filter>plugins</Filter>
</span><span class="cx"> </ClInclude>
</span><del>- <ClInclude Include="..\plugins\PluginPackage.h">
- <Filter>plugins</Filter>
- </ClInclude>
- <ClInclude Include="..\plugins\PluginQuirkSet.h">
- <Filter>plugins</Filter>
- </ClInclude>
</del><span class="cx"> <ClInclude Include="..\plugins\PluginStrategy.h">
</span><span class="cx"> <Filter>plugins</Filter>
</span><span class="cx"> </ClInclude>
</span><del>- <ClInclude Include="..\plugins\PluginStream.h">
- <Filter>plugins</Filter>
- </ClInclude>
- <ClInclude Include="..\plugins\PluginView.h">
- <Filter>plugins</Filter>
- </ClInclude>
- <ClInclude Include="..\plugins\win\PluginMessageThrottlerWin.h">
- <Filter>plugins\win</Filter>
- </ClInclude>
</del><span class="cx"> <ClInclude Include="..\svg\ColorDistance.h">
</span><span class="cx"> <Filter>rendering\svg</Filter>
</span><span class="cx"> </ClInclude>
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorevcxprojcopyForwardingHeaderscmd"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.vcxproj/copyForwardingHeaders.cmd (178218 => 178219)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.vcxproj/copyForwardingHeaders.cmd        2015-01-10 00:09:59 UTC (rev 178218)
+++ trunk/Source/WebCore/WebCore.vcxproj/copyForwardingHeaders.cmd        2015-01-10 00:16:52 UTC (rev 178219)
</span><span class="lines">@@ -79,6 +79,7 @@
</span><span class="cx"> xcopy /y /d "%ProjectDir%..\page\animation\*.h" "%CONFIGURATIONBUILDDIR%\include\WebCore"
</span><span class="cx"> xcopy /y /d "%ProjectDir%..\page\win\*.h" "%CONFIGURATIONBUILDDIR%\include\WebCore"
</span><span class="cx"> xcopy /y /d "%ProjectDir%..\bridge\*.h" "%CONFIGURATIONBUILDDIR%\include\WebCore"
</span><ins>+xcopy /y /d "%ProjectDir%..\bridge\c\*.h" "%CONFIGURATIONBUILDDIR%\include\WebCore"
</ins><span class="cx"> xcopy /y /d "%ProjectDir%..\bridge\jsc\*.h" "%CONFIGURATIONBUILDDIR%\include\WebCore"
</span><span class="cx"> xcopy /y /d "%ProjectDir%..\plugins\*.h" "%CONFIGURATIONBUILDDIR%\include\WebCore"
</span><span class="cx"> xcopy /y /d "%ProjectDir%..\plugins\win\*.h" "%CONFIGURATIONBUILDDIR%\include\WebCore"
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderFrameLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (178218 => 178219)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/FrameLoader.cpp        2015-01-10 00:09:59 UTC (rev 178218)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp        2015-01-10 00:16:52 UTC (rev 178219)
</span><span class="lines">@@ -91,7 +91,6 @@
</span><span class="cx"> #include "PageTransitionEvent.h"
</span><span class="cx"> #include "PlatformStrategies.h"
</span><span class="cx"> #include "PluginData.h"
</span><del>-#include "PluginDatabase.h"
</del><span class="cx"> #include "PluginDocument.h"
</span><span class="cx"> #include "PolicyChecker.h"
</span><span class="cx"> #include "ProgressTracker.h"
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformeflTemporaryLinkStubscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/efl/TemporaryLinkStubs.cpp (178218 => 178219)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/efl/TemporaryLinkStubs.cpp        2015-01-10 00:09:59 UTC (rev 178218)
+++ trunk/Source/WebCore/platform/efl/TemporaryLinkStubs.cpp        2015-01-10 00:16:52 UTC (rev 178219)
</span><span class="lines">@@ -36,7 +36,6 @@
</span><span class="cx"> #include "FrameView.h"
</span><span class="cx"> #include "URL.h"
</span><span class="cx"> #include "NotImplemented.h"
</span><del>-#include "PluginView.h"
</del><span class="cx"> #include "ScrollbarTheme.h"
</span><span class="cx"> #include "SharedBuffer.h"
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorepluginsPluginDatabasecpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/plugins/PluginDatabase.cpp (178218 => 178219)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/plugins/PluginDatabase.cpp        2015-01-10 00:09:59 UTC (rev 178218)
+++ trunk/Source/WebCore/plugins/PluginDatabase.cpp        2015-01-10 00:16:52 UTC (rev 178219)
</span><span class="lines">@@ -1,677 +0,0 @@
</span><del>-/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- * Copyright (C) 2008 Collabora, Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "PluginDatabase.h"
-
-#include "Frame.h"
-#include "URL.h"
-#include "PluginPackage.h"
-#if ENABLE(NETSCAPE_PLUGIN_METADATA_CACHE)
-#include "FileSystem.h"
-#endif
-#include <stdlib.h>
-#include <wtf/text/CString.h>
-
-namespace WebCore {
-
-typedef HashMap<String, RefPtr<PluginPackage> > PluginPackageByNameMap;
-
-#if ENABLE(NETSCAPE_PLUGIN_METADATA_CACHE)
-static const size_t maximumPersistentPluginMetadataCacheSize = 32768;
-
-static bool gPersistentPluginMetadataCacheIsEnabled;
-
-String& persistentPluginMetadataCachePath()
-{
- DEPRECATED_DEFINE_STATIC_LOCAL(String, cachePath, ());
- return cachePath;
-}
-#endif
-
-PluginDatabase::PluginDatabase()
-#if ENABLE(NETSCAPE_PLUGIN_METADATA_CACHE)
- : m_persistentMetadataCacheIsLoaded(false)
-#endif
-{
-}
-
-PluginDatabase* PluginDatabase::installedPlugins(bool populate)
-{
- static PluginDatabase* plugins = 0;
-
- if (!plugins) {
- plugins = new PluginDatabase;
-
- if (populate) {
- plugins->setPluginDirectories(PluginDatabase::defaultPluginDirectories());
- plugins->refresh();
- }
- }
-
- return plugins;
-}
-
-bool PluginDatabase::isMIMETypeRegistered(const String& mimeType)
-{
- if (mimeType.isNull())
- return false;
- if (m_registeredMIMETypes.contains(mimeType))
- return true;
- // No plugin was found, try refreshing the database and searching again
- return (refresh() && m_registeredMIMETypes.contains(mimeType));
-}
-
-void PluginDatabase::addExtraPluginDirectory(const String& directory)
-{
- m_pluginDirectories.append(directory);
- refresh();
-}
-
-bool PluginDatabase::refresh()
-{
-#if ENABLE(NETSCAPE_PLUGIN_METADATA_CACHE)
- if (!m_persistentMetadataCacheIsLoaded)
- loadPersistentMetadataCache();
-#endif
- bool pluginSetChanged = false;
-
- if (!m_plugins.isEmpty()) {
- PluginSet pluginsToUnload;
- getDeletedPlugins(pluginsToUnload);
-
- // Unload plugins
- PluginSet::const_iterator end = pluginsToUnload.end();
- for (PluginSet::const_iterator it = pluginsToUnload.begin(); it != end; ++it)
- remove(it->get());
-
- pluginSetChanged = !pluginsToUnload.isEmpty();
- }
-
- HashSet<String> paths;
- getPluginPathsInDirectories(paths);
-
- HashMap<String, time_t> pathsWithTimes;
-
- // We should only skip unchanged files if we didn't remove any plugins above. If we did remove
- // any plugins, we need to look at every plugin file so that, e.g., if the user has two versions
- // of RealPlayer installed and just removed the newer one, we'll pick up the older one.
- bool shouldSkipUnchangedFiles = !pluginSetChanged;
-
- HashSet<String>::const_iterator pathsEnd = paths.end();
- for (HashSet<String>::const_iterator it = paths.begin(); it != pathsEnd; ++it) {
- time_t lastModified;
- if (!getFileModificationTime(*it, lastModified))
- continue;
-
- pathsWithTimes.add(*it, lastModified);
-
- // If the path's timestamp hasn't changed since the last time we ran refresh(), we don't have to do anything.
- if (shouldSkipUnchangedFiles && m_pluginPathsWithTimes.get(*it) == lastModified)
- continue;
-
- if (RefPtr<PluginPackage> oldPackage = m_pluginsByPath.get(*it)) {
- ASSERT(!shouldSkipUnchangedFiles || oldPackage->lastModified() != lastModified);
- remove(oldPackage.get());
- }
-
- RefPtr<PluginPackage> package = PluginPackage::createPackage(*it, lastModified);
- if (package && add(package.release()))
- pluginSetChanged = true;
- }
-
- // Cache all the paths we found with their timestamps for next time.
- pathsWithTimes.swap(m_pluginPathsWithTimes);
-
- if (!pluginSetChanged)
- return false;
-
-#if ENABLE(NETSCAPE_PLUGIN_METADATA_CACHE)
- updatePersistentMetadataCache();
-#endif
-
- m_registeredMIMETypes.clear();
-
- // Register plug-in MIME types
- PluginSet::const_iterator end = m_plugins.end();
- for (PluginSet::const_iterator it = m_plugins.begin(); it != end; ++it) {
- // Get MIME types
- MIMEToDescriptionsMap::const_iterator map_it = (*it)->mimeToDescriptions().begin();
- MIMEToDescriptionsMap::const_iterator map_end = (*it)->mimeToDescriptions().end();
- for (; map_it != map_end; ++map_it)
- m_registeredMIMETypes.add(map_it->key);
- }
-
- return true;
-}
-
-Vector<PluginPackage*> PluginDatabase::plugins() const
-{
- Vector<PluginPackage*> result;
-
- PluginSet::const_iterator end = m_plugins.end();
- for (PluginSet::const_iterator it = m_plugins.begin(); it != end; ++it)
- result.append((*it).get());
-
- return result;
-}
-
-int PluginDatabase::preferredPluginCompare(const void* a, const void* b)
-{
- PluginPackage* pluginA = *static_cast<PluginPackage* const*>(a);
- PluginPackage* pluginB = *static_cast<PluginPackage* const*>(b);
-
- return pluginA->compare(*pluginB);
-}
-
-PluginPackage* PluginDatabase::pluginForMIMEType(const String& mimeType)
-{
- if (mimeType.isEmpty())
- return 0;
-
- String key = mimeType.lower();
- PluginSet::const_iterator end = m_plugins.end();
- PluginPackage* preferredPlugin = m_preferredPlugins.get(key);
- if (preferredPlugin
- && preferredPlugin->isEnabled()
- && preferredPlugin->mimeToDescriptions().contains(key)) {
- return preferredPlugin;
- }
-
- Vector<PluginPackage*, 2> pluginChoices;
-
- for (PluginSet::const_iterator it = m_plugins.begin(); it != end; ++it) {
- PluginPackage* plugin = (*it).get();
-
- if (!plugin->isEnabled())
- continue;
-
- if (plugin->mimeToDescriptions().contains(key)) {
-#if ENABLE(NETSCAPE_PLUGIN_METADATA_CACHE)
- if (!plugin->ensurePluginLoaded())
- continue;
-#endif
- pluginChoices.append(plugin);
- }
- }
-
- if (pluginChoices.isEmpty())
- return 0;
-
- qsort(pluginChoices.data(), pluginChoices.size(), sizeof(PluginPackage*), PluginDatabase::preferredPluginCompare);
-
- return pluginChoices[0];
-}
-
-String PluginDatabase::MIMETypeForExtension(const String& extension) const
-{
- if (extension.isEmpty())
- return String();
-
- PluginSet::const_iterator end = m_plugins.end();
- String mimeType;
- Vector<PluginPackage*, 2> pluginChoices;
- HashMap<PluginPackage*, String> mimeTypeForPlugin;
-
- for (PluginSet::const_iterator it = m_plugins.begin(); it != end; ++it) {
- if (!(*it)->isEnabled())
- continue;
-
- MIMEToExtensionsMap::const_iterator mime_end = (*it)->mimeToExtensions().end();
-
- for (MIMEToExtensionsMap::const_iterator mime_it = (*it)->mimeToExtensions().begin(); mime_it != mime_end; ++mime_it) {
- mimeType = mime_it->key;
- PluginPackage* preferredPlugin = m_preferredPlugins.get(mimeType);
- const Vector<String>& extensions = mime_it->value;
- bool foundMapping = false;
- for (unsigned i = 0; i < extensions.size(); i++) {
- if (equalIgnoringCase(extensions[i], extension)) {
- PluginPackage* plugin = (*it).get();
-
- if (preferredPlugin && PluginPackage::equal(*plugin, *preferredPlugin))
- return mimeType;
-
-#if ENABLE(NETSCAPE_PLUGIN_METADATA_CACHE)
- if (!plugin->ensurePluginLoaded())
- continue;
-#endif
- pluginChoices.append(plugin);
- mimeTypeForPlugin.add(plugin, mimeType);
- foundMapping = true;
- break;
- }
- }
- if (foundMapping)
- break;
- }
- }
-
- if (pluginChoices.isEmpty())
- return String();
-
- qsort(pluginChoices.data(), pluginChoices.size(), sizeof(PluginPackage*), PluginDatabase::preferredPluginCompare);
-
- return mimeTypeForPlugin.get(pluginChoices[0]);
-}
-
-PluginPackage* PluginDatabase::findPlugin(const URL& url, String& mimeType)
-{
- if (!mimeType.isEmpty())
- return pluginForMIMEType(mimeType);
-
- String filename = url.lastPathComponent();
- if (filename.endsWith('/'))
- return 0;
-
- int extensionPos = filename.reverseFind('.');
- if (extensionPos == -1)
- return 0;
-
- String mimeTypeForExtension = MIMETypeForExtension(filename.substring(extensionPos + 1));
- PluginPackage* plugin = pluginForMIMEType(mimeTypeForExtension);
- if (!plugin) {
- // FIXME: if no plugin could be found, query Windows for the mime type
- // corresponding to the extension.
- return 0;
- }
-
- mimeType = mimeTypeForExtension;
- return plugin;
-}
-
-void PluginDatabase::setPreferredPluginForMIMEType(const String& mimeType, PluginPackage* plugin)
-{
- if (!plugin || plugin->mimeToExtensions().contains(mimeType))
- m_preferredPlugins.set(mimeType.lower(), plugin);
-}
-
-bool PluginDatabase::fileExistsAndIsNotDisabled(const String& filePath) const
-{
- // Skip plugin files that are disabled by filename.
- if (m_disabledPluginFiles.contains(pathGetFileName(filePath)))
- return false;
-
- return fileExists(filePath);
-}
-
-void PluginDatabase::getDeletedPlugins(PluginSet& plugins) const
-{
- PluginSet::const_iterator end = m_plugins.end();
- for (PluginSet::const_iterator it = m_plugins.begin(); it != end; ++it) {
- if (!fileExistsAndIsNotDisabled((*it)->path()))
- plugins.add(*it);
- }
-}
-
-bool PluginDatabase::add(PassRefPtr<PluginPackage> prpPackage)
-{
- ASSERT_ARG(prpPackage, prpPackage);
-
- RefPtr<PluginPackage> package = prpPackage;
-
- if (!m_plugins.add(package).isNewEntry)
- return false;
-
- m_pluginsByPath.add(package->path(), package);
- return true;
-}
-
-void PluginDatabase::remove(PluginPackage* package)
-{
- MIMEToExtensionsMap::const_iterator it = package->mimeToExtensions().begin();
- MIMEToExtensionsMap::const_iterator end = package->mimeToExtensions().end();
- for ( ; it != end; ++it) {
- PluginPackageByNameMap::iterator packageInMap = m_preferredPlugins.find(it->key);
- if (packageInMap != m_preferredPlugins.end() && packageInMap->value == package)
- m_preferredPlugins.remove(packageInMap);
- }
-
- m_plugins.remove(package);
- m_pluginsByPath.remove(package->path());
-}
-
-void PluginDatabase::clear()
-{
- m_plugins.clear();
- m_pluginsByPath.clear();
- m_pluginPathsWithTimes.clear();
- m_registeredMIMETypes.clear();
- m_preferredPlugins.clear();
-#if ENABLE(NETSCAPE_PLUGIN_METADATA_CACHE)
- m_persistentMetadataCacheIsLoaded = false;
-#endif
-}
-
-bool PluginDatabase::removeDisabledPluginFile(const String& fileName)
-{
- return m_disabledPluginFiles.remove(fileName);
-}
-
-bool PluginDatabase::addDisabledPluginFile(const String& fileName)
-{
- return m_disabledPluginFiles.add(fileName).isNewEntry;
-}
-
-#if (!OS(WINDOWS) || !ENABLE(NETSCAPE_PLUGIN_API))
-// For Safari/Win the following three methods are implemented
-// in PluginDatabaseWin.cpp, but if we can use WebCore constructs
-// for the logic we should perhaps move it here under XP_WIN?
-
-Vector<String> PluginDatabase::defaultPluginDirectories()
-{
- Vector<String> paths;
-
- // Add paths specific to each platform
-#if defined(XP_UNIX)
- String userPluginPath = homeDirectoryPath();
- userPluginPath.append(String("/.mozilla/plugins"));
- paths.append(userPluginPath);
-
- userPluginPath = homeDirectoryPath();
- userPluginPath.append(String("/.netscape/plugins"));
- paths.append(userPluginPath);
-
- paths.append("/usr/lib/browser/plugins");
- paths.append("/usr/local/lib/mozilla/plugins");
- paths.append("/usr/lib/firefox/plugins");
- paths.append("/usr/lib64/browser-plugins");
- paths.append("/usr/lib/browser-plugins");
- paths.append("/usr/lib/mozilla/plugins");
- paths.append("/usr/local/netscape/plugins");
- paths.append("/opt/mozilla/plugins");
- paths.append("/opt/mozilla/lib/plugins");
- paths.append("/opt/netscape/plugins");
- paths.append("/opt/netscape/communicator/plugins");
- paths.append("/usr/lib/netscape/plugins");
- paths.append("/usr/lib/netscape/plugins-libc5");
- paths.append("/usr/lib/netscape/plugins-libc6");
- paths.append("/usr/lib64/netscape/plugins");
- paths.append("/usr/lib64/mozilla/plugins");
- paths.append("/usr/lib/nsbrowser/plugins");
- paths.append("/usr/lib64/nsbrowser/plugins");
-
- String mozHome(getenv("MOZILLA_HOME"));
- mozHome.append("/plugins");
- paths.append(mozHome);
-
- Vector<String> mozPaths;
- String mozPath(getenv("MOZ_PLUGIN_PATH"));
- mozPath.split(UChar(':'), /* allowEmptyEntries */ false, mozPaths);
- paths.appendVector(mozPaths);
-#elif defined(XP_MACOSX)
- String userPluginPath = homeDirectoryPath();
- userPluginPath.append(String("/Library/Internet Plug-Ins"));
- paths.append(userPluginPath);
- paths.append("/Library/Internet Plug-Ins");
-#elif defined(XP_WIN)
- String userPluginPath = homeDirectoryPath();
- userPluginPath.append(String("\\Application Data\\Mozilla\\plugins"));
- paths.append(userPluginPath);
-#endif
-
- return paths;
-}
-
-bool PluginDatabase::isPreferredPluginDirectory(const String& path)
-{
- String preferredPath = homeDirectoryPath();
-
-#if defined(XP_UNIX)
- preferredPath.append(String("/.mozilla/plugins"));
-#elif defined(XP_MACOSX)
- preferredPath.append(String("/Library/Internet Plug-Ins"));
-#elif defined(XP_WIN)
- preferredPath.append(String("\\Application Data\\Mozilla\\plugins"));
-#endif
-
- // TODO: We should normalize the path before doing a comparison.
- return path == preferredPath;
-}
-
-void PluginDatabase::getPluginPathsInDirectories(HashSet<String>& paths) const
-{
- // FIXME: This should be a case insensitive set.
- HashSet<String> uniqueFilenames;
-
-#if defined(XP_UNIX)
- String fileNameFilter("*.so");
-#else
- String fileNameFilter("");
-#endif
-
- Vector<String>::const_iterator dirsEnd = m_pluginDirectories.end();
- for (Vector<String>::const_iterator dIt = m_pluginDirectories.begin(); dIt != dirsEnd; ++dIt) {
- Vector<String> pluginPaths = listDirectory(*dIt, fileNameFilter);
- Vector<String>::const_iterator pluginsEnd = pluginPaths.end();
- for (Vector<String>::const_iterator pIt = pluginPaths.begin(); pIt != pluginsEnd; ++pIt) {
- if (!fileExistsAndIsNotDisabled(*pIt))
- continue;
-
- paths.add(*pIt);
- }
- }
-}
-
-#endif // !OS(WINDOWS)
-
-#if ENABLE(NETSCAPE_PLUGIN_METADATA_CACHE)
-
-static void fillBufferWithContentsOfFile(PlatformFileHandle file, Vector<char>& buffer)
-{
- size_t bufferSize = 0;
- size_t bufferCapacity = 1024;
- buffer.resize(bufferCapacity);
-
- do {
- bufferSize += readFromFile(file, buffer.data() + bufferSize, bufferCapacity - bufferSize);
- if (bufferSize == bufferCapacity) {
- if (bufferCapacity < maximumPersistentPluginMetadataCacheSize) {
- bufferCapacity *= 2;
- buffer.resize(bufferCapacity);
- } else {
- buffer.clear();
- return;
- }
- } else
- break;
- } while (true);
-
- buffer.shrink(bufferSize);
-}
-
-static bool readUTF8String(String& resultString, char*& start, const char* end)
-{
- if (start >= end)
- return false;
-
- int len = strlen(start);
- resultString = String::fromUTF8(start, len);
- start += len + 1;
-
- return true;
-}
-
-static bool readTime(time_t& resultTime, char*& start, const char* end)
-{
- if (start + sizeof(time_t) >= end)
- return false;
-
- // The stream is not necessary aligned.
- memcpy(&resultTime, start, sizeof(time_t));
- start += sizeof(time_t);
-
- return true;
-}
-
-static const char schemaVersion = '1';
-static const char persistentPluginMetadataCacheFilename[] = "PluginMetadataCache.bin";
-
-void PluginDatabase::loadPersistentMetadataCache()
-{
- if (!isPersistentMetadataCacheEnabled() || persistentMetadataCachePath().isEmpty())
- return;
-
- PlatformFileHandle file;
- String absoluteCachePath = pathByAppendingComponent(persistentMetadataCachePath(), persistentPluginMetadataCacheFilename);
- file = openFile(absoluteCachePath, OpenForRead);
-
- if (!isHandleValid(file))
- return;
-
- // Mark cache as loaded regardless of success or failure. If
- // there's error in the cache, we won't try to load it anymore.
- m_persistentMetadataCacheIsLoaded = true;
-
- Vector<char> fileContents;
- fillBufferWithContentsOfFile(file, fileContents);
- closeFile(file);
-
- if (fileContents.size() < 2 || fileContents.first() != schemaVersion || fileContents.last() != '\0') {
- LOG_ERROR("Unable to read plugin metadata cache: corrupt schema");
- deleteFile(absoluteCachePath);
- return;
- }
-
- char* bufferPos = fileContents.data() + 1;
- char* end = fileContents.data() + fileContents.size();
-
- PluginSet cachedPlugins;
- HashMap<String, time_t> cachedPluginPathsWithTimes;
- HashMap<String, RefPtr<PluginPackage> > cachedPluginsByPath;
-
- while (bufferPos < end) {
- String path;
- time_t lastModified;
- String name;
- String desc;
- String mimeDesc;
- if (!(readUTF8String(path, bufferPos, end)
- && readTime(lastModified, bufferPos, end)
- && readUTF8String(name, bufferPos, end)
- && readUTF8String(desc, bufferPos, end)
- && readUTF8String(mimeDesc, bufferPos, end))) {
- LOG_ERROR("Unable to read plugin metadata cache: corrupt data");
- deleteFile(absoluteCachePath);
- return;
- }
-
- // Skip metadata that points to plugins from directories that
- // are not part of plugin directory list anymore.
- String pluginDirectoryName = directoryName(path);
- if (m_pluginDirectories.find(pluginDirectoryName) == WTF::notFound)
- continue;
-
- RefPtr<PluginPackage> package = PluginPackage::createPackageFromCache(path, lastModified, name, desc, mimeDesc);
-
- if (package && cachedPlugins.add(package).isNewEntry) {
- cachedPluginPathsWithTimes.add(package->path(), package->lastModified());
- cachedPluginsByPath.add(package->path(), package);
- }
- }
-
- m_plugins.swap(cachedPlugins);
- m_pluginsByPath.swap(cachedPluginsByPath);
- m_pluginPathsWithTimes.swap(cachedPluginPathsWithTimes);
-}
-
-static bool writeUTF8String(PlatformFileHandle file, const String& string)
-{
- CString utf8String = string.utf8();
- int length = utf8String.length() + 1;
- return writeToFile(file, utf8String.data(), length) == length;
-}
-
-static bool writeTime(PlatformFileHandle file, const time_t& time)
-{
- return writeToFile(file, reinterpret_cast<const char*>(&time), sizeof(time_t)) == sizeof(time_t);
-}
-
-void PluginDatabase::updatePersistentMetadataCache()
-{
- if (!isPersistentMetadataCacheEnabled() || persistentMetadataCachePath().isEmpty())
- return;
-
- makeAllDirectories(persistentMetadataCachePath());
- String absoluteCachePath = pathByAppendingComponent(persistentMetadataCachePath(), persistentPluginMetadataCacheFilename);
- deleteFile(absoluteCachePath);
-
- if (m_plugins.isEmpty())
- return;
-
- PlatformFileHandle file;
- file = openFile(absoluteCachePath, OpenForWrite);
-
- if (!isHandleValid(file)) {
- LOG_ERROR("Unable to open plugin metadata cache for saving");
- return;
- }
-
- char localSchemaVersion = schemaVersion;
- if (writeToFile(file, &localSchemaVersion, 1) != 1) {
- LOG_ERROR("Unable to write plugin metadata cache schema");
- closeFile(file);
- deleteFile(absoluteCachePath);
- return;
- }
-
- PluginSet::const_iterator end = m_plugins.end();
- for (PluginSet::const_iterator it = m_plugins.begin(); it != end; ++it) {
- if (!(writeUTF8String(file, (*it)->path())
- && writeTime(file, (*it)->lastModified())
- && writeUTF8String(file, (*it)->name())
- && writeUTF8String(file, (*it)->description())
- && writeUTF8String(file, (*it)->fullMIMEDescription()))) {
- LOG_ERROR("Unable to write plugin metadata to cache");
- closeFile(file);
- deleteFile(absoluteCachePath);
- return;
- }
- }
-
- closeFile(file);
-}
-
-bool PluginDatabase::isPersistentMetadataCacheEnabled()
-{
- return gPersistentPluginMetadataCacheIsEnabled;
-}
-
-void PluginDatabase::setPersistentMetadataCacheEnabled(bool isEnabled)
-{
- gPersistentPluginMetadataCacheIsEnabled = isEnabled;
-}
-
-String PluginDatabase::persistentMetadataCachePath()
-{
- return WebCore::persistentPluginMetadataCachePath();
-}
-
-void PluginDatabase::setPersistentMetadataCachePath(const String& persistentMetadataCachePath)
-{
- WebCore::persistentPluginMetadataCachePath() = persistentMetadataCachePath;
-}
-#endif
-}
</del></span></pre></div>
<a id="trunkSourceWebCorepluginsPluginDatabaseh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/plugins/PluginDatabase.h (178218 => 178219)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/plugins/PluginDatabase.h        2015-01-10 00:09:59 UTC (rev 178218)
+++ trunk/Source/WebCore/plugins/PluginDatabase.h        2015-01-10 00:16:52 UTC (rev 178219)
</span><span class="lines">@@ -1,118 +0,0 @@
</span><del>-/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- * Copyright (C) 2008 Collabora, Ltd. All rights reserved.
- * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef PluginDatabase_h
-#define PluginDatabase_h
-
-#include "PluginPackage.h"
-#include <wtf/HashSet.h>
-#include <wtf/Vector.h>
-#include <wtf/text/StringHash.h>
-#include <wtf/text/WTFString.h>
-
-namespace WebCore {
- class Element;
- class Frame;
- class IntSize;
- class URL;
- class PluginDatabaseClient;
- class PluginPackage;
-
- typedef HashSet<RefPtr<PluginPackage>, PluginPackageHash, PluginPackageHashTraits> PluginSet;
-
- class PluginDatabase {
- WTF_MAKE_NONCOPYABLE(PluginDatabase); WTF_MAKE_FAST_ALLOCATED;
- public:
- PluginDatabase();
-
- // The first call to installedPlugins creates the plugin database
- // and by default populates it with the plugins installed on the system.
- // For testing purposes, it is possible to not populate the database
- // automatically, as the plugins might affect the DRT results by
- // writing to a.o. stderr.
- static PluginDatabase* installedPlugins(bool populate = true);
-
- bool refresh();
- void clear();
- Vector<PluginPackage*> plugins() const;
- bool isMIMETypeRegistered(const String& mimeType);
- void addExtraPluginDirectory(const String&);
-
- static bool isPreferredPluginDirectory(const String& directory);
- static int preferredPluginCompare(const void*, const void*);
-
- PluginPackage* findPlugin(const URL&, String& mimeType);
- PluginPackage* pluginForMIMEType(const String& mimeType);
- void setPreferredPluginForMIMEType(const String& mimeType, PluginPackage* plugin);
-
- void setPluginDirectories(const Vector<String>& directories)
- {
- clear();
- m_pluginDirectories = directories;
- }
-
- bool removeDisabledPluginFile(const String& fileName);
- bool addDisabledPluginFile(const String& fileName);
- static Vector<String> defaultPluginDirectories();
- Vector<String> pluginDirectories() const { return m_pluginDirectories; }
-
- String MIMETypeForExtension(const String& extension) const;
-#if ENABLE(NETSCAPE_PLUGIN_METADATA_CACHE)
- static bool isPersistentMetadataCacheEnabled();
- static void setPersistentMetadataCacheEnabled(bool isEnabled);
- static String persistentMetadataCachePath();
- static void setPersistentMetadataCachePath(const String& persistentMetadataCachePath);
-#endif
-
- private:
- void getPluginPathsInDirectories(HashSet<String>&) const;
- void getDeletedPlugins(PluginSet&) const;
- bool fileExistsAndIsNotDisabled(const String&) const;
-
- // Returns whether the plugin was actually added or not (it won't be added if it's a duplicate of an existing plugin).
- bool add(PassRefPtr<PluginPackage>);
- void remove(PluginPackage*);
-#if ENABLE(NETSCAPE_PLUGIN_METADATA_CACHE)
- void loadPersistentMetadataCache();
- void updatePersistentMetadataCache();
-#endif
-
- HashSet<String> m_disabledPluginFiles;
- Vector<String> m_pluginDirectories;
- HashSet<String> m_registeredMIMETypes;
- PluginSet m_plugins;
- HashMap<String, RefPtr<PluginPackage> > m_pluginsByPath;
- HashMap<String, time_t> m_pluginPathsWithTimes;
- HashMap<String, RefPtr<PluginPackage> > m_preferredPlugins;
-#if ENABLE(NETSCAPE_PLUGIN_METADATA_CACHE)
- bool m_persistentMetadataCacheIsLoaded;
-#endif
- };
-
-} // namespace WebCore
-
-#endif
</del></span></pre></div>
<a id="trunkSourceWebCorepluginsPluginDebugcpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/plugins/PluginDebug.cpp (178218 => 178219)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/plugins/PluginDebug.cpp        2015-01-10 00:09:59 UTC (rev 178218)
+++ trunk/Source/WebCore/plugins/PluginDebug.cpp        2015-01-10 00:16:52 UTC (rev 178219)
</span><span class="lines">@@ -1,179 +0,0 @@
</span><del>-/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "PluginDebug.h"
-
-#include <wtf/text/WTFString.h>
-
-#if !LOG_DISABLED
-
-namespace WebCore {
-
-static const char* const errorStrings[] = {
- "No errors occurred.", /* NPERR_NO_ERROR */
- "Error with no specific error code occurred.", /* NPERR_GENERIC_ERROR */
- "Invalid instance passed to the plug-in.", /* NPERR_INVALID_INSTANCE_ERROR */
- "Function table invalid.", /* NPERR_INVALID_FUNCTABLE_ERROR */
- "Loading of plug-in failed.", /* NPERR_MODULE_LOAD_FAILED_ERROR */
- "Memory allocation failed.", /* NPERR_OUT_OF_MEMORY_ERROR */
- "Plug-in missing or invalid.", /* NPERR_INVALID_PLUGIN_ERROR */
- "Plug-in directory missing or invalid.", /* NPERR_INVALID_PLUGIN_DIR_ERROR */
- "Versions of plug-in and Communicator do not match.", /* NPERR_INCOMPATIBLE_VERSION_ERROR */
- "Parameter missing or invalid.", /* NPERR_INVALID_PARAM */
- "URL missing or invalid.", /* NPERR_INVALID_URL */
- "File missing or invalid.", /* NPERR_FILE_NOT_FOUND */
- "Stream contains no data.", /* NPERR_NO_DATA */
- "Seekable stream expected.", /* NPERR_STREAM_NOT_SEEKABLE */
- "Unknown error code"
-};
-
-#ifdef XP_MACOSX
-static const char* const drawingModels[] = {
- "NPDrawingModelQuickDraw",
- "NPDrawingModelCoreGraphics",
- "NPDrawingModelOpenGL",
- "NPDrawingModelCoreAnimation"
-};
-
-static const char* const eventModels[] = {
- "NPEventModelCarbon",
- "NPEventModelCocoa"
-};
-#endif //XP_MACOSX
-
-const char* prettyNameForNPError(NPError error)
-{
- return errorStrings[error];
-}
-
-#ifdef XP_MACOSX
-const char* prettyNameForDrawingModel(NPDrawingModel drawingModel)
-{
- return drawingModels[drawingModel];
-}
-
-const char* prettyNameForEventModel(NPEventModel eventModel)
-{
- return eventModels[eventModel];
-}
-#endif //XP_MACOSX
-
-CString prettyNameForNPNVariable(NPNVariable variable)
-{
- switch (variable) {
- case NPNVxDisplay: return "NPNVxDisplay";
- case NPNVxtAppContext: return "NPNVxtAppContext";
- case NPNVnetscapeWindow: return "NPNVnetscapeWindow";
- case NPNVjavascriptEnabledBool: return "NPNVjavascriptEnabledBool";
- case NPNVasdEnabledBool: return "NPNVasdEnabledBool";
- case NPNVisOfflineBool: return "NPNVisOfflineBool";
-
- case NPNVserviceManager: return "NPNVserviceManager (not supported)";
- case NPNVDOMElement: return "NPNVDOMElement (not supported)";
- case NPNVDOMWindow: return "NPNVDOMWindow (not supported)";
- case NPNVToolkit: return "NPNVToolkit (not supported)";
- case NPNVSupportsXEmbedBool: return "NPNVSupportsXEmbedBool (not supported)";
-
- case NPNVWindowNPObject: return "NPNVWindowNPObject";
- case NPNVPluginElementNPObject: return "NPNVPluginElementNPObject";
- case NPNVSupportsWindowless: return "NPNVSupportsWindowless";
- case NPNVprivateModeBool: return "NPNVprivateModeBool";
-
-#ifdef XP_MACOSX
- case NPNVpluginDrawingModel: return "NPNVpluginDrawingModel";
-#ifndef NP_NO_QUICKDRAW
- case NPNVsupportsQuickDrawBool: return "NPNVsupportsQuickDrawBool";
-#endif
- case NPNVsupportsCoreGraphicsBool: return "NPNVsupportsCoreGraphicsBool";
- case NPNVsupportsOpenGLBool: return "NPNVsupportsOpenGLBool";
- case NPNVsupportsCoreAnimationBool: return "NPNVsupportsCoreAnimationBool";
-#ifndef NP_NO_CARBON
- case NPNVsupportsCarbonBool: return "NPNVsupportsCarbonBool";
-#endif
- case NPNVsupportsCocoaBool: return "NPNVsupportsCocoaBool";
-#endif
-
- default: return "Unknown variable";
- }
-}
-
-CString prettyNameForNPPVariable(NPPVariable variable, void* value)
-{
- switch (variable) {
- case NPPVpluginNameString: return "NPPVpluginNameString";
- case NPPVpluginDescriptionString: return "NPPVpluginDescriptionString";
- case NPPVpluginWindowBool: return "NPPVpluginWindowBool";
- case NPPVpluginTransparentBool: return "NPPVpluginTransparentBool";
-
- case NPPVjavaClass: return "NPPVjavaClass (not supported)";
- case NPPVpluginWindowSize: return "NPPVpluginWindowSize (not supported)";
- case NPPVpluginTimerInterval: return "NPPVpluginTimerInterval (not supported)";
- case NPPVpluginScriptableInstance: return "NPPVpluginScriptableInstance (not supported)";
- case NPPVpluginScriptableIID: return "NPPVpluginScriptableIID (not supported)";
- case NPPVjavascriptPushCallerBool: return "NPPVjavascriptPushCallerBool (not supported)";
- case NPPVpluginKeepLibraryInMemory: return "NPPVpluginKeepLibraryInMemory (not supported)";
- case NPPVpluginNeedsXEmbed: return "NPPVpluginNeedsXEmbed (not supported)";
-
- case NPPVpluginScriptableNPObject: return "NPPVpluginScriptableNPObject";
-
- case NPPVformValue: return "NPPVformValue (not supported)";
- case NPPVpluginUrlRequestsDisplayedBool: return "NPPVpluginUrlRequestsDisplayedBool (not supported)";
-
- case NPPVpluginWantsAllNetworkStreams: return "NPPVpluginWantsAllNetworkStreams";
- case NPPVpluginCancelSrcStream: return "NPPVpluginCancelSrcStream";
-
-#ifdef XP_MACOSX
- case NPPVpluginDrawingModel: {
- String result("NPPVpluginDrawingModel, ");
- result.append(prettyNameForDrawingModel(NPDrawingModel(uintptr_t(value))));
- return result.latin1();
- }
- case NPPVpluginEventModel: {
- String result("NPPVpluginEventModel, ");
- result.append(prettyNameForEventModel(NPEventModel(uintptr_t(value))));
- return result.latin1();
- }
- case NPPVpluginCoreAnimationLayer: return "NPPVpluginCoreAnimationLayer";
-#else
- UNUSED_PARAM(value);
-#endif
-
- default: return "Unknown variable";
- }
-}
-
-CString prettyNameForNPNURLVariable(NPNURLVariable variable)
-{
- switch (variable) {
- case NPNURLVCookie: return "NPNURLVCookie";
- case NPNURLVProxy: return "NPNURLVProxy";
- default: return "Unknown variable";
- }
-}
-} // namespace WebCore
-
-#endif // !LOG_DISABLED
</del></span></pre></div>
<a id="trunkSourceWebCorepluginsPluginDebugh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/plugins/PluginDebug.h (178218 => 178219)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/plugins/PluginDebug.h        2015-01-10 00:09:59 UTC (rev 178218)
+++ trunk/Source/WebCore/plugins/PluginDebug.h        2015-01-10 00:16:52 UTC (rev 178219)
</span><span class="lines">@@ -1,55 +0,0 @@
</span><del>-/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef PluginDebug_h
-#define PluginDebug_h
-
-#include "Logging.h"
-#include "npruntime_internal.h"
-#include <wtf/text/CString.h>
-
-#define LOG_NPERROR(err) if (err != NPERR_NO_ERROR) LOG_VERBOSE(Plugins, "%s\n", prettyNameForNPError(err))
-#define LOG_PLUGIN_NET_ERROR() LOG_VERBOSE(Plugins, "Stream failed due to problems with network, disk I/O, lack of memory, or other problems.\n")
-
-#if !LOG_DISABLED
-
-namespace WebCore {
-
-const char* prettyNameForNPError(NPError error);
-
-CString prettyNameForNPNVariable(NPNVariable variable);
-CString prettyNameForNPPVariable(NPPVariable variable, void* value);
-CString prettyNameForNPNURLVariable(NPNURLVariable variable);
-
-#ifdef XP_MACOSX
-const char* prettyNameForDrawingModel(NPDrawingModel drawingModel);
-const char* prettyNameForEventModel(NPEventModel eventModel);
-#endif
-
-} // namespace WebCore
-
-#endif // !LOG_DISABLED
-
-#endif // PluginDebug_h
</del></span></pre></div>
<a id="trunkSourceWebCorepluginsPluginPackagecpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/plugins/PluginPackage.cpp (178218 => 178219)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/plugins/PluginPackage.cpp        2015-01-10 00:09:59 UTC (rev 178218)
+++ trunk/Source/WebCore/plugins/PluginPackage.cpp        2015-01-10 00:16:52 UTC (rev 178219)
</span><span class="lines">@@ -1,478 +0,0 @@
</span><del>-/*
- * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
- * Copyright (C) 2008 Collabora Ltd. All rights reserved.
- * Copyright (C) 2009 Holger Hans Peter Freyther
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "PluginPackage.h"
-
-#include "c_utility.h"
-#include "IdentifierRep.h"
-#include "MIMETypeRegistry.h"
-#include "NP_jsobject.h"
-#include "PluginDatabase.h"
-#include "PluginDebug.h"
-#include "PluginView.h"
-#include "runtime_root.h"
-#include "Timer.h"
-#include "npruntime_impl.h"
-#include <string.h>
-#include <JavaScriptCore/Completion.h>
-#include <JavaScriptCore/JSGlobalObject.h>
-#include <wtf/text/CString.h>
-
-namespace WebCore {
-
-PluginPackage::~PluginPackage()
-{
- // This destructor gets called during refresh() if PluginDatabase's
- // PluginSet hash is already populated, as it removes items from
- // the hash table. Calling the destructor on a loaded plug-in of
- // course would cause a crash, so we check to call unload before we
- // ASSERT.
- // FIXME: There is probably a better way to fix this.
- if (!m_loadCount)
- unloadWithoutShutdown();
- else
- unload();
-
- ASSERT(!m_isLoaded);
-}
-
-void PluginPackage::freeLibrarySoon()
-{
- ASSERT(!m_freeLibraryTimer.isActive());
- ASSERT(m_module);
- ASSERT(!m_loadCount);
-
- m_freeLibraryTimer.startOneShot(0);
-}
-
-void PluginPackage::freeLibraryTimerFired()
-{
- ASSERT(m_module);
- // Do nothing if the module got loaded again meanwhile
- if (!m_loadCount) {
- unloadModule(m_module);
- m_module = 0;
- }
-}
-
-
-int PluginPackage::compare(const PluginPackage& compareTo) const
-{
- // Sort plug-ins that allow multiple instances first.
- bool AallowsMultipleInstances = !quirks().contains(PluginQuirkDontAllowMultipleInstances);
- bool BallowsMultipleInstances = !compareTo.quirks().contains(PluginQuirkDontAllowMultipleInstances);
- if (AallowsMultipleInstances != BallowsMultipleInstances)
- return AallowsMultipleInstances ? -1 : 1;
-
- // Sort plug-ins in a preferred path first.
- bool AisInPreferredDirectory = PluginDatabase::isPreferredPluginDirectory(parentDirectory());
- bool BisInPreferredDirectory = PluginDatabase::isPreferredPluginDirectory(compareTo.parentDirectory());
- if (AisInPreferredDirectory != BisInPreferredDirectory)
- return AisInPreferredDirectory ? -1 : 1;
-
- int diff = strcmp(name().utf8().data(), compareTo.name().utf8().data());
- if (diff)
- return diff;
-
- diff = compareFileVersion(compareTo.version());
- if (diff)
- return diff;
-
- return strcmp(parentDirectory().utf8().data(), compareTo.parentDirectory().utf8().data());
-}
-
-PluginPackage::PluginPackage(const String& path, const time_t& lastModified)
- : m_isEnabled(true)
- , m_isLoaded(false)
- , m_loadCount(0)
- , m_path(path)
- , m_moduleVersion(0)
- , m_module(0)
- , m_lastModified(lastModified)
- , m_freeLibraryTimer(*this, &PluginPackage::freeLibraryTimerFired)
-#if ENABLE(NETSCAPE_PLUGIN_METADATA_CACHE)
- , m_infoIsFromCache(true)
-#endif
-{
- m_fileName = pathGetFileName(m_path);
- m_parentDirectory = m_path.left(m_path.length() - m_fileName.length() - 1);
-}
-
-void PluginPackage::unload()
-{
- if (!m_isLoaded)
- return;
-
- if (--m_loadCount > 0)
- return;
-
-#if ENABLE(NETSCAPE_PLUGIN_API)
- m_NPP_Shutdown();
-#endif
-
- unloadWithoutShutdown();
-}
-
-void PluginPackage::unloadWithoutShutdown()
-{
- if (!m_isLoaded)
- return;
-
- ASSERT(!m_loadCount);
- ASSERT(m_module);
-
- // <rdar://5530519>: Crash when closing tab with pdf file (Reader 7 only)
- // If the plugin has subclassed its parent window, as with Reader 7, we may have
- // gotten here by way of the plugin's internal window proc forwarding a message to our
- // original window proc. If we free the plugin library from here, we will jump back
- // to code we just freed when we return, so delay calling FreeLibrary at least until
- // the next message loop
- freeLibrarySoon();
-
- m_isLoaded = false;
-}
-
-void PluginPackage::setEnabled(bool enabled)
-{
- m_isEnabled = enabled;
-}
-
-PassRefPtr<PluginPackage> PluginPackage::createPackage(const String& path, const time_t& lastModified)
-{
- RefPtr<PluginPackage> package = adoptRef(new PluginPackage(path, lastModified));
-
- if (!package->fetchInfo())
- return 0;
-
- return package.release();
-}
-
-#if ENABLE(NETSCAPE_PLUGIN_METADATA_CACHE)
-PassRefPtr<PluginPackage> PluginPackage::createPackageFromCache(const String& path, const time_t& lastModified, const String& name, const String& description, const String& mimeDescription)
-{
- RefPtr<PluginPackage> package = adoptRef(new PluginPackage(path, lastModified));
- package->m_name = name;
- package->m_description = description;
- package->determineModuleVersionFromDescription();
- package->setMIMEDescription(mimeDescription);
- package->m_infoIsFromCache = true;
- return package.release();
-}
-#endif
-
-#if defined(XP_UNIX)
-void PluginPackage::determineQuirks(const String& mimeType)
-{
- if (MIMETypeRegistry::isJavaAppletMIMEType(mimeType)) {
- // Because a single process cannot create multiple VMs, and we cannot reliably unload a
- // Java VM, we cannot unload the Java plugin, or we'll lose reference to our only VM
- m_quirks.add(PluginQuirkDontUnloadPlugin);
-
- // Setting the window region to an empty region causes bad scrolling repaint problems
- // with the Java plug-in.
- m_quirks.add(PluginQuirkDontClipToZeroRectWhenScrolling);
- return;
- }
-
- if (mimeType == "application/x-shockwave-flash") {
- static const PlatformModuleVersion flashTenVersion(0x0a000000);
-
- if (compareFileVersion(flashTenVersion) >= 0) {
- // Flash 10.0 b218 doesn't like having a NULL window handle
- m_quirks.add(PluginQuirkDontSetNullWindowHandleOnDestroy);
- } else {
- // Flash 9 and older requests windowless plugins if we return a mozilla user agent
- m_quirks.add(PluginQuirkWantsMozillaUserAgent);
- }
-
-#if CPU(X86_64)
- // 64-bit Flash freezes if right-click is sent in windowless mode
- m_quirks.add(PluginQuirkIgnoreRightClickInWindowlessMode);
-#endif
-
- m_quirks.add(PluginQuirkRequiresDefaultScreenDepth);
- m_quirks.add(PluginQuirkThrottleInvalidate);
- m_quirks.add(PluginQuirkThrottleWMUserPlusOneMessages);
- m_quirks.add(PluginQuirkFlashURLNotifyBug);
- }
-}
-#endif
-
-#if !OS(WINDOWS)
-void PluginPackage::determineModuleVersionFromDescription()
-{
- // It's a bit lame to detect the plugin version by parsing it
- // from the plugin description string, but it doesn't seem that
- // version information is available in any standardized way at
- // the module level, like in Windows
-
- if (m_description.isEmpty())
- return;
-
- if (m_description.startsWith("Shockwave Flash") && m_description.length() >= 19) {
- // The flash version as a PlatformModuleVersion differs on Unix from Windows
- // since the revision can be larger than a 8 bits, so we allow it 16 here and
- // push the major/minor up 8 bits. Thus on Unix, Flash's version may be
- // 0x0a000000 instead of 0x000a0000.
-
- Vector<String> versionParts;
- m_description.substring(16).split(' ', /*allowEmptyEntries =*/ false, versionParts);
- if (versionParts.isEmpty())
- return;
-
- if (versionParts.size() >= 1) {
- Vector<String> majorMinorParts;
- versionParts[0].split('.', majorMinorParts);
- if (majorMinorParts.size() >= 1) {
- bool converted = false;
- unsigned major = majorMinorParts[0].toUInt(&converted);
- if (converted)
- m_moduleVersion = (major & 0xff) << 24;
- }
- if (majorMinorParts.size() == 2) {
- bool converted = false;
- unsigned minor = majorMinorParts[1].toUInt(&converted);
- if (converted)
- m_moduleVersion |= (minor & 0xff) << 16;
- }
- }
-
- if (versionParts.size() >= 2) {
- String revision = versionParts[1];
- if (revision.length() > 1 && (revision[0] == 'r' || revision[0] == 'b')) {
- revision.remove(0, 1);
- m_moduleVersion |= revision.toInt() & 0xffff;
- }
- }
- }
-}
-#endif
-
-#if ENABLE(NETSCAPE_PLUGIN_API)
-static void getListFromVariantArgs(JSC::ExecState* exec, const NPVariant* args, unsigned argCount, JSC::Bindings::RootObject* rootObject, JSC::MarkedArgumentBuffer& aList)
-{
- for (unsigned i = 0; i < argCount; ++i)
- aList.append(JSC::Bindings::convertNPVariantToValue(exec, &args[i], rootObject));
-}
-
-static inline JSC::SourceCode makeSource(const String& source, const String& url = String(), const TextPosition& startPosition = TextPosition::minimumPosition())
-{
- return JSC::SourceCode(JSC::StringSourceProvider::create(source, url, startPosition), startPosition.m_line.oneBasedInt(), startPosition.m_column.oneBasedInt());
-}
-
-static bool NPN_Evaluate(NPP instance, NPObject* o, NPString* s, NPVariant* variant)
-{
- if (o->_class == NPScriptObjectClass) {
- JavaScriptObject* obj = reinterpret_cast<JavaScriptObject*>(o);
-
- JSC::Bindings::RootObject* rootObject = obj->rootObject;
- if (!rootObject || !rootObject->isValid())
- return false;
-
- // There is a crash in Flash when evaluating a script that destroys the
- // PluginView, so we destroy it asynchronously.
- PluginView::keepAlive(instance);
-
- JSC::ExecState* exec = rootObject->globalObject()->globalExec();
- JSC::JSLockHolder lock(exec);
- String scriptString = JSC::Bindings::convertNPStringToUTF16(s);
-
- JSC::JSValue returnValue = JSC::evaluate(rootObject->globalObject()->globalExec(), makeSource(scriptString), JSC::JSValue());
-
- JSC::Bindings::convertValueToNPVariant(exec, returnValue, variant);
- exec->clearException();
- return true;
- }
-
- VOID_TO_NPVARIANT(*variant);
- return false;
-}
-
-static bool NPN_Invoke(NPP npp, NPObject* o, NPIdentifier methodName, const NPVariant* args, uint32_t argCount, NPVariant* result)
-{
- if (o->_class == NPScriptObjectClass) {
- JavaScriptObject* obj = reinterpret_cast<JavaScriptObject*>(o);
-
- IdentifierRep* i = static_cast<IdentifierRep*>(methodName);
- if (!i->isString())
- return false;
-
- // Special case the "eval" method.
- if (methodName == _NPN_GetStringIdentifier("eval")) {
- if (argCount != 1)
- return false;
- if (args[0].type != NPVariantType_String)
- return false;
- return WebCore::NPN_Evaluate(npp, o, const_cast<NPString*>(&args[0].value.stringValue), result);
- }
-
- // Look up the function object.
- JSC::Bindings::RootObject* rootObject = obj->rootObject;
- if (!rootObject || !rootObject->isValid())
- return false;
- JSC::ExecState* exec = rootObject->globalObject()->globalExec();
- JSC::JSLockHolder lock(exec);
- JSC::JSValue function = obj->imp->get(exec, JSC::Bindings::identifierFromNPIdentifier(exec, i->string()));
- JSC::CallData callData;
- JSC::CallType callType = getCallData(function, callData);
- if (callType == JSC::CallTypeNone)
- return false;
-
- // Call the function object.
- JSC::MarkedArgumentBuffer argList;
- getListFromVariantArgs(exec, args, argCount, rootObject, argList);
- JSC::JSValue resultV = JSC::call(exec, function, callType, callData, obj->imp, argList);
-
- // Convert and return the result of the function call.
- JSC::Bindings::convertValueToNPVariant(exec, resultV, result);
- exec->clearException();
- return true;
- }
-
- if (o->_class->invoke)
- return o->_class->invoke(o, methodName, args, argCount, result);
-
- VOID_TO_NPVARIANT(*result);
- return true;
-}
-
-void PluginPackage::initializeBrowserFuncs()
-{
- memset(&m_browserFuncs, 0, sizeof(m_browserFuncs));
- m_browserFuncs.size = sizeof(m_browserFuncs);
- m_browserFuncs.version = NPVersion();
-
- m_browserFuncs.geturl = NPN_GetURL;
- m_browserFuncs.posturl = NPN_PostURL;
- m_browserFuncs.requestread = NPN_RequestRead;
- m_browserFuncs.newstream = NPN_NewStream;
- m_browserFuncs.write = NPN_Write;
- m_browserFuncs.destroystream = NPN_DestroyStream;
- m_browserFuncs.status = NPN_Status;
- m_browserFuncs.uagent = NPN_UserAgent;
- m_browserFuncs.memalloc = NPN_MemAlloc;
- m_browserFuncs.memfree = NPN_MemFree;
- m_browserFuncs.memflush = NPN_MemFlush;
- m_browserFuncs.reloadplugins = NPN_ReloadPlugins;
- m_browserFuncs.geturlnotify = NPN_GetURLNotify;
- m_browserFuncs.posturlnotify = NPN_PostURLNotify;
- m_browserFuncs.getvalue = NPN_GetValue;
- m_browserFuncs.setvalue = NPN_SetValue;
- m_browserFuncs.invalidaterect = NPN_InvalidateRect;
- m_browserFuncs.invalidateregion = NPN_InvalidateRegion;
- m_browserFuncs.forceredraw = NPN_ForceRedraw;
- m_browserFuncs.getJavaEnv = NPN_GetJavaEnv;
- m_browserFuncs.getJavaPeer = NPN_GetJavaPeer;
- m_browserFuncs.pushpopupsenabledstate = NPN_PushPopupsEnabledState;
- m_browserFuncs.poppopupsenabledstate = NPN_PopPopupsEnabledState;
- m_browserFuncs.pluginthreadasynccall = NPN_PluginThreadAsyncCall;
-
- m_browserFuncs.releasevariantvalue = _NPN_ReleaseVariantValue;
- m_browserFuncs.getstringidentifier = _NPN_GetStringIdentifier;
- m_browserFuncs.getstringidentifiers = _NPN_GetStringIdentifiers;
- m_browserFuncs.getintidentifier = _NPN_GetIntIdentifier;
- m_browserFuncs.identifierisstring = _NPN_IdentifierIsString;
- m_browserFuncs.utf8fromidentifier = _NPN_UTF8FromIdentifier;
- m_browserFuncs.intfromidentifier = _NPN_IntFromIdentifier;
- m_browserFuncs.createobject = _NPN_CreateObject;
- m_browserFuncs.retainobject = _NPN_RetainObject;
- m_browserFuncs.releaseobject = _NPN_ReleaseObject;
- m_browserFuncs.invoke = WebCore::NPN_Invoke;
- m_browserFuncs.invokeDefault = _NPN_InvokeDefault;
- m_browserFuncs.evaluate = WebCore::NPN_Evaluate;
- m_browserFuncs.getproperty = _NPN_GetProperty;
- m_browserFuncs.setproperty = _NPN_SetProperty;
- m_browserFuncs.removeproperty = _NPN_RemoveProperty;
- m_browserFuncs.hasproperty = _NPN_HasProperty;
- m_browserFuncs.hasmethod = _NPN_HasMethod;
- m_browserFuncs.setexception = _NPN_SetException;
- m_browserFuncs.enumerate = _NPN_Enumerate;
- m_browserFuncs.construct = _NPN_Construct;
- m_browserFuncs.getvalueforurl = NPN_GetValueForURL;
- m_browserFuncs.setvalueforurl = NPN_SetValueForURL;
- m_browserFuncs.getauthenticationinfo = NPN_GetAuthenticationInfo;
-
- m_browserFuncs.popupcontextmenu = NPN_PopUpContextMenu;
-}
-#endif // ENABLE(NETSCAPE_PLUGIN_API)
-
-#if ENABLE(PLUGIN_PACKAGE_SIMPLE_HASH)
-unsigned PluginPackage::hash() const
-{
- struct HashCodes {
- unsigned hash;
- time_t modifiedDate;
- } hashCodes;
-
- hashCodes.hash = m_path.impl()->hash();
- hashCodes.modifiedDate = m_lastModified;
-
- return StringHasher::hashMemory<sizeof(hashCodes)>(&hashCodes);
-}
-
-bool PluginPackage::equal(const PluginPackage& a, const PluginPackage& b)
-{
- return a.m_description == b.m_description;
-}
-#endif
-
-int PluginPackage::compareFileVersion(const PlatformModuleVersion& compareVersion) const
-{
- // return -1, 0, or 1 if plug-in version is less than, equal to, or greater than
- // the passed version
-
-#if OS(WINDOWS)
- if (m_moduleVersion.mostSig != compareVersion.mostSig)
- return m_moduleVersion.mostSig > compareVersion.mostSig ? 1 : -1;
- if (m_moduleVersion.leastSig != compareVersion.leastSig)
- return m_moduleVersion.leastSig > compareVersion.leastSig ? 1 : -1;
-#else
- if (m_moduleVersion != compareVersion)
- return m_moduleVersion > compareVersion ? 1 : -1;
-#endif
-
- return 0;
-}
-
-#if ENABLE(NETSCAPE_PLUGIN_METADATA_CACHE)
-bool PluginPackage::ensurePluginLoaded()
-{
- if (!m_infoIsFromCache)
- return m_isLoaded;
-
- m_quirks = PluginQuirkSet();
- m_name = String();
- m_description = String();
- m_fullMIMEDescription = String();
- m_moduleVersion = 0;
-
- return fetchInfo();
-}
-#endif
-
-}
</del></span></pre></div>
<a id="trunkSourceWebCorepluginsPluginPackageh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/plugins/PluginPackage.h (178218 => 178219)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/plugins/PluginPackage.h        2015-01-10 00:09:59 UTC (rev 178218)
+++ trunk/Source/WebCore/plugins/PluginPackage.h        2015-01-10 00:16:52 UTC (rev 178219)
</span><span class="lines">@@ -1,149 +0,0 @@
</span><del>-/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- * Copyright (C) 2008 Collabora, Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef PluginPackage_h
-#define PluginPackage_h
-
-#include "FileSystem.h"
-#include "PluginQuirkSet.h"
-#include "Timer.h"
-#if ENABLE(NETSCAPE_PLUGIN_API)
-#include "npruntime_internal.h"
-#endif
-#include <wtf/HashMap.h>
-#include <wtf/RefCounted.h>
-#include <wtf/text/StringHash.h>
-#include <wtf/text/WTFString.h>
-
-namespace WebCore {
- typedef HashMap<String, String> MIMEToDescriptionsMap;
- typedef HashMap<String, Vector<String> > MIMEToExtensionsMap;
-
- class PluginPackage : public RefCounted<PluginPackage> {
- public:
- ~PluginPackage();
- static PassRefPtr<PluginPackage> createPackage(const String& path, const time_t& lastModified);
-#if ENABLE(NETSCAPE_PLUGIN_METADATA_CACHE)
- static PassRefPtr<PluginPackage> createPackageFromCache(const String& path, const time_t& lastModified, const String& name, const String& description, const String& mimeDescription);
-#endif
-
- const String& name() const { return m_name; }
- const String& description() const { return m_description; }
- const String& path() const { return m_path; }
- const String& fileName() const { return m_fileName; }
- const String& parentDirectory() const { return m_parentDirectory; }
- PlatformModule module() const { return m_module; }
- uint16_t NPVersion() const;
- time_t lastModified() const { return m_lastModified; }
-
- const MIMEToDescriptionsMap& mimeToDescriptions() const { return m_mimeToDescriptions; }
- const MIMEToExtensionsMap& mimeToExtensions() const { return m_mimeToExtensions; }
-
- unsigned hash() const;
- static bool equal(const PluginPackage& a, const PluginPackage& b);
-
- bool load();
- void unload();
- void unloadWithoutShutdown();
-
- bool isEnabled() const { return m_isEnabled; }
- void setEnabled(bool);
-
-#if ENABLE(NETSCAPE_PLUGIN_API)
- const NPPluginFuncs* pluginFuncs() const { return &m_pluginFuncs; }
-#endif
- int compareFileVersion(const PlatformModuleVersion&) const;
- int compare(const PluginPackage&) const;
- PluginQuirkSet quirks() const { return m_quirks; }
- const PlatformModuleVersion& version() const { return m_moduleVersion; }
-
-#if ENABLE(NETSCAPE_PLUGIN_METADATA_CACHE)
- bool ensurePluginLoaded();
- void setMIMEDescription(const String& mimeDescription);
- String fullMIMEDescription() const { return m_fullMIMEDescription;}
-#endif
- private:
- PluginPackage(const String& path, const time_t& lastModified);
-
- bool fetchInfo();
- bool isPluginBlacklisted();
- void determineQuirks(const String& mimeType);
-
- void determineModuleVersionFromDescription();
- void initializeBrowserFuncs();
-
- bool m_isEnabled;
- bool m_isLoaded;
- int m_loadCount;
-
- String m_description;
- String m_path;
- String m_fileName;
- String m_name;
- String m_parentDirectory;
-
- PlatformModuleVersion m_moduleVersion;
-
- MIMEToDescriptionsMap m_mimeToDescriptions;
- MIMEToExtensionsMap m_mimeToExtensions;
-
- PlatformModule m_module;
- time_t m_lastModified;
-
-#if ENABLE(NETSCAPE_PLUGIN_API)
- NPP_ShutdownProcPtr m_NPP_Shutdown;
- NPPluginFuncs m_pluginFuncs;
- NPNetscapeFuncs m_browserFuncs;
-#endif
-
- void freeLibrarySoon();
- void freeLibraryTimerFired();
- Timer m_freeLibraryTimer;
-
- PluginQuirkSet m_quirks;
-#if ENABLE(NETSCAPE_PLUGIN_METADATA_CACHE)
- String m_fullMIMEDescription;
- bool m_infoIsFromCache;
-#endif
- };
-
- // FIXME: This is a workaround because PluginPackageHash is broken and may consider keys with different hashes as equal.
- struct PluginPackageHashTraits : HashTraits<RefPtr<PluginPackage> > {
- static const int minimumTableSize = 64;
- };
-
- struct PluginPackageHash {
- static unsigned hash(const uintptr_t key) { return reinterpret_cast<PluginPackage*>(key)->hash(); }
- static unsigned hash(const RefPtr<PluginPackage>& key) { return key->hash(); }
-
- static bool equal(const uintptr_t a, const uintptr_t b) { return equal(reinterpret_cast<PluginPackage*>(a), reinterpret_cast<PluginPackage*>(b)); }
- static bool equal(const RefPtr<PluginPackage>& a, const RefPtr<PluginPackage>& b) { return PluginPackage::equal(*a.get(), *b.get()); }
- static const bool safeToCompareToEmptyOrDeleted = false;
- };
-
-} // namespace WebCore
-
-#endif
</del></span></pre></div>
<a id="trunkSourceWebCorepluginsPluginQuirkSeth"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/plugins/PluginQuirkSet.h (178218 => 178219)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/plugins/PluginQuirkSet.h        2015-01-10 00:09:59 UTC (rev 178218)
+++ trunk/Source/WebCore/plugins/PluginQuirkSet.h        2015-01-10 00:16:52 UTC (rev 178219)
</span><span class="lines">@@ -1,66 +0,0 @@
</span><del>-/*
- * Copyright (C) 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef PluginQuirkSet_h
-#define PluginQuirkSet_h
-
-
-namespace WebCore {
-
- enum PluginQuirk {
- PluginQuirkWantsMozillaUserAgent = 1 << 0,
- PluginQuirkDeferFirstSetWindowCall = 1 << 1,
- PluginQuirkThrottleInvalidate = 1 << 2,
- PluginQuirkRemoveWindowlessVideoParam = 1 << 3,
- PluginQuirkThrottleWMUserPlusOneMessages = 1 << 4,
- PluginQuirkDontUnloadPlugin = 1 << 5,
- PluginQuirkDontCallWndProcForSameMessageRecursively = 1 << 6,
- PluginQuirkHasModalMessageLoop = 1 << 7,
- PluginQuirkFlashURLNotifyBug = 1 << 8,
- PluginQuirkDontClipToZeroRectWhenScrolling = 1 << 9,
- PluginQuirkDontSetNullWindowHandleOnDestroy = 1 << 10,
- PluginQuirkDontAllowMultipleInstances = 1 << 11,
- PluginQuirkRequiresGtkToolKit = 1 << 12,
- PluginQuirkRequiresDefaultScreenDepth = 1 << 13,
- PluginQuirkDontCallSetWindowMoreThanOnce = 1 << 14,
- PluginQuirkIgnoreRightClickInWindowlessMode = 1 << 15,
- PluginQuirkWantsChromeUserAgent = 1 << 16
- };
-
- class PluginQuirkSet {
- public:
- PluginQuirkSet() : m_quirks(0) { }
- void add(PluginQuirk quirk) { m_quirks |= quirk; }
- bool contains(PluginQuirk quirk) const { return m_quirks & quirk; }
- private:
- unsigned m_quirks;
- };
-
-} // namespace WebCore
-
-#endif // PluginQuirkSet_h
</del></span></pre></div>
<a id="trunkSourceWebCorepluginsPluginStreamcpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/plugins/PluginStream.cpp (178218 => 178219)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/plugins/PluginStream.cpp        2015-01-10 00:09:59 UTC (rev 178218)
+++ trunk/Source/WebCore/plugins/PluginStream.cpp        2015-01-10 00:16:52 UTC (rev 178219)
</span><span class="lines">@@ -1,482 +0,0 @@
</span><del>-/*
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
- * Copyright (C) 2008 Collabora, Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "PluginStream.h"
-
-#include "DocumentLoader.h"
-#include "Frame.h"
-#include "FrameLoader.h"
-#include "HTTPHeaderNames.h"
-#include "PluginDebug.h"
-#include "ResourceLoadScheduler.h"
-#include "SharedBuffer.h"
-#include "SubresourceLoader.h"
-#include <wtf/StringExtras.h>
-#include <wtf/text/CString.h>
-#include <wtf/text/StringBuilder.h>
-#include <wtf/text/WTFString.h>
-
-// We use -2 here because some plugins like to return -1 to indicate error
-// and this way we won't clash with them.
-static const int WebReasonNone = -2;
-
-using std::max;
-using std::min;
-
-namespace WebCore {
-
-typedef HashMap<NPStream*, NPP> StreamMap;
-static StreamMap& streams()
-{
- static StreamMap staticStreams;
- return staticStreams;
-}
-
-PluginStream::PluginStream(PluginStreamClient* client, Frame* frame, const ResourceRequest& resourceRequest, bool sendNotification, void* notifyData, const NPPluginFuncs* pluginFuncs, NPP instance, const PluginQuirkSet& quirks)
- : m_resourceRequest(resourceRequest)
- , m_client(client)
- , m_frame(frame)
- , m_notifyData(notifyData)
- , m_sendNotification(sendNotification)
- , m_streamState(StreamBeforeStarted)
- , m_loadManually(false)
- , m_delayDeliveryTimer(*this, &PluginStream::delayDeliveryTimerFired)
- , m_tempFileHandle(invalidPlatformFileHandle)
- , m_pluginFuncs(pluginFuncs)
- , m_instance(instance)
- , m_quirks(quirks)
-{
- ASSERT(m_instance);
-
- m_stream.url = 0;
- m_stream.ndata = 0;
- m_stream.pdata = 0;
- m_stream.end = 0;
- m_stream.notifyData = 0;
- m_stream.lastmodified = 0;
- m_stream.headers = 0;
-
- streams().add(&m_stream, m_instance);
-}
-
-PluginStream::~PluginStream()
-{
- ASSERT(m_streamState != StreamStarted);
- ASSERT(!m_loader);
-
- fastFree((char*)m_stream.url);
-
- streams().remove(&m_stream);
-}
-
-void PluginStream::start()
-{
- ASSERT(!m_loadManually);
- m_loader = resourceLoadScheduler()->schedulePluginStreamLoad(m_frame, this, m_resourceRequest);
-}
-
-void PluginStream::stop()
-{
- m_streamState = StreamStopped;
-
- if (m_loadManually) {
- ASSERT(!m_loader);
-
- DocumentLoader* documentLoader = m_frame->loader().activeDocumentLoader();
- ASSERT(documentLoader);
-
- if (documentLoader->isLoadingMainResource())
- documentLoader->cancelMainResourceLoad(m_frame->loader().cancelledError(m_resourceRequest));
-
- return;
- }
-
- if (m_loader) {
- m_loader->cancel();
- m_loader = 0;
- }
-
- m_client = 0;
-}
-
-static uint32_t lastModifiedDate(const ResourceResponse& response)
-{
- double lastModified = response.lastModified();
- if (!std::isfinite(lastModified))
- return 0;
-
- return lastModified * 1000;
-}
-
-void PluginStream::startStream()
-{
- ASSERT(m_streamState == StreamBeforeStarted);
-
- const URL& responseURL = m_resourceResponse.url();
-
- // Some plugins (Flash) expect that javascript URLs are passed back decoded as this is the
- // format used when requesting the URL.
- if (protocolIsJavaScript(responseURL))
- m_stream.url = fastStrDup(decodeURLEscapeSequences(responseURL.string()).utf8().data());
- else
- m_stream.url = fastStrDup(responseURL.string().utf8().data());
-
- CString mimeTypeStr = m_resourceResponse.mimeType().utf8();
-
- long long expectedContentLength = m_resourceResponse.expectedContentLength();
-
- if (m_resourceResponse.isHTTP()) {
- StringBuilder stringBuilder;
- String separator = ASCIILiteral(": ");
-
- String statusLine = "HTTP " + String::number(m_resourceResponse.httpStatusCode()) + " OK\n";
- stringBuilder.append(statusLine);
-
- HTTPHeaderMap::const_iterator end = m_resourceResponse.httpHeaderFields().end();
- for (HTTPHeaderMap::const_iterator it = m_resourceResponse.httpHeaderFields().begin(); it != end; ++it) {
- stringBuilder.append(it->key);
- stringBuilder.append(separator);
- stringBuilder.append(it->value);
- stringBuilder.append('\n');
- }
-
- m_headers = stringBuilder.toString().utf8();
-
- // If the content is encoded (most likely compressed), then don't send its length to the plugin,
- // which is only interested in the decoded length, not yet known at the moment.
- // <rdar://problem/4470599> tracks a request for -[NSURLResponse expectedContentLength] to incorporate this logic.
- String contentEncoding = m_resourceResponse.httpHeaderField(HTTPHeaderName::ContentEncoding);
- if (!contentEncoding.isNull() && contentEncoding != "identity")
- expectedContentLength = -1;
- }
-
- m_stream.headers = m_headers.data();
- m_stream.pdata = 0;
- m_stream.ndata = this;
- m_stream.end = max(expectedContentLength, 0LL);
- m_stream.lastmodified = lastModifiedDate(m_resourceResponse);
- m_stream.notifyData = m_notifyData;
-
- m_transferMode = NP_NORMAL;
- m_offset = 0;
- m_reason = WebReasonNone;
-
- // Protect the stream if destroystream is called from within the newstream handler
- RefPtr<PluginStream> protect(this);
-
- // calling into a plug-in could result in re-entrance if the plug-in yields
- // control to the system (rdar://5744899). prevent this by deferring further
- // loading while calling into the plug-in.
- if (m_loader)
- m_loader->setDefersLoading(true);
- NPError npErr = m_pluginFuncs->newstream(m_instance, (NPMIMEType)mimeTypeStr.data(), &m_stream, false, &m_transferMode);
- if (m_loader)
- m_loader->setDefersLoading(false);
-
- // If the stream was destroyed in the call to newstream we return
- if (m_reason != WebReasonNone)
- return;
-
- if (npErr != NPERR_NO_ERROR) {
- cancelAndDestroyStream(npErr);
- return;
- }
-
- m_streamState = StreamStarted;
-
- if (m_transferMode == NP_NORMAL)
- return;
-
- m_path = openTemporaryFile("WKP", m_tempFileHandle);
-
- // Something went wrong, cancel loading the stream
- if (!isHandleValid(m_tempFileHandle))
- cancelAndDestroyStream(NPRES_NETWORK_ERR);
-}
-
-NPP PluginStream::ownerForStream(NPStream* stream)
-{
- return streams().get(stream);
-}
-
-void PluginStream::cancelAndDestroyStream(NPReason reason)
-{
- RefPtr<PluginStream> protect(this);
-
- destroyStream(reason);
- stop();
-}
-
-void PluginStream::destroyStream(NPReason reason)
-{
- m_reason = reason;
- if (m_reason != NPRES_DONE) {
- // Stop any pending data from being streamed
- if (m_deliveryData)
- m_deliveryData->resize(0);
- } else if (m_deliveryData && m_deliveryData->size() > 0) {
- // There is more data to be streamed, don't destroy the stream now.
- return;
- }
- destroyStream();
-}
-
-void PluginStream::destroyStream()
-{
- if (m_streamState == StreamStopped)
- return;
-
- ASSERT(m_reason != WebReasonNone);
- ASSERT(!m_deliveryData || m_deliveryData->size() == 0);
-
- closeFile(m_tempFileHandle);
-
- bool newStreamCalled = m_stream.ndata;
-
- // Protect from destruction if:
- // NPN_DestroyStream is called from NPP_NewStream or
- // PluginStreamClient::streamDidFinishLoading() removes the last reference
- RefPtr<PluginStream> protect(this);
-
- if (newStreamCalled) {
- if (m_reason == NPRES_DONE && (m_transferMode == NP_ASFILE || m_transferMode == NP_ASFILEONLY)) {
- ASSERT(!m_path.isNull());
-
- if (m_loader)
- m_loader->setDefersLoading(true);
- m_pluginFuncs->asfile(m_instance, &m_stream, m_path.utf8().data());
- if (m_loader)
- m_loader->setDefersLoading(false);
- }
-
- if (m_streamState != StreamBeforeStarted) {
- if (m_loader)
- m_loader->setDefersLoading(true);
-
- NPError npErr = m_pluginFuncs->destroystream(m_instance, &m_stream, m_reason);
-
- if (m_loader)
- m_loader->setDefersLoading(false);
-
- LOG_NPERROR(npErr);
- }
-
- m_stream.ndata = 0;
- }
-
- if (m_sendNotification) {
- // Flash 9 can dereference null if we call NPP_URLNotify without first calling NPP_NewStream
- // for requests made with NPN_PostURLNotify; see <rdar://5588807>
- if (m_loader)
- m_loader->setDefersLoading(true);
- if (!newStreamCalled && m_quirks.contains(PluginQuirkFlashURLNotifyBug) &&
- equalIgnoringCase(m_resourceRequest.httpMethod(), "POST")) {
- m_transferMode = NP_NORMAL;
- m_stream.url = "";
- m_stream.notifyData = m_notifyData;
-
- static char emptyMimeType[] = "";
- m_pluginFuncs->newstream(m_instance, emptyMimeType, &m_stream, false, &m_transferMode);
- m_pluginFuncs->destroystream(m_instance, &m_stream, m_reason);
-
- // in successful requests, the URL is dynamically allocated and freed in our
- // destructor, so reset it to 0
- m_stream.url = 0;
- }
- m_pluginFuncs->urlnotify(m_instance, m_resourceRequest.url().string().utf8().data(), m_reason, m_notifyData);
- if (m_loader)
- m_loader->setDefersLoading(false);
- }
-
- m_streamState = StreamStopped;
-
- if (!m_loadManually && m_client)
- m_client->streamDidFinishLoading(this);
-
- if (!m_path.isNull())
- deleteFile(m_path);
-}
-
-void PluginStream::delayDeliveryTimerFired()
-{
- deliverData();
-}
-
-void PluginStream::deliverData()
-{
- ASSERT(m_deliveryData);
-
- if (m_streamState == StreamStopped)
- // FIXME: We should cancel our job in the SubresourceLoader on error so we don't reach this case
- return;
-
- ASSERT(m_streamState != StreamBeforeStarted);
-
- if (!m_stream.ndata || m_deliveryData->size() == 0)
- return;
-
- int32_t totalBytes = m_deliveryData->size();
- int32_t totalBytesDelivered = 0;
-
- if (m_loader)
- m_loader->setDefersLoading(true);
- while (totalBytesDelivered < totalBytes) {
- int32_t deliveryBytes = m_pluginFuncs->writeready(m_instance, &m_stream);
-
- if (deliveryBytes <= 0) {
- m_delayDeliveryTimer.startOneShot(0);
- break;
- } else {
- deliveryBytes = min(deliveryBytes, totalBytes - totalBytesDelivered);
- int32_t dataLength = deliveryBytes;
- char* data = m_deliveryData->data() + totalBytesDelivered;
-
- // Write the data
- deliveryBytes = m_pluginFuncs->write(m_instance, &m_stream, m_offset, dataLength, (void*)data);
- if (deliveryBytes < 0) {
- LOG_PLUGIN_NET_ERROR();
- if (m_loader)
- m_loader->setDefersLoading(false);
- cancelAndDestroyStream(NPRES_NETWORK_ERR);
- return;
- }
- deliveryBytes = min(deliveryBytes, dataLength);
- m_offset += deliveryBytes;
- totalBytesDelivered += deliveryBytes;
- }
- }
- if (m_loader)
- m_loader->setDefersLoading(false);
-
- if (totalBytesDelivered > 0) {
- if (totalBytesDelivered < totalBytes) {
- int remainingBytes = totalBytes - totalBytesDelivered;
- memmove(m_deliveryData->data(), m_deliveryData->data() + totalBytesDelivered, remainingBytes);
- m_deliveryData->resize(remainingBytes);
- } else {
- m_deliveryData->resize(0);
- if (m_reason != WebReasonNone)
- destroyStream();
- }
- }
-}
-
-void PluginStream::sendJavaScriptStream(const URL& requestURL, const CString& resultString)
-{
- didReceiveResponse(0, ResourceResponse(requestURL, "text/plain", resultString.length(), ""));
-
- if (m_streamState == StreamStopped)
- return;
-
- if (!resultString.isNull()) {
- didReceiveData(0, resultString.data(), resultString.length());
- if (m_streamState == StreamStopped)
- return;
- }
-
- m_loader = 0;
-
- destroyStream(resultString.isNull() ? NPRES_NETWORK_ERR : NPRES_DONE);
-}
-
-void PluginStream::didReceiveResponse(NetscapePlugInStreamLoader* loader, const ResourceResponse& response)
-{
- ASSERT_UNUSED(loader, loader == m_loader);
- ASSERT(m_streamState == StreamBeforeStarted);
-
- m_resourceResponse = response;
-
- startStream();
-}
-
-void PluginStream::didReceiveData(NetscapePlugInStreamLoader* loader, const char* data, int length)
-{
- ASSERT_UNUSED(loader, loader == m_loader);
- ASSERT(m_streamState == StreamStarted);
-
- // If the plug-in cancels the stream in deliverData it could be deleted,
- // so protect it here.
- RefPtr<PluginStream> protect(this);
-
- if (m_transferMode != NP_ASFILEONLY) {
- if (!m_deliveryData)
- m_deliveryData = std::make_unique<Vector<char>>();
-
- int oldSize = m_deliveryData->size();
- m_deliveryData->resize(oldSize + length);
- memcpy(m_deliveryData->data() + oldSize, data, length);
-
- deliverData();
- }
-
- if (m_streamState != StreamStopped && isHandleValid(m_tempFileHandle)) {
- int bytesWritten = writeToFile(m_tempFileHandle, data, length);
- if (bytesWritten != length)
- cancelAndDestroyStream(NPRES_NETWORK_ERR);
- }
-}
-
-void PluginStream::didFail(NetscapePlugInStreamLoader* loader, const ResourceError&)
-{
- ASSERT_UNUSED(loader, loader == m_loader);
-
- LOG_PLUGIN_NET_ERROR();
-
- // destroyStream can result in our being deleted
- RefPtr<PluginStream> protect(this);
-
- destroyStream(NPRES_NETWORK_ERR);
-
- m_loader = 0;
-}
-
-void PluginStream::didFinishLoading(NetscapePlugInStreamLoader* loader)
-{
- ASSERT_UNUSED(loader, loader == m_loader);
- ASSERT(m_streamState == StreamStarted);
-
- // destroyStream can result in our being deleted
- RefPtr<PluginStream> protect(this);
-
- destroyStream(NPRES_DONE);
-
- m_loader = 0;
-}
-
-bool PluginStream::wantsAllStreams() const
-{
- if (!m_pluginFuncs->getvalue)
- return false;
-
- void* result = 0;
- if (m_pluginFuncs->getvalue(m_instance, NPPVpluginWantsAllNetworkStreams, &result) != NPERR_NO_ERROR)
- return false;
-
- return result != 0;
-}
-
-}
</del></span></pre></div>
<a id="trunkSourceWebCorepluginsPluginStreamh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/plugins/PluginStream.h (178218 => 178219)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/plugins/PluginStream.h        2015-01-10 00:09:59 UTC (rev 178218)
+++ trunk/Source/WebCore/plugins/PluginStream.h        2015-01-10 00:16:52 UTC (rev 178219)
</span><span class="lines">@@ -1,122 +0,0 @@
</span><del>-/*
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
- * Copyright (C) 2008 Collabora, Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef PluginStream_h
-#define PluginStream_h
-
-#include "FileSystem.h"
-#include "URL.h"
-#include "NetscapePlugInStreamLoader.h"
-#include "PluginQuirkSet.h"
-#include "ResourceRequest.h"
-#include "ResourceResponse.h"
-#include "Timer.h"
-#include "npruntime_internal.h"
-#include <wtf/HashMap.h>
-#include <wtf/RefCounted.h>
-#include <wtf/Vector.h>
-#include <wtf/text/CString.h>
-#include <wtf/text/StringHash.h>
-#include <wtf/text/WTFString.h>
-
-namespace WebCore {
- class Frame;
- class PluginStream;
-
- enum PluginStreamState { StreamBeforeStarted, StreamStarted, StreamStopped };
-
- class PluginStreamClient {
- public:
- virtual ~PluginStreamClient() {}
- virtual void streamDidFinishLoading(PluginStream*) {}
- };
-
- class PluginStream : public RefCounted<PluginStream>, private NetscapePlugInStreamLoaderClient {
- public:
- static PassRefPtr<PluginStream> create(PluginStreamClient* client, Frame* frame, const ResourceRequest& request, bool sendNotification, void* notifyData, const NPPluginFuncs* functions, NPP instance, const PluginQuirkSet& quirks)
- {
- return adoptRef(new PluginStream(client, frame, request, sendNotification, notifyData, functions, instance, quirks));
- }
- virtual ~PluginStream();
-
- void start();
- void stop();
-
- void startStream();
-
- void setLoadManually(bool loadManually) { m_loadManually = loadManually; }
-
- void sendJavaScriptStream(const URL& requestURL, const WTF::CString& resultString);
- void cancelAndDestroyStream(NPReason);
-
- static NPP ownerForStream(NPStream*);
-
- // NetscapePlugInStreamLoaderClient
- virtual void didReceiveResponse(NetscapePlugInStreamLoader*, const ResourceResponse&);
- virtual void didReceiveData(NetscapePlugInStreamLoader*, const char*, int);
- virtual void didFail(NetscapePlugInStreamLoader*, const ResourceError&);
- virtual void didFinishLoading(NetscapePlugInStreamLoader*);
- virtual bool wantsAllStreams() const;
-
- private:
- PluginStream(PluginStreamClient*, Frame*, const ResourceRequest&, bool sendNotification, void* notifyData, const NPPluginFuncs*, NPP instance, const PluginQuirkSet&);
-
- void deliverData();
- void destroyStream(NPReason);
- void destroyStream();
-
- ResourceRequest m_resourceRequest;
- ResourceResponse m_resourceResponse;
-
- PluginStreamClient* m_client;
- Frame* m_frame;
- RefPtr<NetscapePlugInStreamLoader> m_loader;
- void* m_notifyData;
- bool m_sendNotification;
- PluginStreamState m_streamState;
- bool m_loadManually;
-
- Timer m_delayDeliveryTimer;
- void delayDeliveryTimerFired();
-
- std::unique_ptr<Vector<char>> m_deliveryData;
-
- PlatformFileHandle m_tempFileHandle;
-
- const NPPluginFuncs* m_pluginFuncs;
- NPP m_instance;
- uint16_t m_transferMode;
- int32_t m_offset;
- CString m_headers;
- String m_path;
- NPReason m_reason;
- NPStream m_stream;
- PluginQuirkSet m_quirks;
- };
-
-} // namespace WebCore
-
-#endif
</del></span></pre></div>
<a id="trunkSourceWebCorepluginsPluginViewcpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/plugins/PluginView.cpp (178218 => 178219)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/plugins/PluginView.cpp        2015-01-10 00:09:59 UTC (rev 178218)
+++ trunk/Source/WebCore/plugins/PluginView.cpp        2015-01-10 00:16:52 UTC (rev 178219)
</span><span class="lines">@@ -1,1489 +0,0 @@
</span><del>-/*
- * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
- * Copyright (C) 2008 Collabora Ltd. All rights reserved.
- * Copyright (C) 2010 Girish Ramakrishnan <girish@forwardbias.in>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "PluginView.h"
-
-#include "BridgeJSC.h"
-#include "Chrome.h"
-#include "CookieJar.h"
-#include "Document.h"
-#include "DocumentLoader.h"
-#include "Element.h"
-#include "FocusController.h"
-#include "Frame.h"
-#include "FrameLoadRequest.h"
-#include "FrameLoader.h"
-#include "FrameLoaderClient.h"
-#include "FrameTree.h"
-#include "FrameView.h"
-#include "GraphicsContext.h"
-#include "HTMLNames.h"
-#include "HTMLPlugInElement.h"
-#include "HTTPHeaderNames.h"
-#include "Image.h"
-#include "JSDOMBinding.h"
-#include "JSDOMWindow.h"
-#include "KeyboardEvent.h"
-#include "MIMETypeRegistry.h"
-#include "MouseEvent.h"
-#include "NotImplemented.h"
-#include "Page.h"
-#include "PlatformMouseEvent.h"
-#include "PluginDatabase.h"
-#include "PluginDebug.h"
-#include "PluginMainThreadScheduler.h"
-#include "PluginPackage.h"
-#include "ProxyServer.h"
-#include "RenderBox.h"
-#include "RenderObject.h"
-#include "ScriptController.h"
-#include "SecurityOrigin.h"
-#include "Settings.h"
-#include "UserGestureIndicator.h"
-#include "WheelEvent.h"
-#include "c_instance.h"
-#include "npruntime_impl.h"
-#include "runtime_root.h"
-#include <bindings/ScriptValue.h>
-#include <runtime/JSCJSValue.h>
-#include <runtime/JSLock.h>
-#include <wtf/ASCIICType.h>
-#include <wtf/text/WTFString.h>
-
-#if OS(WINDOWS) && ENABLE(NETSCAPE_PLUGIN_API)
-#include "PluginMessageThrottlerWin.h"
-#endif
-
-using JSC::ExecState;
-using JSC::JSLock;
-using JSC::JSObject;
-using JSC::JSValue;
-
-#if ENABLE(NETSCAPE_PLUGIN_API)
-
-using std::min;
-
-using namespace WTF;
-
-namespace WebCore {
-
-using namespace HTMLNames;
-
-static int s_callingPlugin;
-
-typedef HashMap<NPP, PluginView*> InstanceMap;
-
-static InstanceMap& instanceMap()
-{
- static InstanceMap& map = *new InstanceMap;
- return map;
-}
-
-static String scriptStringIfJavaScriptURL(const URL& url)
-{
- if (!protocolIsJavaScript(url))
- return String();
-
- // This returns an unescaped string
- return decodeURLEscapeSequences(url.string().substring(11));
-}
-
-PluginView* PluginView::s_currentPluginView = 0;
-
-void PluginView::popPopupsStateTimerFired()
-{
- popPopupsEnabledState();
-}
-
-IntRect PluginView::windowClipRect() const
-{
- // Start by clipping to our bounds.
- IntRect clipRect(m_windowRect);
-
- // Take our element and get the clip rect from the enclosing layer and frame view.
- FrameView* parentView = m_element->document().view();
- clipRect.intersect(parentView->windowClipRectForFrameOwner(m_element, true));
-
- return clipRect;
-}
-
-void PluginView::setFrameRect(const IntRect& rect)
-{
- if (m_element->document().printing())
- return;
-
- if (rect != frameRect())
- Widget::setFrameRect(rect);
-
- updatePluginWidget();
-
-#if OS(WINDOWS)
- // On Windows always call plugin to change geometry.
- setNPWindowRect(rect);
-#elif defined(XP_UNIX)
- // On Unix, multiple calls to setNPWindow() in windowed mode causes Flash to crash
- if (m_mode == NP_FULL || !m_isWindowed)
- setNPWindowRect(rect);
-#endif
-}
-
-void PluginView::frameRectsChanged()
-{
- updatePluginWidget();
-}
-
-void PluginView::clipRectChanged()
-{
- updatePluginWidget();
-}
-
-void PluginView::handleEvent(Event* event)
-{
- if (!m_plugin || m_isWindowed)
- return;
-
- // Protect the plug-in from deletion while dispatching the event.
- RefPtr<PluginView> protect(this);
-
- if (event->isMouseEvent())
- handleMouseEvent(static_cast<MouseEvent*>(event));
- else if (event->isKeyboardEvent())
- handleKeyboardEvent(static_cast<KeyboardEvent*>(event));
-#if defined(XP_MACOSX)
- else if (event->type() == eventNames().wheelEvent || event->type() == eventNames().mousewheelEvent)
- handleWheelEvent(static_cast<WheelEvent*>(event));
-#endif
- else if (event->type() == eventNames().contextmenuEvent)
- event->setDefaultHandled(); // We don't know if the plug-in has handled mousedown event by displaying a context menu, so we never want WebKit to show a default one.
-#if defined(XP_UNIX) && ENABLE(NETSCAPE_PLUGIN_API)
- else if (event->type() == eventNames().focusoutEvent)
- handleFocusOutEvent();
- else if (event->type() == eventNames().focusinEvent)
- handleFocusInEvent();
-#endif
-}
-
-void PluginView::init()
-{
- if (m_haveInitialized)
- return;
-
- m_haveInitialized = true;
-
- if (!m_plugin) {
- ASSERT(m_status == PluginStatusCanNotFindPlugin);
- return;
- }
-
- LOG(Plugins, "PluginView::init(): Initializing plug-in '%s'", m_plugin->name().utf8().data());
-
- if (!m_plugin->load()) {
- m_plugin = 0;
- m_status = PluginStatusCanNotLoadPlugin;
- return;
- }
-
- if (!startOrAddToUnstartedList()) {
- m_status = PluginStatusCanNotLoadPlugin;
- return;
- }
-
- m_status = PluginStatusLoadedSuccessfully;
-}
-
-bool PluginView::startOrAddToUnstartedList()
-{
- if (!m_parentFrame->page())
- return false;
-
- // We only delay starting the plug-in if we're going to kick off the load
- // ourselves. Otherwise, the loader will try to deliver data before we've
- // started the plug-in.
- if (!m_loadManually && !m_parentFrame->page()->canStartMedia()) {
- m_parentFrame->document()->addMediaCanStartListener(this);
- m_isWaitingToStart = true;
- return true;
- }
-
- return start();
-}
-
-bool PluginView::start()
-{
- if (m_isStarted)
- return false;
-
- m_isWaitingToStart = false;
-
- PluginMainThreadScheduler::scheduler().registerPlugin(m_instance);
-
- ASSERT(m_plugin);
- ASSERT(m_plugin->pluginFuncs()->newp);
-
- NPError npErr;
- {
- PluginView::setCurrentPluginView(this);
- JSC::JSLock::DropAllLocks dropAllLocks(JSDOMWindowBase::commonVM());
- setCallingPlugin(true);
- npErr = m_plugin->pluginFuncs()->newp((NPMIMEType)m_mimeType.utf8().data(), m_instance, m_mode, m_paramCount, m_paramNames, m_paramValues, NULL);
- setCallingPlugin(false);
- LOG_NPERROR(npErr);
- PluginView::setCurrentPluginView(0);
- }
-
- if (npErr != NPERR_NO_ERROR) {
- m_status = PluginStatusCanNotLoadPlugin;
- PluginMainThreadScheduler::scheduler().unregisterPlugin(m_instance);
- return false;
- }
-
- m_isStarted = true;
-
- if (!m_url.isEmpty() && !m_loadManually) {
- FrameLoadRequest frameLoadRequest(m_parentFrame->document()->securityOrigin());
- frameLoadRequest.resourceRequest().setHTTPMethod("GET");
- frameLoadRequest.resourceRequest().setURL(m_url);
- load(frameLoadRequest, false, 0);
- }
-
- m_status = PluginStatusLoadedSuccessfully;
-
- if (!platformStart())
- m_status = PluginStatusCanNotLoadPlugin;
-
- if (m_status != PluginStatusLoadedSuccessfully)
- return false;
-
- return true;
-}
-
-void PluginView::mediaCanStart()
-{
- ASSERT(!m_isStarted);
- if (!start())
- parentFrame()->loader().client().dispatchDidFailToStartPlugin(this);
-}
-
-PluginView::~PluginView()
-{
- LOG(Plugins, "PluginView::~PluginView()");
-
- ASSERT(!m_lifeSupportTimer.isActive());
-
- // If we failed to find the plug-in, we'll return early in our constructor, and
- // m_instance will be 0.
- if (m_instance)
- instanceMap().remove(m_instance);
-
- if (m_isWaitingToStart)
- m_parentFrame->document()->removeMediaCanStartListener(this);
-
- stop();
-
- freeStringArray(m_paramNames, m_paramCount);
- freeStringArray(m_paramValues, m_paramCount);
-
- platformDestroy();
-
- m_parentFrame->script().cleanupScriptObjectsForPlugin(this);
-
- if (m_plugin && !(m_plugin->quirks().contains(PluginQuirkDontUnloadPlugin)))
- m_plugin->unload();
-}
-
-void PluginView::stop()
-{
- if (!m_isStarted)
- return;
-
- LOG(Plugins, "PluginView::stop(): Stopping plug-in '%s'", m_plugin->name().utf8().data());
-
- HashSet<RefPtr<PluginStream> > streams = m_streams;
- HashSet<RefPtr<PluginStream> >::iterator end = streams.end();
- for (HashSet<RefPtr<PluginStream> >::iterator it = streams.begin(); it != end; ++it) {
- (*it)->stop();
- disconnectStream((*it).get());
- }
-
- ASSERT(m_streams.isEmpty());
-
- m_isStarted = false;
-
- JSC::JSLock::DropAllLocks dropAllLocks(JSDOMWindowBase::commonVM());
-
-#if ENABLE(NETSCAPE_PLUGIN_API)
-#if defined(XP_WIN) && !PLATFORM(GTK)
- // Unsubclass the window
- if (m_isWindowed) {
- WNDPROC currentWndProc = (WNDPROC)GetWindowLongPtr(platformPluginWidget(), GWLP_WNDPROC);
-
- if (currentWndProc == PluginViewWndProc)
- SetWindowLongPtr(platformPluginWidget(), GWLP_WNDPROC, (LONG_PTR)m_pluginWndProc);
- }
-#endif // !defined(XP_WIN) || PLATFORM(GTK)
-#endif // ENABLE(NETSCAPE_PLUGIN_API)
-
-#if !defined(XP_MACOSX)
- // Clear the window
- m_npWindow.window = 0;
-
- if (m_plugin->pluginFuncs()->setwindow && !m_plugin->quirks().contains(PluginQuirkDontSetNullWindowHandleOnDestroy)) {
- PluginView::setCurrentPluginView(this);
- setCallingPlugin(true);
- m_plugin->pluginFuncs()->setwindow(m_instance, &m_npWindow);
- setCallingPlugin(false);
- PluginView::setCurrentPluginView(0);
- }
-
-#ifdef XP_UNIX
- delete static_cast<NPSetWindowCallbackStruct*>(m_npWindow.ws_info);
- m_npWindow.ws_info = 0;
-#endif
-
-#endif // !defined(XP_MACOSX)
-
- PluginMainThreadScheduler::scheduler().unregisterPlugin(m_instance);
-
- NPSavedData* savedData = 0;
- PluginView::setCurrentPluginView(this);
- setCallingPlugin(true);
- NPError npErr = m_plugin->pluginFuncs()->destroy(m_instance, &savedData);
- setCallingPlugin(false);
- LOG_NPERROR(npErr);
- PluginView::setCurrentPluginView(0);
-
-#if ENABLE(NETSCAPE_PLUGIN_API)
- if (savedData) {
- // TODO: Actually save this data instead of just discarding it
- if (savedData->buf)
- NPN_MemFree(savedData->buf);
- NPN_MemFree(savedData);
- }
-#endif
-
- m_instance->pdata = 0;
-}
-
-void PluginView::setCurrentPluginView(PluginView* pluginView)
-{
- s_currentPluginView = pluginView;
-}
-
-PluginView* PluginView::currentPluginView()
-{
- return s_currentPluginView;
-}
-
-static char* createUTF8String(const String& str)
-{
- CString cstr = str.utf8();
- const size_t cstrLength = cstr.length();
- char* result = reinterpret_cast<char*>(fastMalloc(cstrLength + 1));
-
- memcpy(result, cstr.data(), cstrLength);
- result[cstrLength] = '\0';
-
- return result;
-}
-
-void PluginView::performRequest(PluginRequest* request)
-{
- if (!m_isStarted)
- return;
-
- // don't let a plugin start any loads if it is no longer part of a document that is being
- // displayed unless the loads are in the same frame as the plugin.
- const String& targetFrameName = request->frameLoadRequest().frameName();
- if (m_parentFrame->loader().documentLoader() != m_parentFrame->loader().activeDocumentLoader() && (targetFrameName.isNull() || m_parentFrame->tree().find(targetFrameName) != m_parentFrame))
- return;
-
- URL requestURL = request->frameLoadRequest().resourceRequest().url();
- String jsString = scriptStringIfJavaScriptURL(requestURL);
-
- UserGestureIndicator gestureIndicator(request->shouldAllowPopups() ? DefinitelyProcessingUserGesture : PossiblyProcessingUserGesture);
-
- if (jsString.isNull()) {
- // if this is not a targeted request, create a stream for it. otherwise,
- // just pass it off to the loader
- if (targetFrameName.isEmpty()) {
- RefPtr<PluginStream> stream = PluginStream::create(this, m_parentFrame.get(), request->frameLoadRequest().resourceRequest(), request->sendNotification(), request->notifyData(), plugin()->pluginFuncs(), instance(), m_plugin->quirks());
- m_streams.add(stream);
- stream->start();
- } else {
- // If the target frame is our frame, we could destroy the
- // PluginView, so we protect it. <rdar://problem/6991251>
- RefPtr<PluginView> protect(this);
-
- FrameLoadRequest frameRequest(m_parentFrame.get(), request->frameLoadRequest().resourceRequest());
- frameRequest.setFrameName(targetFrameName);
- frameRequest.setShouldCheckNewWindowPolicy(true);
- m_parentFrame->loader().load(frameRequest);
-
- // FIXME: <rdar://problem/4807469> This should be sent when the document has finished loading
- if (request->sendNotification()) {
- PluginView::setCurrentPluginView(this);
- JSC::JSLock::DropAllLocks dropAllLocks(JSDOMWindowBase::commonVM());
- setCallingPlugin(true);
- m_plugin->pluginFuncs()->urlnotify(m_instance, requestURL.string().utf8().data(), NPRES_DONE, request->notifyData());
- setCallingPlugin(false);
- PluginView::setCurrentPluginView(0);
- }
- }
- return;
- }
-
- // Targeted JavaScript requests are only allowed on the frame that contains the JavaScript plugin
- // and this has been made sure in ::load.
- ASSERT(targetFrameName.isEmpty() || m_parentFrame->tree().find(targetFrameName) == m_parentFrame);
-
- // Executing a script can cause the plugin view to be destroyed, so we keep a reference to it.
- RefPtr<PluginView> protector(this);
- Deprecated::ScriptValue result = m_parentFrame->script().executeScript(jsString, request->shouldAllowPopups());
-
- if (targetFrameName.isNull()) {
- String resultString;
-
- JSC::ExecState* scriptState = m_parentFrame->script().globalObject(pluginWorld())->globalExec();
- CString cstr;
- if (result.getString(scriptState, resultString))
- cstr = resultString.utf8();
-
- RefPtr<PluginStream> stream = PluginStream::create(this, m_parentFrame.get(), request->frameLoadRequest().resourceRequest(), request->sendNotification(), request->notifyData(), plugin()->pluginFuncs(), instance(), m_plugin->quirks());
- m_streams.add(stream);
- stream->sendJavaScriptStream(requestURL, cstr);
- }
-}
-
-void PluginView::requestTimerFired()
-{
- ASSERT(!m_requests.isEmpty());
- ASSERT(!m_isJavaScriptPaused);
-
- std::unique_ptr<PluginRequest> request = WTF::move(m_requests[0]);
- m_requests.remove(0);
-
- // Schedule a new request before calling performRequest since the call to
- // performRequest can cause the plugin view to be deleted.
- if (!m_requests.isEmpty())
- m_requestTimer.startOneShot(0);
-
- performRequest(request.get());
-}
-
-void PluginView::scheduleRequest(std::unique_ptr<PluginRequest> request)
-{
- m_requests.append(WTF::move(request));
-
- if (!m_isJavaScriptPaused)
- m_requestTimer.startOneShot(0);
-}
-
-NPError PluginView::load(const FrameLoadRequest& frameLoadRequest, bool sendNotification, void* notifyData)
-{
- ASSERT(frameLoadRequest.resourceRequest().httpMethod() == "GET" || frameLoadRequest.resourceRequest().httpMethod() == "POST");
-
- URL url = frameLoadRequest.resourceRequest().url();
-
- if (url.isEmpty())
- return NPERR_INVALID_URL;
-
- // Don't allow requests to be made when the document loader is stopping all loaders.
- DocumentLoader* loader = m_parentFrame->loader().documentLoader();
- if (!loader || loader->isStopping())
- return NPERR_GENERIC_ERROR;
-
- const String& targetFrameName = frameLoadRequest.frameName();
- String jsString = scriptStringIfJavaScriptURL(url);
-
- if (!jsString.isNull()) {
- // Return NPERR_GENERIC_ERROR if JS is disabled. This is what Mozilla does.
- if (!m_parentFrame->script().canExecuteScripts(NotAboutToExecuteScript))
- return NPERR_GENERIC_ERROR;
-
- // For security reasons, only allow JS requests to be made on the frame that contains the plug-in.
- if (!targetFrameName.isNull() && m_parentFrame->tree().find(targetFrameName) != m_parentFrame)
- return NPERR_INVALID_PARAM;
- } else if (!m_parentFrame->document()->securityOrigin()->canDisplay(url))
- return NPERR_GENERIC_ERROR;
-
- scheduleRequest(std::make_unique<PluginRequest>(frameLoadRequest, sendNotification, notifyData, arePopupsAllowed()));
-
- return NPERR_NO_ERROR;
-}
-
-static URL makeURL(const URL& baseURL, const char* relativeURLString)
-{
- String urlString = relativeURLString;
-
- // Strip return characters.
- urlString.replaceWithLiteral('\n', "");
- urlString.replaceWithLiteral('\r', "");
-
- return URL(baseURL, urlString);
-}
-
-NPError PluginView::getURLNotify(const char* url, const char* target, void* notifyData)
-{
- FrameLoadRequest frameLoadRequest(m_parentFrame->document()->securityOrigin());
-
- frameLoadRequest.setFrameName(target);
- frameLoadRequest.resourceRequest().setHTTPMethod("GET");
- frameLoadRequest.resourceRequest().setURL(makeURL(m_parentFrame->document()->baseURL(), url));
-
- return load(frameLoadRequest, true, notifyData);
-}
-
-NPError PluginView::getURL(const char* url, const char* target)
-{
- FrameLoadRequest frameLoadRequest(m_parentFrame->document()->securityOrigin());
-
- frameLoadRequest.setFrameName(target);
- frameLoadRequest.resourceRequest().setHTTPMethod("GET");
- frameLoadRequest.resourceRequest().setURL(makeURL(m_parentFrame->document()->baseURL(), url));
-
- return load(frameLoadRequest, false, 0);
-}
-
-NPError PluginView::postURLNotify(const char* url, const char* target, uint32_t len, const char* buf, NPBool file, void* notifyData)
-{
- return handlePost(url, target, len, buf, file, notifyData, true, true);
-}
-
-NPError PluginView::postURL(const char* url, const char* target, uint32_t len, const char* buf, NPBool file)
-{
- // As documented, only allow headers to be specified via NPP_PostURL when using a file.
- return handlePost(url, target, len, buf, file, 0, false, file);
-}
-
-NPError PluginView::newStream(NPMIMEType, const char* /* target */, NPStream**)
-{
- notImplemented();
- // Unsupported
- return NPERR_GENERIC_ERROR;
-}
-
-int32_t PluginView::write(NPStream*, int32_t /* len */, void* /* buffer */)
-{
- notImplemented();
- // Unsupported
- return -1;
-}
-
-NPError PluginView::destroyStream(NPStream* stream, NPReason reason)
-{
- if (!stream || PluginStream::ownerForStream(stream) != m_instance)
- return NPERR_INVALID_INSTANCE_ERROR;
-
- PluginStream* browserStream = static_cast<PluginStream*>(stream->ndata);
- browserStream->cancelAndDestroyStream(reason);
-
- return NPERR_NO_ERROR;
-}
-
-void PluginView::status(const char* message)
-{
- if (Page* page = m_parentFrame->page())
- page->chrome().setStatusbarText(m_parentFrame.get(), String::fromUTF8(message));
-}
-
-NPError PluginView::setValue(NPPVariable variable, void* value)
-{
- LOG(Plugins, "PluginView::setValue(%s): ", prettyNameForNPPVariable(variable, value).data());
-
- switch (variable) {
- case NPPVpluginWindowBool:
- m_isWindowed = value;
- return NPERR_NO_ERROR;
- case NPPVpluginTransparentBool:
- m_isTransparent = value;
- return NPERR_NO_ERROR;
-#if defined(XP_MACOSX)
- case NPPVpluginDrawingModel: {
- // Can only set drawing model inside NPP_New()
- if (this != currentPluginView())
- return NPERR_GENERIC_ERROR;
-
- NPDrawingModel newDrawingModel = NPDrawingModel(uintptr_t(value));
- switch (newDrawingModel) {
- case NPDrawingModelCoreGraphics:
- return NPERR_NO_ERROR;
- case NPDrawingModelCoreAnimation:
- default:
- LOG(Plugins, "Plugin asked for unsupported drawing model: %s",
- prettyNameForDrawingModel(newDrawingModel));
- return NPERR_GENERIC_ERROR;
- }
- }
-
- case NPPVpluginEventModel: {
- // Can only set event model inside NPP_New()
- if (this != currentPluginView())
- return NPERR_GENERIC_ERROR;
-
- NPEventModel newEventModel = NPEventModel(uintptr_t(value));
- switch (newEventModel) {
- case NPEventModelCocoa:
- return NPERR_NO_ERROR;
- default:
- LOG(Plugins, "Plugin asked for unsupported event model: %s",
- prettyNameForEventModel(newEventModel));
- return NPERR_GENERIC_ERROR;
- }
- }
-#endif // defined(XP_MACOSX)
-
- default:
- notImplemented();
- return NPERR_GENERIC_ERROR;
- }
-}
-
-void PluginView::invalidateTimerFired()
-{
- for (unsigned i = 0; i < m_invalidRects.size(); i++)
- invalidateRect(m_invalidRects[i]);
- m_invalidRects.clear();
-}
-
-
-void PluginView::pushPopupsEnabledState(bool state)
-{
- m_popupStateStack.append(state);
-}
-
-void PluginView::popPopupsEnabledState()
-{
- m_popupStateStack.removeLast();
-}
-
-bool PluginView::arePopupsAllowed() const
-{
- if (!m_popupStateStack.isEmpty())
- return m_popupStateStack.last();
-
- return false;
-}
-
-void PluginView::setJavaScriptPaused(bool paused)
-{
- if (m_isJavaScriptPaused == paused)
- return;
- m_isJavaScriptPaused = paused;
-
- if (m_isJavaScriptPaused)
- m_requestTimer.stop();
- else if (!m_requests.isEmpty())
- m_requestTimer.startOneShot(0);
-}
-
-#if ENABLE(NETSCAPE_PLUGIN_API)
-NPObject* PluginView::npObject()
-{
- NPObject* object = 0;
-
- if (!m_isStarted || !m_plugin || !m_plugin->pluginFuncs()->getvalue)
- return 0;
-
- // On Windows, calling Java's NPN_GetValue can allow the message loop to
- // run, allowing loading to take place or JavaScript to run. Protect the
- // PluginView from destruction. <rdar://problem/6978804>
- RefPtr<PluginView> protect(this);
-
- NPError npErr;
- {
- PluginView::setCurrentPluginView(this);
- JSC::JSLock::DropAllLocks dropAllLocks(JSDOMWindowBase::commonVM());
- setCallingPlugin(true);
- npErr = m_plugin->pluginFuncs()->getvalue(m_instance, NPPVpluginScriptableNPObject, &object);
- setCallingPlugin(false);
- PluginView::setCurrentPluginView(0);
- }
-
- if (npErr != NPERR_NO_ERROR)
- return 0;
-
- return object;
-}
-#endif
-
-PassRefPtr<JSC::Bindings::Instance> PluginView::bindingInstance()
-{
-#if ENABLE(NETSCAPE_PLUGIN_API)
- NPObject* object = npObject();
- if (!object)
- return 0;
-
- if (hasOneRef()) {
- // The renderer for the PluginView was destroyed during the above call, and
- // the PluginView will be destroyed when this function returns, so we
- // return null.
- return 0;
- }
-
- RefPtr<JSC::Bindings::RootObject> root = m_parentFrame->script().createRootObject(this);
- RefPtr<JSC::Bindings::Instance> instance = JSC::Bindings::CInstance::create(object, root.release());
-
- _NPN_ReleaseObject(object);
-
- return instance.release();
-#else
- return 0;
-#endif
-}
-
-void PluginView::disconnectStream(PluginStream* stream)
-{
- ASSERT(m_streams.contains(stream));
-
- m_streams.remove(stream);
-}
-
-void PluginView::setParameters(const Vector<String>& paramNames, const Vector<String>& paramValues)
-{
- ASSERT(paramNames.size() == paramValues.size());
-
- unsigned size = paramNames.size();
- unsigned paramCount = 0;
-
- m_paramNames = reinterpret_cast<char**>(fastMalloc(sizeof(char*) * size));
- m_paramValues = reinterpret_cast<char**>(fastMalloc(sizeof(char*) * size));
-
- for (unsigned i = 0; i < size; i++) {
- if (m_plugin->quirks().contains(PluginQuirkRemoveWindowlessVideoParam) && equalIgnoringCase(paramNames[i], "windowlessvideo"))
- continue;
-
- if (paramNames[i] == "pluginspage")
- m_pluginsPage = paramValues[i];
-
- m_paramNames[paramCount] = createUTF8String(paramNames[i]);
- m_paramValues[paramCount] = createUTF8String(paramValues[i]);
-
- paramCount++;
- }
-
- m_paramCount = paramCount;
-}
-
-PluginView::PluginView(Frame* parentFrame, const IntSize& size, PluginPackage* plugin, HTMLPlugInElement* element, const URL& url, const Vector<String>& paramNames, const Vector<String>& paramValues, const String& mimeType, bool loadManually)
- : m_parentFrame(parentFrame)
- , m_plugin(plugin)
- , m_element(element)
- , m_isStarted(false)
- , m_url(url)
- , m_status(PluginStatusLoadedSuccessfully)
- , m_requestTimer(*this, &PluginView::requestTimerFired)
- , m_invalidateTimer(*this, &PluginView::invalidateTimerFired)
- , m_popPopupsStateTimer(*this, &PluginView::popPopupsStateTimerFired)
- , m_lifeSupportTimer(*this, &PluginView::lifeSupportTimerFired)
- , m_mode(loadManually ? NP_FULL : NP_EMBED)
- , m_paramNames(0)
- , m_paramValues(0)
- , m_mimeType(mimeType)
- , m_instance(0)
-#if defined(XP_MACOSX)
- , m_isWindowed(false)
- , m_updatedCocoaTextInputRequested(false)
- , m_keyDownSent(false)
- , m_disregardKeyUpCounter(0)
-#else
- , m_isWindowed(true)
-#endif
- , m_isTransparent(false)
- , m_haveInitialized(false)
- , m_isWaitingToStart(false)
-#if defined(XP_UNIX)
- , m_needsXEmbed(false)
-#endif
-#if OS(WINDOWS) && ENABLE(NETSCAPE_PLUGIN_API)
- , m_pluginWndProc(0)
- , m_lastMessage(0)
- , m_isCallingPluginWndProc(false)
- , m_wmPrintHDC(0)
- , m_haveUpdatedPluginWidget(false)
-#endif
-#if PLATFORM(EFL)
- , m_window(0)
-#endif
-#if defined(XP_MACOSX)
- , m_contextRef(0)
-#endif
-#if defined(XP_UNIX) && ENABLE(NETSCAPE_PLUGIN_API)
- , m_hasPendingGeometryChange(true)
- , m_drawable(0)
- , m_visual(0)
- , m_colormap(0)
- , m_pluginDisplay(0)
-#endif
- , m_loadManually(loadManually)
- , m_manualStream(0)
- , m_isJavaScriptPaused(false)
- , m_haveCalledSetWindow(false)
-{
- if (!m_plugin) {
- m_status = PluginStatusCanNotFindPlugin;
- return;
- }
-
- m_instance = &m_instanceStruct;
- m_instance->ndata = this;
- m_instance->pdata = 0;
-
- instanceMap().add(m_instance, this);
-
- setParameters(paramNames, paramValues);
-
- memset(&m_npWindow, 0, sizeof(m_npWindow));
-#if defined(XP_MACOSX)
- memset(&m_npCgContext, 0, sizeof(m_npCgContext));
-#endif
-
- resize(size);
-}
-
-void PluginView::focusPluginElement()
-{
- if (Page* page = m_parentFrame->page())
- page->focusController().setFocusedElement(m_element, m_parentFrame);
- else
- m_parentFrame->document()->setFocusedElement(m_element);
-}
-
-void PluginView::didReceiveResponse(const ResourceResponse& response)
-{
- if (m_status != PluginStatusLoadedSuccessfully)
- return;
-
- ASSERT(m_loadManually);
- ASSERT(!m_manualStream);
-
- m_manualStream = PluginStream::create(this, m_parentFrame.get(), m_parentFrame->loader().activeDocumentLoader()->request(), false, 0, plugin()->pluginFuncs(), instance(), m_plugin->quirks());
- m_manualStream->setLoadManually(true);
-
- m_manualStream->didReceiveResponse(0, response);
-}
-
-void PluginView::didReceiveData(const char* data, int length)
-{
- if (m_status != PluginStatusLoadedSuccessfully)
- return;
-
- ASSERT(m_loadManually);
- ASSERT(m_manualStream);
-
- m_manualStream->didReceiveData(0, data, length);
-}
-
-void PluginView::didFinishLoading()
-{
- if (m_status != PluginStatusLoadedSuccessfully)
- return;
-
- ASSERT(m_loadManually);
- ASSERT(m_manualStream);
-
- m_manualStream->didFinishLoading(0);
-}
-
-void PluginView::didFail(const ResourceError& error)
-{
- if (m_status != PluginStatusLoadedSuccessfully)
- return;
-
- ASSERT(m_loadManually);
-
- if (m_manualStream)
- m_manualStream->didFail(0, error);
-}
-
-void PluginView::setCallingPlugin(bool b) const
-{
- if (!m_plugin->quirks().contains(PluginQuirkHasModalMessageLoop))
- return;
-
- if (b)
- ++s_callingPlugin;
- else
- --s_callingPlugin;
-
- ASSERT(s_callingPlugin >= 0);
-}
-
-bool PluginView::isCallingPlugin()
-{
- return s_callingPlugin > 0;
-}
-
-PassRefPtr<PluginView> PluginView::create(Frame* parentFrame, const IntSize& size, HTMLPlugInElement* element, const URL& url, const Vector<String>& paramNames, const Vector<String>& paramValues, const String& mimeType, bool loadManually)
-{
- // if we fail to find a plugin for this MIME type, findPlugin will search for
- // a plugin by the file extension and update the MIME type, so pass a mutable String
- String mimeTypeCopy = mimeType;
- PluginPackage* plugin = PluginDatabase::installedPlugins()->findPlugin(url, mimeTypeCopy);
-
- // No plugin was found, try refreshing the database and searching again
- if (!plugin && PluginDatabase::installedPlugins()->refresh()) {
- mimeTypeCopy = mimeType;
- plugin = PluginDatabase::installedPlugins()->findPlugin(url, mimeTypeCopy);
- }
-
- return adoptRef(new PluginView(parentFrame, size, plugin, element, url, paramNames, paramValues, mimeTypeCopy, loadManually));
-}
-
-void PluginView::freeStringArray(char** stringArray, int length)
-{
- if (!stringArray)
- return;
-
- for (int i = 0; i < length; i++)
- fastFree(stringArray[i]);
-
- fastFree(stringArray);
-}
-
-static inline bool startsWithBlankLine(const Vector<char>& buffer)
-{
- return buffer.size() > 0 && buffer[0] == '\n';
-}
-
-static inline int locationAfterFirstBlankLine(const Vector<char>& buffer)
-{
- const char* bytes = buffer.data();
- unsigned length = buffer.size();
-
- for (unsigned i = 0; i < length - 4; i++) {
- // Support for Acrobat. It sends "\n\n".
- if (bytes[i] == '\n' && bytes[i + 1] == '\n')
- return i + 2;
-
- // Returns the position after 2 CRLF's or 1 CRLF if it is the first line.
- if (bytes[i] == '\r' && bytes[i + 1] == '\n') {
- i += 2;
- if (i == 2)
- return i;
- else if (bytes[i] == '\n')
- // Support for Director. It sends "\r\n\n" (3880387).
- return i + 1;
- else if (bytes[i] == '\r' && bytes[i + 1] == '\n')
- // Support for Flash. It sends "\r\n\r\n" (3758113).
- return i + 2;
- }
- }
-
- return -1;
-}
-
-static inline const char* findEOL(const char* bytes, unsigned length)
-{
- // According to the HTTP specification EOL is defined as
- // a CRLF pair. Unfortunately, some servers will use LF
- // instead. Worse yet, some servers will use a combination
- // of both (e.g. <header>CRLFLF<body>), so findEOL needs
- // to be more forgiving. It will now accept CRLF, LF or
- // CR.
- //
- // It returns NULL if EOLF is not found or it will return
- // a pointer to the first terminating character.
- for (unsigned i = 0; i < length; i++) {
- if (bytes[i] == '\n')
- return bytes + i;
- if (bytes[i] == '\r') {
- // Check to see if spanning buffer bounds
- // (CRLF is across reads). If so, wait for
- // next read.
- if (i + 1 == length)
- break;
-
- return bytes + i;
- }
- }
-
- return 0;
-}
-
-static inline String capitalizeRFC822HeaderFieldName(const String& name)
-{
- bool capitalizeCharacter = true;
- String result;
-
- for (unsigned i = 0; i < name.length(); i++) {
- UChar c;
-
- if (capitalizeCharacter && name[i] >= 'a' && name[i] <= 'z')
- c = toASCIIUpper(name[i]);
- else if (!capitalizeCharacter && name[i] >= 'A' && name[i] <= 'Z')
- c = toASCIILower(name[i]);
- else
- c = name[i];
-
- if (name[i] == '-')
- capitalizeCharacter = true;
- else
- capitalizeCharacter = false;
-
- result.append(c);
- }
-
- return result;
-}
-
-static inline HTTPHeaderMap parseRFC822HeaderFields(const Vector<char>& buffer, unsigned length)
-{
- const char* bytes = buffer.data();
- const char* eol;
- String lastKey;
- HTTPHeaderMap headerFields;
-
- // Loop ove rlines until we're past the header, or we can't find any more end-of-lines
- while ((eol = findEOL(bytes, length))) {
- const char* line = bytes;
- int lineLength = eol - bytes;
-
- // Move bytes to the character after the terminator as returned by findEOL.
- bytes = eol + 1;
- if ((*eol == '\r') && (*bytes == '\n'))
- bytes++; // Safe since findEOL won't return a spanning CRLF.
-
- length -= (bytes - line);
- if (lineLength == 0)
- // Blank line; we're at the end of the header
- break;
- else if (*line == ' ' || *line == '\t') {
- // Continuation of the previous header
- if (lastKey.isNull()) {
- // malformed header; ignore it and continue
- continue;
- } else {
- // Merge the continuation of the previous header
- String currentValue = headerFields.get(lastKey);
- String newValue(line, lineLength);
-
- headerFields.set(lastKey, currentValue + newValue);
- }
- } else {
- // Brand new header
- const char* colon;
- for (colon = line; *colon != ':' && colon != eol; colon++) {
- // empty loop
- }
- if (colon == eol)
- // malformed header; ignore it and continue
- continue;
- else {
- lastKey = capitalizeRFC822HeaderFieldName(String(line, colon - line));
- String value;
-
- for (colon++; colon != eol; colon++) {
- if (*colon != ' ' && *colon != '\t')
- break;
- }
- if (colon == eol)
- value = "";
- else
- value = String(colon, eol - colon);
-
- String oldValue = headerFields.get(lastKey);
- if (!oldValue.isNull())
- value = oldValue + ", " + value;
-
- headerFields.set(lastKey, value);
- }
- }
- }
-
- return headerFields;
-}
-
-NPError PluginView::handlePost(const char* url, const char* target, uint32_t len, const char* buf, bool file, void* notifyData, bool sendNotification, bool allowHeaders)
-{
- if (!url || !len || !buf)
- return NPERR_INVALID_PARAM;
-
- FrameLoadRequest frameLoadRequest(m_parentFrame->document()->securityOrigin());
-
- HTTPHeaderMap headerFields;
- Vector<char> buffer;
-
- if (file) {
- NPError readResult = handlePostReadFile(buffer, len, buf);
- if(readResult != NPERR_NO_ERROR)
- return readResult;
- } else {
- buffer.resize(len);
- memcpy(buffer.data(), buf, len);
- }
-
- const char* postData = buffer.data();
- int postDataLength = buffer.size();
-
- if (allowHeaders) {
- if (startsWithBlankLine(buffer)) {
- postData++;
- postDataLength--;
- } else {
- int location = locationAfterFirstBlankLine(buffer);
- if (location != -1) {
- // If the blank line is somewhere in the middle of the buffer, everything before is the header
- headerFields = parseRFC822HeaderFields(buffer, location);
- unsigned dataLength = buffer.size() - location;
-
- // Sometimes plugins like to set Content-Length themselves when they post,
- // but WebFoundation does not like that. So we will remove the header
- // and instead truncate the data to the requested length.
- String contentLength = headerFields.get(HTTPHeaderName::ContentLength);
-
- if (!contentLength.isNull())
- dataLength = min(contentLength.toInt(), (int)dataLength);
- headerFields.remove(HTTPHeaderName::ContentLength);
-
- postData += location;
- postDataLength = dataLength;
- }
- }
- }
-
- frameLoadRequest.resourceRequest().setHTTPMethod("POST");
- frameLoadRequest.resourceRequest().setURL(makeURL(m_parentFrame->document()->baseURL(), url));
- frameLoadRequest.resourceRequest().setHTTPHeaderFields(WTF::move(headerFields));
- frameLoadRequest.resourceRequest().setHTTPBody(FormData::create(postData, postDataLength));
- frameLoadRequest.setFrameName(target);
-
- return load(frameLoadRequest, sendNotification, notifyData);
-}
-
-void PluginView::invalidateWindowlessPluginRect(const IntRect& rect)
-{
- if (!isVisible())
- return;
-
- if (!m_element->renderer())
- return;
- auto& renderer = downcast<RenderBox>(*m_element->renderer());
-
- IntRect dirtyRect = rect;
- dirtyRect.move(renderer.borderLeft() + renderer.paddingLeft(), renderer.borderTop() + renderer.paddingTop());
- renderer.repaintRectangle(dirtyRect);
-}
-
-void PluginView::paintMissingPluginIcon(GraphicsContext* context, const IntRect& rect)
-{
- static RefPtr<Image> nullPluginImage;
- if (!nullPluginImage)
- nullPluginImage = Image::loadPlatformResource("nullPlugin");
-
- IntRect imageRect(frameRect().x(), frameRect().y(), nullPluginImage->width(), nullPluginImage->height());
-
- int xOffset = (frameRect().width() - imageRect.width()) / 2;
- int yOffset = (frameRect().height() - imageRect.height()) / 2;
-
- imageRect.move(xOffset, yOffset);
-
- if (!rect.intersects(imageRect))
- return;
-
- context->save();
- context->clip(windowClipRect());
- context->drawImage(nullPluginImage.get(), ColorSpaceDeviceRGB, imageRect.location());
- context->restore();
-}
-
-static const char* MozillaUserAgent = "Mozilla/5.0 ("
-#if defined(XP_MACOSX)
- "Macintosh; U; Intel Mac OS X;"
-#elif defined(XP_WIN)
- "Windows; U; Windows NT 5.1;"
-#elif defined(XP_UNIX)
-// The Gtk port uses X11 plugins in Mac.
-#if OS(DARWIN) && PLATFORM(GTK)
- "X11; U; Intel Mac OS X;"
-#else
- "X11; U; Linux i686;"
-#endif
-#endif
- " en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0";
-
-static const char* const ChromeUserAgent = "Mozilla/5.0 ("
-#if defined(XP_MACOSX)
- "Macintosh; U; Intel Mac OS X;"
-#elif defined(XP_WIN)
- "Windows; U; Windows NT 5.1;"
-#elif defined(XP_UNIX)
- // The Gtk port uses X11 plugins in Mac.
-#if OS(DARWIN) && PLATFORM(GTK)
- "X11; U; Intel Mac OS X;"
-#else
- "X11; U; Linux i686;"
-#endif
-#endif
- " AppleWebKit/534.34 (KHTML, like Gecko) Chrome/19.0.1055.1 Safari/534.34";
-
-const char* PluginView::userAgent()
-{
- if (m_plugin->quirks().contains(PluginQuirkWantsMozillaUserAgent))
- return MozillaUserAgent;
- else if (m_plugin->quirks().contains(PluginQuirkWantsChromeUserAgent))
- return ChromeUserAgent;
- if (m_userAgent.isNull())
- m_userAgent = m_parentFrame->loader().userAgent(m_url).utf8();
-
- return m_userAgent.data();
-}
-
-#if ENABLE(NETSCAPE_PLUGIN_API)
-const char* PluginView::userAgentStatic()
-{
- return MozillaUserAgent;
-}
-#endif
-
-
-void PluginView::lifeSupportTimerFired()
-{
- deref();
-}
-
-void PluginView::keepAlive()
-{
- if (m_lifeSupportTimer.isActive())
- return;
-
- ref();
- m_lifeSupportTimer.startOneShot(0);
-}
-
-#if ENABLE(NETSCAPE_PLUGIN_API)
-void PluginView::keepAlive(NPP instance)
-{
- PluginView* view = instanceMap().get(instance);
- if (!view)
- return;
-
- view->keepAlive();
-}
-
-NPError PluginView::getValueStatic(NPNVariable variable, void* value)
-{
- LOG(Plugins, "PluginView::getValueStatic(%s)", prettyNameForNPNVariable(variable).data());
-
- NPError result;
- if (platformGetValueStatic(variable, value, &result))
- return result;
-
- return NPERR_GENERIC_ERROR;
-}
-
-NPError PluginView::getValue(NPNVariable variable, void* value)
-{
- LOG(Plugins, "PluginView::getValue(%s)", prettyNameForNPNVariable(variable).data());
-
- NPError result;
- if (platformGetValue(variable, value, &result))
- return result;
-
- if (platformGetValueStatic(variable, value, &result))
- return result;
-
- switch (variable) {
- case NPNVWindowNPObject: {
- if (m_isJavaScriptPaused)
- return NPERR_GENERIC_ERROR;
-
- NPObject* windowScriptObject = m_parentFrame->script().windowScriptNPObject();
-
- // Return value is expected to be retained, as described here: <http://www.mozilla.org/projects/plugin/npruntime.html>
- if (windowScriptObject)
- _NPN_RetainObject(windowScriptObject);
-
- void** v = (void**)value;
- *v = windowScriptObject;
-
- return NPERR_NO_ERROR;
- }
-
- case NPNVPluginElementNPObject: {
- if (m_isJavaScriptPaused)
- return NPERR_GENERIC_ERROR;
-
- NPObject* pluginScriptObject = 0;
-
- if (m_element->hasTagName(appletTag) || m_element->hasTagName(embedTag) || m_element->hasTagName(objectTag))
- pluginScriptObject = m_element->getNPObject();
-
- // Return value is expected to be retained, as described here: <http://www.mozilla.org/projects/plugin/npruntime.html>
- if (pluginScriptObject)
- _NPN_RetainObject(pluginScriptObject);
-
- void** v = (void**)value;
- *v = pluginScriptObject;
-
- return NPERR_NO_ERROR;
- }
-
- case NPNVprivateModeBool: {
- Page* page = m_parentFrame->page();
- if (!page)
- return NPERR_GENERIC_ERROR;
- *((NPBool*)value) = page->usesEphemeralSession();
- return NPERR_NO_ERROR;
- }
-
- default:
- return NPERR_GENERIC_ERROR;
- }
-}
-
-static Frame* getFrame(Frame* parentFrame, Element* element)
-{
- if (parentFrame)
- return parentFrame;
-
- return element->document().frame();
-}
-
-NPError PluginView::getValueForURL(NPNURLVariable variable, const char* url, char** value, uint32_t* len)
-{
- LOG(Plugins, "PluginView::getValueForURL(%s)", prettyNameForNPNURLVariable(variable).data());
-
- NPError result = NPERR_NO_ERROR;
-
- switch (variable) {
- case NPNURLVCookie: {
- URL u(m_parentFrame->document()->baseURL(), url);
- if (u.isValid()) {
- Frame* frame = getFrame(parentFrame(), m_element);
- if (frame) {
- const CString cookieStr = cookies(frame->document(), u).utf8();
- if (!cookieStr.isNull()) {
- const int size = cookieStr.length();
- *value = static_cast<char*>(NPN_MemAlloc(size+1));
- if (*value) {
- memset(*value, 0, size+1);
- memcpy(*value, cookieStr.data(), size+1);
- if (len)
- *len = size;
- } else
- result = NPERR_OUT_OF_MEMORY_ERROR;
- }
- }
- } else
- result = NPERR_INVALID_URL;
- break;
- }
- case NPNURLVProxy: {
- URL u(m_parentFrame->document()->baseURL(), url);
- if (u.isValid()) {
- Frame* frame = getFrame(parentFrame(), m_element);
- const FrameLoader* frameLoader = frame ? &frame->loader() : 0;
- const NetworkingContext* context = frameLoader ? frameLoader->networkingContext() : 0;
- const CString proxyStr = toString(proxyServersForURL(u, context)).utf8();
- if (!proxyStr.isNull()) {
- const int size = proxyStr.length();
- *value = static_cast<char*>(NPN_MemAlloc(size+1));
- if (*value) {
- memset(*value, 0, size+1);
- memcpy(*value, proxyStr.data(), size+1);
- if (len)
- *len = size;
- } else
- result = NPERR_OUT_OF_MEMORY_ERROR;
- }
- } else
- result = NPERR_INVALID_URL;
- break;
- }
- default:
- result = NPERR_GENERIC_ERROR;
- LOG(Plugins, "PluginView::getValueForURL: %s", prettyNameForNPNURLVariable(variable).data());
- break;
- }
-
- return result;
-}
-
-
-NPError PluginView::setValueForURL(NPNURLVariable variable, const char* url, const char* value, uint32_t len)
-{
- LOG(Plugins, "PluginView::setValueForURL(%s)", prettyNameForNPNURLVariable(variable).data());
-
- NPError result = NPERR_NO_ERROR;
-
- switch (variable) {
- case NPNURLVCookie: {
- URL u(m_parentFrame->document()->baseURL(), url);
- if (u.isValid()) {
- const String cookieStr = String::fromUTF8(value, len);
- Frame* frame = getFrame(parentFrame(), m_element);
- if (frame && !cookieStr.isEmpty())
- setCookies(frame->document(), u, cookieStr);
- } else
- result = NPERR_INVALID_URL;
- break;
- }
- case NPNURLVProxy:
- LOG(Plugins, "PluginView::setValueForURL(%s): Plugins are NOT allowed to set proxy information.", prettyNameForNPNURLVariable(variable).data());
- result = NPERR_GENERIC_ERROR;
- break;
- default:
- LOG(Plugins, "PluginView::setValueForURL: %s", prettyNameForNPNURLVariable(variable).data());
- result = NPERR_GENERIC_ERROR;
- break;
- }
-
- return result;
-}
-
-NPError PluginView::getAuthenticationInfo(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 */)
-{
-#if LOG_DISABLED
- UNUSED_PARAM(protocol);
- UNUSED_PARAM(host);
- UNUSED_PARAM(port);
-#endif
- LOG(Plugins, "PluginView::getAuthenticationInfo: protocol=%s, host=%s, port=%d", protocol, host, port);
- notImplemented();
- return NPERR_GENERIC_ERROR;
-}
-#endif
-
-void PluginView::privateBrowsingStateChanged(bool privateBrowsingEnabled)
-{
- NPP_SetValueProcPtr setValue = m_plugin->pluginFuncs()->setvalue;
- if (!setValue)
- return;
-
- PluginView::setCurrentPluginView(this);
- JSC::JSLock::DropAllLocks dropAllLocks(JSDOMWindowBase::commonVM());
- setCallingPlugin(true);
- NPBool value = privateBrowsingEnabled;
- setValue(m_instance, NPNVprivateModeBool, &value);
- setCallingPlugin(false);
- PluginView::setCurrentPluginView(0);
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(NETSCAPE_PLUGIN_API)
</del></span></pre></div>
<a id="trunkSourceWebCorepluginsPluginViewh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/plugins/PluginView.h (178218 => 178219)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/plugins/PluginView.h        2015-01-10 00:09:59 UTC (rev 178218)
+++ trunk/Source/WebCore/plugins/PluginView.h        2015-01-10 00:16:52 UTC (rev 178219)
</span><span class="lines">@@ -1,440 +0,0 @@
</span><del>-/*
- * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
- * Copyright (C) 2008 Collabora Ltd. All rights reserved.
- * Copyright (C) 2009 Girish Ramakrishnan <girish@forwardbias.in>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef PluginView_h
-#define PluginView_h
-
-#include "FrameLoadRequest.h"
-#include "IntRect.h"
-#include "MediaCanStartListener.h"
-#include "PluginViewBase.h"
-#include "ResourceRequest.h"
-#include "Timer.h"
-#include <wtf/HashMap.h>
-#include <wtf/HashSet.h>
-#include <wtf/OwnPtr.h>
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefPtr.h>
-#include <wtf/Vector.h>
-#include <wtf/text/CString.h>
-
-#if ENABLE(NETSCAPE_PLUGIN_API)
-#include "PluginStream.h"
-#include "npruntime_internal.h"
-#endif
-
-#if OS(WINDOWS) && PLATFORM(GTK)
-typedef struct HWND__* HWND;
-typedef HWND PlatformPluginWidget;
-#else
-typedef PlatformWidget PlatformPluginWidget;
-#endif
-#if PLATFORM(GTK)
-typedef struct _GtkSocket GtkSocket;
-#endif
-
-#if PLATFORM(X11)
-typedef unsigned long Window;
-typedef struct _XDisplay Display;
-#endif
-
-namespace JSC {
- namespace Bindings {
- class Instance;
- }
-}
-
-namespace WebCore {
- class Frame;
- class FrameView;
- class Image;
- class HTMLPlugInElement;
- class KeyboardEvent;
- class MouseEvent;
- class URL;
-#if OS(WINDOWS) && ENABLE(NETSCAPE_PLUGIN_API)
- class PluginMessageThrottlerWin;
-#endif
- class PluginPackage;
- class PluginRequest;
- class PluginStream;
- class ResourceError;
- class ResourceResponse;
- class WheelEvent;
-
- enum PluginStatus {
- PluginStatusCanNotFindPlugin,
- PluginStatusCanNotLoadPlugin,
- PluginStatusLoadedSuccessfully
- };
-
- class PluginRequest {
- WTF_MAKE_NONCOPYABLE(PluginRequest); WTF_MAKE_FAST_ALLOCATED;
- public:
- PluginRequest(const FrameLoadRequest& frameLoadRequest, bool sendNotification, void* notifyData, bool shouldAllowPopups)
- : m_frameLoadRequest(frameLoadRequest)
- , m_notifyData(notifyData)
- , m_sendNotification(sendNotification)
- , m_shouldAllowPopups(shouldAllowPopups) { }
- public:
- const FrameLoadRequest& frameLoadRequest() const { return m_frameLoadRequest; }
- void* notifyData() const { return m_notifyData; }
- bool sendNotification() const { return m_sendNotification; }
- bool shouldAllowPopups() const { return m_shouldAllowPopups; }
- private:
- FrameLoadRequest m_frameLoadRequest;
- void* m_notifyData;
- bool m_sendNotification;
- bool m_shouldAllowPopups;
- };
-
- class PluginManualLoader {
- public:
- virtual ~PluginManualLoader() {}
- virtual void didReceiveResponse(const ResourceResponse&) = 0;
- virtual void didReceiveData(const char*, int) = 0;
- virtual void didFinishLoading() = 0;
- virtual void didFail(const ResourceError&) = 0;
- };
-
- class PluginView : public PluginViewBase
-#if ENABLE(NETSCAPE_PLUGIN_API)
- , private PluginStreamClient
-#endif
- , public PluginManualLoader
- , private MediaCanStartListener {
- public:
- static PassRefPtr<PluginView> create(Frame* parentFrame, const IntSize&, HTMLPlugInElement*, const URL&, const Vector<String>& paramNames, const Vector<String>& paramValues, const String& mimeType, bool loadManually);
- virtual ~PluginView();
-
- PluginPackage* plugin() const { return m_plugin.get(); }
-#if ENABLE(NETSCAPE_PLUGIN_API)
- NPP instance() const { return m_instance; }
-#endif
-
- void setNPWindowRect(const IntRect&);
- static PluginView* currentPluginView();
-
-#if ENABLE(NETSCAPE_PLUGIN_API)
- NPObject* npObject();
-#endif
- PassRefPtr<JSC::Bindings::Instance> bindingInstance();
-
- PluginStatus status() const { return m_status; }
-
-#if ENABLE(NETSCAPE_PLUGIN_API)
- // NPN functions
- NPError getURLNotify(const char* url, const char* target, void* notifyData);
- NPError getURL(const char* url, const char* target);
- NPError postURLNotify(const char* url, const char* target, uint32_t len, const char* but, NPBool file, void* notifyData);
- NPError postURL(const char* url, const char* target, uint32_t len, const char* but, NPBool file);
- NPError newStream(NPMIMEType type, const char* target, NPStream** stream);
- int32_t write(NPStream* stream, int32_t len, void* buffer);
- NPError destroyStream(NPStream* stream, NPReason reason);
-#endif
- const char* userAgent();
-#if ENABLE(NETSCAPE_PLUGIN_API)
- static const char* userAgentStatic();
-#endif
- void status(const char* message);
-
-#if ENABLE(NETSCAPE_PLUGIN_API)
- NPError getValue(NPNVariable variable, void* value);
- static NPError getValueStatic(NPNVariable variable, void* value);
- NPError setValue(NPPVariable variable, void* value);
- NPError getValueForURL(NPNURLVariable variable, const char* url, char** value, uint32_t* len);
- NPError setValueForURL(NPNURLVariable variable, const char* url, const char* value, uint32_t len);
- NPError getAuthenticationInfo(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);
- void invalidateRect(NPRect*);
- void invalidateRegion(NPRegion);
-#endif
- void forceRedraw();
- void pushPopupsEnabledState(bool state);
- void popPopupsEnabledState();
-
- virtual void invalidateRect(const IntRect&);
-
- bool arePopupsAllowed() const;
-
- void setJavaScriptPaused(bool);
-
- void privateBrowsingStateChanged(bool);
-
- void disconnectStream(PluginStream*);
- void streamDidFinishLoading(PluginStream* stream) { disconnectStream(stream); }
-
- // Widget functions
- virtual void setFrameRect(const IntRect&);
- virtual void frameRectsChanged();
- virtual void setFocus(bool);
- virtual void show();
- virtual void hide();
- virtual void paint(GraphicsContext*, const IntRect&);
- virtual void clipRectChanged() override;
-
- // This method is used by plugins on all platforms to obtain a clip rect that includes clips set by WebCore,
- // e.g., in overflow:auto sections. The clip rects coordinates are in the containing window's coordinate space.
- // This clip includes any clips that the widget itself sets up for its children.
- IntRect windowClipRect() const;
-
- virtual void handleEvent(Event*);
- virtual void setParent(ScrollView*);
- virtual void setParentVisible(bool);
-
- virtual bool isPluginView() const override { return true; }
-
- Frame* parentFrame() const { return m_parentFrame.get(); }
-
- void focusPluginElement();
-
- const String& pluginsPage() const { return m_pluginsPage; }
- const String& mimeType() const { return m_mimeType; }
- const URL& url() const { return m_url; }
-
-#if defined(XP_MACOSX) && ENABLE(NETSCAPE_PLUGIN_API)
- bool popUpContextMenu(NPMenu*);
-#endif
-
-#if OS(WINDOWS) && ENABLE(NETSCAPE_PLUGIN_API)
- static LRESULT CALLBACK PluginViewWndProc(HWND, UINT, WPARAM, LPARAM);
- LRESULT wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
- WNDPROC pluginWndProc() const { return m_pluginWndProc; }
-#endif
-
- // Used for manual loading
- void didReceiveResponse(const ResourceResponse&);
- void didReceiveData(const char*, int);
- void didFinishLoading();
- void didFail(const ResourceError&);
-
- static bool isCallingPlugin();
-
- bool start();
-
-#if ENABLE(NETSCAPE_PLUGIN_API)
- static void keepAlive(NPP);
-#endif
- void keepAlive();
-
-#if PLATFORM(X11)
- static Display* getPluginDisplay(Frame*);
- static Window getRootWindow(Frame* parentFrame);
-#endif
-
- private:
- PluginView(Frame* parentFrame, const IntSize&, PluginPackage*, HTMLPlugInElement*, const URL&, const Vector<String>& paramNames, const Vector<String>& paramValues, const String& mimeType, bool loadManually);
-
- void setParameters(const Vector<String>& paramNames, const Vector<String>& paramValues);
- bool startOrAddToUnstartedList();
- void init();
- bool platformStart();
- void stop();
- void platformDestroy();
- static void setCurrentPluginView(PluginView*);
-#if ENABLE(NETSCAPE_PLUGIN_API)
- NPError load(const FrameLoadRequest&, bool sendNotification, void* notifyData);
- NPError handlePost(const char* url, const char* target, uint32_t len, const char* buf, bool file, void* notifyData, bool sendNotification, bool allowHeaders);
- NPError handlePostReadFile(Vector<char>& buffer, uint32_t len, const char* buf);
-#endif
- static void freeStringArray(char** stringArray, int length);
- void setCallingPlugin(bool) const;
-
- void invalidateWindowlessPluginRect(const IntRect&);
-
- virtual void mediaCanStart();
-
-#if OS(WINDOWS) && ENABLE(NETSCAPE_PLUGIN_API)
- void paintWindowedPluginIntoContext(GraphicsContext*, const IntRect&);
- static HDC WINAPI hookedBeginPaint(HWND, PAINTSTRUCT*);
- static BOOL WINAPI hookedEndPaint(HWND, const PAINTSTRUCT*);
-#endif
-
-#if ENABLE(NETSCAPE_PLUGIN_API)
- static bool platformGetValueStatic(NPNVariable variable, void* value, NPError* result);
- bool platformGetValue(NPNVariable variable, void* value, NPError* result);
-#endif
-
- RefPtr<Frame> m_parentFrame;
- RefPtr<PluginPackage> m_plugin;
- HTMLPlugInElement* m_element;
- bool m_isStarted;
- URL m_url;
- PluginStatus m_status;
- Vector<IntRect> m_invalidRects;
-
- void performRequest(PluginRequest*);
- void scheduleRequest(std::unique_ptr<PluginRequest>);
- void requestTimerFired();
- void invalidateTimerFired();
- Timer m_requestTimer;
- Timer m_invalidateTimer;
-
- void popPopupsStateTimerFired();
- Timer m_popPopupsStateTimer;
-
- void lifeSupportTimerFired();
- Timer m_lifeSupportTimer;
-
-#if ENABLE(NETSCAPE_PLUGIN_API)
- bool dispatchNPEvent(NPEvent&);
-#endif
-#if defined(XP_MACOSX) && ENABLE(NETSCAPE_PLUGIN_API)
- int16_t dispatchNPCocoaEvent(NPCocoaEvent&);
- bool m_updatedCocoaTextInputRequested;
- bool m_keyDownSent;
- uint16_t m_disregardKeyUpCounter;
-#endif
-
-#if defined(XP_MACOSX)
- void handleWheelEvent(WheelEvent*);
-#endif
- void updatePluginWidget();
- void paintMissingPluginIcon(GraphicsContext*, const IntRect&);
-
- void handleKeyboardEvent(KeyboardEvent*);
- void handleMouseEvent(MouseEvent*);
-#if defined(XP_UNIX) && ENABLE(NETSCAPE_PLUGIN_API)
- void handleFocusInEvent();
- void handleFocusOutEvent();
-#endif
-
-#if OS(WINDOWS)
- void paintIntoTransformedContext(HDC);
- PassRefPtr<Image> snapshot();
-#endif
-
- int m_mode;
- int m_paramCount;
- char** m_paramNames;
- char** m_paramValues;
- String m_pluginsPage;
-
- String m_mimeType;
- WTF::CString m_userAgent;
-
-#if ENABLE(NETSCAPE_PLUGIN_API)
- NPP m_instance;
- NPP_t m_instanceStruct;
- NPWindow m_npWindow;
-#endif
-
- Vector<bool, 4> m_popupStateStack;
-
- HashSet<RefPtr<PluginStream> > m_streams;
- Vector<std::unique_ptr<PluginRequest>> m_requests;
-
- bool m_isWindowed;
- bool m_isTransparent;
- bool m_haveInitialized;
- bool m_isWaitingToStart;
-
-#if defined(XP_UNIX)
- bool m_needsXEmbed;
-#endif
-
-#if OS(WINDOWS) && ENABLE(NETSCAPE_PLUGIN_API)
- OwnPtr<PluginMessageThrottlerWin> m_messageThrottler;
- WNDPROC m_pluginWndProc;
- unsigned m_lastMessage;
- bool m_isCallingPluginWndProc;
- HDC m_wmPrintHDC;
- bool m_haveUpdatedPluginWidget;
-#endif
-
-#if (PLATFORM(GTK) && OS(WINDOWS)) || PLATFORM(EFL)
- // On Mac OSX and Qt/Windows the plugin does not have its own native widget,
- // but is using the containing window as its reference for positioning/painting.
- PlatformPluginWidget m_window;
-public:
- PlatformPluginWidget platformPluginWidget() const { return m_window; }
- void setPlatformPluginWidget(PlatformPluginWidget widget) { m_window = widget; }
-#else
-public:
- void setPlatformPluginWidget(PlatformPluginWidget widget) { setPlatformWidget(widget); }
- PlatformPluginWidget platformPluginWidget() const { return platformWidget(); }
-#endif
-
-private:
-
-#if defined(XP_UNIX) || PLATFORM(GTK)
- void setNPWindowIfNeeded();
-#elif defined(XP_MACOSX)
- NP_CGContext m_npCgContext;
- CGContextRef m_contextRef;
-
- void setNPWindowIfNeeded();
-#endif
-
-#if defined(XP_UNIX) && ENABLE(NETSCAPE_PLUGIN_API)
- bool m_hasPendingGeometryChange;
- Pixmap m_drawable;
- Visual* m_visual;
- Colormap m_colormap;
- Display* m_pluginDisplay;
-
- void initXEvent(XEvent* event);
-#endif
-
-#if PLATFORM(GTK)
- static gboolean plugRemovedCallback(GtkSocket*, PluginView*);
- static void plugAddedCallback(GtkSocket*, PluginView*);
- void updateWidgetAllocationAndClip();
- bool m_plugAdded;
- IntRect m_delayedAllocation;
-#endif
-
- IntRect m_clipRect; // The clip rect to apply to a windowed plug-in
- IntRect m_windowRect; // Our window rect.
-
- bool m_loadManually;
- RefPtr<PluginStream> m_manualStream;
-
- bool m_isJavaScriptPaused;
-
- bool m_haveCalledSetWindow;
-
- static PluginView* s_currentPluginView;
- };
-
-inline PluginView* toPluginView(Widget* widget)
-{
- ASSERT(!widget || widget->isPluginView());
- return static_cast<PluginView*>(widget);
-}
-
-inline const PluginView* toPluginView(const Widget* widget)
-{
- ASSERT(!widget || widget->isPluginView());
- return static_cast<const PluginView*>(widget);
-}
-
-// This will catch anyone doing an unnecessary cast.
-void toPluginView(const PluginView*);
-
-} // namespace WebCore
-
-#endif
</del></span></pre></div>
<a id="trunkSourceWebCorepluginsnpapicpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/plugins/npapi.cpp (178218 => 178219)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/plugins/npapi.cpp        2015-01-10 00:09:59 UTC (rev 178218)
+++ trunk/Source/WebCore/plugins/npapi.cpp        2015-01-10 00:16:52 UTC (rev 178219)
</span><span class="lines">@@ -1,208 +0,0 @@
</span><del>-/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include "Page.h"
-#include "PluginMainThreadScheduler.h"
-#include "PluginView.h"
-#include "npruntime_internal.h"
-
-using namespace WebCore;
-
-// The plugin view is always the ndata of the instance,. Sometimes, plug-ins will call an instance-specific function
-// with a NULL instance. To workaround this, call the last plug-in view that made a call to a plug-in.
-// Currently, the current plug-in view is only set before NPP_New in PluginView::start.
-// This specifically works around Flash and Shockwave. When we call NPP_New, they call NPN_Useragent with a NULL instance.
-static PluginView* pluginViewForInstance(NPP instance)
-{
- if (instance && instance->ndata)
- return static_cast<PluginView*>(instance->ndata);
- return PluginView::currentPluginView();
-}
-
-void* NPN_MemAlloc(uint32_t size)
-{
- return malloc(size);
-}
-
-void NPN_MemFree(void* ptr)
-{
- free(ptr);
-}
-
-uint32_t NPN_MemFlush(uint32_t)
-{
- // Do nothing
- return 0;
-}
-
-void NPN_ReloadPlugins(NPBool reloadPages)
-{
- Page::refreshPlugins(reloadPages);
-}
-
-NPError NPN_RequestRead(NPStream*, NPByteRange*)
-{
- return NPERR_STREAM_NOT_SEEKABLE;
-}
-
-NPError NPN_GetURLNotify(NPP instance, const char* url, const char* target, void* notifyData)
-{
- return pluginViewForInstance(instance)->getURLNotify(url, target, notifyData);
-}
-
-NPError NPN_GetURL(NPP instance, const char* url, const char* target)
-{
- return pluginViewForInstance(instance)->getURL(url, target);
-}
-
-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);
-}
-
-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);
-}
-
-NPError NPN_NewStream(NPP instance, NPMIMEType type, const char* target, NPStream** stream)
-{
- return pluginViewForInstance(instance)->newStream(type, target, stream);
-}
-
-int32_t NPN_Write(NPP instance, NPStream* stream, int32_t len, void* buffer)
-{
- return pluginViewForInstance(instance)->write(stream, len, buffer);
-}
-
-NPError NPN_DestroyStream(NPP instance, NPStream* stream, NPReason reason)
-{
- return pluginViewForInstance(instance)->destroyStream(stream, reason);
-}
-
-const char* NPN_UserAgent(NPP instance)
-{
- PluginView* view = pluginViewForInstance(instance);
-
- if (!view)
- return PluginView::userAgentStatic();
-
- return view->userAgent();
-}
-
-void NPN_Status(NPP instance, const char* message)
-{
- pluginViewForInstance(instance)->status(message);
-}
-
-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);
-}
-
-void NPN_InvalidateRegion(NPP instance, NPRegion invalidRegion)
-{
- pluginViewForInstance(instance)->invalidateRegion(invalidRegion);
-}
-
-void NPN_ForceRedraw(NPP instance)
-{
- pluginViewForInstance(instance)->forceRedraw();
-}
-
-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);
-}
-
-NPError NPN_SetValue(NPP instance, NPPVariable variable, void* value)
-{
- return pluginViewForInstance(instance)->setValue(variable, value);
-}
-
-void* NPN_GetJavaEnv()
-{
- // Unsupported
- return 0;
-}
-
-void* NPN_GetJavaPeer(NPP)
-{
- // Unsupported
- return 0;
-}
-
-void NPN_PushPopupsEnabledState(NPP instance, NPBool enabled)
-{
- pluginViewForInstance(instance)->pushPopupsEnabledState(enabled);
-}
-
-void NPN_PopPopupsEnabledState(NPP instance)
-{
- pluginViewForInstance(instance)->popPopupsEnabledState();
-}
-
-extern "C" typedef void PluginThreadAsyncCallFunction(void*);
-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);
-}
-
-NPError NPN_GetValueForURL(NPP instance, NPNURLVariable variable, const char* url, char** value, uint32_t* len)
-{
- return pluginViewForInstance(instance)->getValueForURL(variable, url, value, len);
-}
-
-NPError NPN_SetValueForURL(NPP instance, NPNURLVariable variable, const char* url, const char* value, uint32_t len)
-{
- return pluginViewForInstance(instance)->setValueForURL(variable, url, value, len);
-}
-
-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);
-}
-
-NPError NPN_PopUpContextMenu(NPP instance, NPMenu* menu)
-{
- UNUSED_PARAM(instance);
- UNUSED_PARAM(menu);
- return NPERR_NO_ERROR;
-}
</del></span></pre></div>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (178218 => 178219)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog        2015-01-10 00:09:59 UTC (rev 178218)
+++ trunk/Source/WebKit/ChangeLog        2015-01-10 00:16:52 UTC (rev 178219)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2015-01-06 Anders Carlsson <andersca@apple.com>
+
+ Move the Windows only plug-in code to WebKit/win
+ https://bugs.webkit.org/show_bug.cgi?id=140133
+
+ Reviewed by Darin Adler.
+
+ * WebKit.vcxproj/WebKit/WebKit.vcxproj:
+ * WebKit.vcxproj/WebKit/WebKit.vcxproj.filters:
+
</ins><span class="cx"> 2015-01-08 Brent Fulgham <bfulgham@apple.com>
</span><span class="cx">
</span><span class="cx"> [Win] Unreviewed build fix after r178124.
</span></span></pre></div>
<a id="trunkSourceWebKitWebKitvcxprojWebKitWebKitvcxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebKit.vcxproj/WebKit/WebKit.vcxproj (178218 => 178219)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebKit.vcxproj/WebKit/WebKit.vcxproj        2015-01-10 00:09:59 UTC (rev 178218)
+++ trunk/Source/WebKit/WebKit.vcxproj/WebKit/WebKit.vcxproj        2015-01-10 00:16:52 UTC (rev 178219)
</span><span class="lines">@@ -294,6 +294,16 @@
</span><span class="cx"> <ClCompile Include="..\..\Storage\WebDatabaseProvider.cpp" />
</span><span class="cx"> <ClCompile Include="..\..\Storage\WebStorageNamespaceProvider.cpp" />
</span><span class="cx"> <ClCompile Include="..\..\cf\WebCoreSupport\WebInspectorClientCF.cpp" />
</span><ins>+ <ClCompile Include="..\..\win\Plugins\npapi.cpp" />
+ <ClCompile Include="..\..\win\Plugins\PluginDatabase.cpp" />
+ <ClCompile Include="..\..\win\Plugins\PluginDebug.cpp" />
+ <ClCompile Include="..\..\win\Plugins\PluginPackage.cpp" />
+ <ClCompile Include="..\..\win\Plugins\PluginStream.cpp" />
+ <ClCompile Include="..\..\win\Plugins\PluginView.cpp" />
+ <ClCompile Include="..\..\win\Plugins\PluginDatabaseWin.cpp" />
+ <ClCompile Include="..\..\win\Plugins\PluginMessageThrottlerWin.cpp" />
+ <ClCompile Include="..\..\win\Plugins\PluginPackageWin.cpp" />
+ <ClCompile Include="..\..\win\Plugins\PluginViewWin.cpp" />
</ins><span class="cx"> <ClCompile Include="..\..\win\AccessibleBase.cpp" />
</span><span class="cx"> <ClCompile Include="..\..\win\AccessibleDocument.cpp" />
</span><span class="cx"> <ClCompile Include="..\..\win\AccessibleImage.cpp" />
</span><span class="lines">@@ -436,6 +446,14 @@
</span><span class="cx"> <ClInclude Include="..\..\Storage\StorageTrackerClient.h" />
</span><span class="cx"> <ClInclude Include="..\..\Storage\WebDatabaseProvider.h" />
</span><span class="cx"> <ClInclude Include="..\..\Storage\WebStorageNamespaceProvider.h" />
</span><ins>+ <ClInclude Include="..\..\win\Plugins\PluginDatabase.h" />
+ <ClInclude Include="..\..\win\Plugins\PluginDebug.h" />
+ <ClInclude Include="..\..\win\Plugins\PluginPackage.h" />
+ <ClInclude Include="..\..\win\Plugins\PluginQuirkSet.h" />
+ <ClInclude Include="..\..\win\Plugins\PluginStrategy.h" />
+ <ClInclude Include="..\..\win\Plugins\PluginStream.h" />
+ <ClInclude Include="..\..\win\Plugins\PluginView.h" />
+ <ClInclude Include="..\..\win\Plugins\PluginMessageThrottlerWin.h" />
</ins><span class="cx"> <ClInclude Include="..\..\win\AccessibleBase.h" />
</span><span class="cx"> <ClInclude Include="..\..\win\AccessibleDocument.h" />
</span><span class="cx"> <ClInclude Include="..\..\win\AccessibleImage.h" />
</span></span></pre></div>
<a id="trunkSourceWebKitWebKitvcxprojWebKitWebKitvcxprojfilters"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebKit.vcxproj/WebKit/WebKit.vcxproj.filters (178218 => 178219)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebKit.vcxproj/WebKit/WebKit.vcxproj.filters        2015-01-10 00:09:59 UTC (rev 178218)
+++ trunk/Source/WebKit/WebKit.vcxproj/WebKit/WebKit.vcxproj.filters        2015-01-10 00:16:52 UTC (rev 178219)
</span><span class="lines">@@ -217,6 +217,36 @@
</span><span class="cx"> <ClCompile Include="..\..\win\WebSerializedJSValue.cpp">
</span><span class="cx"> <Filter>Sources</Filter>
</span><span class="cx"> </ClCompile>
</span><ins>+ <ClCompile Include="..\..\win\Plugins\npapi.cpp">
+ <Filter>Sources</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\win\Plugins\PluginDatabase.cpp">
+ <Filter>Sources</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\win\Plugins\PluginDebug.cpp">
+ <Filter>Sources</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\win\Plugins\PluginPackage.cpp">
+ <Filter>Sources</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\win\Plugins\PluginStream.cpp">
+ <Filter>Sources</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\win\Plugins\PluginView.cpp">
+ <Filter>Sources</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\win\Plugins\PluginDatabaseWin.cpp">
+ <Filter>Sources</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\win\Plugins\PluginMessageThrottlerWin.cpp">
+ <Filter>Sources</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\win\Plugins\PluginPackageWin.cpp">
+ <Filter>Sources</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\win\Plugins\PluginViewWin.cpp">
+ <Filter>Sources</Filter>
+ </ClCompile>
</ins><span class="cx"> <ClCompile Include="..\..\Storage\StorageAreaImpl.cpp">
</span><span class="cx"> <Filter>Sources</Filter>
</span><span class="cx"> </ClCompile>
</span><span class="lines">@@ -558,6 +588,27 @@
</span><span class="cx"> <ClInclude Include="..\..\win\WebCoreSupport\AcceleratedCompositingContext.h">
</span><span class="cx"> <Filter>WebCoreSupport</Filter>
</span><span class="cx"> </ClInclude>
</span><ins>+ <ClInclude Include="..\..\win\Plugins\PluginDatabase.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\win\Plugins\PluginDebug.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\win\Plugins\PluginPackage.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\win\Plugins\PluginQuirkSet.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\win\Plugins\PluginStream.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\win\Plugins\PluginView.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\win\Plugins\PluginMessageThrottlerWin.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ins><span class="cx"> <ClInclude Include="..\..\Storage\StorageAreaImpl.h">
</span><span class="cx"> <Filter>Sources</Filter>
</span><span class="cx"> </ClInclude>
</span></span></pre></div>
<a id="trunkSourceWebKitWebKitvcxprojWebKitWebKitCommonprops"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebKit.vcxproj/WebKit/WebKitCommon.props (178218 => 178219)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebKit.vcxproj/WebKit/WebKitCommon.props        2015-01-10 00:09:59 UTC (rev 178218)
+++ trunk/Source/WebKit/WebKit.vcxproj/WebKit/WebKitCommon.props        2015-01-10 00:16:52 UTC (rev 178219)
</span><span class="lines">@@ -5,7 +5,7 @@
</span><span class="cx"> </PropertyGroup>
</span><span class="cx"> <ItemDefinitionGroup>
</span><span class="cx"> <ClCompile>
</span><del>- <AdditionalIncludeDirectories>$(ProjectDir);$(ProjectDir)\..\..\win;$(ProjectDir)\..\..\win\WebCoreSupport;$(ProjectDir)\..\..\Storage;$(ConfigurationBuildDir)\include\WebKit;$(ConfigurationBuildDir)\Include;$(ConfigurationBuildDir)\Include\private;$(ConfigurationBuildDir)\Include\WebCore;$(ConfigurationBuildDir)\Include\WebCore\ForwardingHeaders;$(ConfigurationBuildDir)\Include\JavaScriptCore;$(ConfigurationBuildDir)\Include\private\JavaScriptCore;$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\WebKit\DerivedSources;$(WebKit_Libraries)\Include;$(WebKit_Libraries)\Include\private;$(WebKit_Libraries)\Include\WebCore;$(WebKit_Libraries)\Include\WebCore\ForwardingHeaders;$(WebKit_Libraries)\Include\JavaScriptCore;$(WebKit_Libraries)\Include\private\JavaScriptCore;$(IntDir)include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</del><ins>+ <AdditionalIncludeDirectories>$(ProjectDir);$(ProjectDir)\..\..\win;$(ProjectDir)\..\..\win\Plugins;$(ProjectDir)\..\..\win\WebCoreSupport;$(ProjectDir)\..\..\Storage;$(ConfigurationBuildDir)\include\WebKit;$(ConfigurationBuildDir)\Include;$(ConfigurationBuildDir)\Include\private;$(ConfigurationBuildDir)\Include\WebCore;$(ConfigurationBuildDir)\Include\WebCore\ForwardingHeaders;$(ConfigurationBuildDir)\Include\JavaScriptCore;$(ConfigurationBuildDir)\Include\private\JavaScriptCore;$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\WebKit\DerivedSources;$(WebKit_Libraries)\Include;$(WebKit_Libraries)\Include\private;$(WebKit_Libraries)\Include\WebCore;$(WebKit_Libraries)\Include\WebCore\ForwardingHeaders;$(WebKit_Libraries)\Include\JavaScriptCore;$(WebKit_Libraries)\Include\private\JavaScriptCore;$(IntDir)include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ins><span class="cx"> <PreprocessorDefinitions>WEBKIT_EXPORTS;FRAMEWORK_NAME=WebKit;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</span><span class="cx"> <PrecompiledHeader>Use</PrecompiledHeader>
</span><span class="cx"> <PrecompiledHeaderFile>WebKitPrefix.h</PrecompiledHeaderFile>
</span></span></pre></div>
<a id="trunkSourceWebKitwinChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/win/ChangeLog (178218 => 178219)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/win/ChangeLog        2015-01-10 00:09:59 UTC (rev 178218)
+++ trunk/Source/WebKit/win/ChangeLog        2015-01-10 00:16:52 UTC (rev 178219)
</span><span class="lines">@@ -1,3 +1,308 @@
</span><ins>+2015-01-06 Anders Carlsson <andersca@apple.com>
+
+ Move the Windows only plug-in code to WebKit/win
+ https://bugs.webkit.org/show_bug.cgi?id=140133
+
+ Reviewed by Darin Adler.
+
+ * Plugins/PaintHooks.asm: Renamed from Source/WebCore/plugins/win/PaintHooks.asm.
+ * Plugins/PluginDatabase.cpp: Renamed from Source/WebCore/plugins/PluginDatabase.cpp.
+ (WebCore::persistentPluginMetadataCachePath):
+ (WebCore::PluginDatabase::PluginDatabase):
+ (WebCore::PluginDatabase::installedPlugins):
+ (WebCore::PluginDatabase::isMIMETypeRegistered):
+ (WebCore::PluginDatabase::addExtraPluginDirectory):
+ (WebCore::PluginDatabase::refresh):
+ (WebCore::PluginDatabase::plugins):
+ (WebCore::PluginDatabase::preferredPluginCompare):
+ (WebCore::PluginDatabase::pluginForMIMEType):
+ (WebCore::PluginDatabase::MIMETypeForExtension):
+ (WebCore::PluginDatabase::findPlugin):
+ (WebCore::PluginDatabase::setPreferredPluginForMIMEType):
+ (WebCore::PluginDatabase::fileExistsAndIsNotDisabled):
+ (WebCore::PluginDatabase::getDeletedPlugins):
+ (WebCore::PluginDatabase::add):
+ (WebCore::PluginDatabase::remove):
+ (WebCore::PluginDatabase::clear):
+ (WebCore::PluginDatabase::removeDisabledPluginFile):
+ (WebCore::PluginDatabase::addDisabledPluginFile):
+ (WebCore::PluginDatabase::defaultPluginDirectories):
+ (WebCore::PluginDatabase::isPreferredPluginDirectory):
+ (WebCore::PluginDatabase::getPluginPathsInDirectories):
+ (WebCore::fillBufferWithContentsOfFile):
+ (WebCore::readUTF8String):
+ (WebCore::readTime):
+ (WebCore::PluginDatabase::loadPersistentMetadataCache):
+ (WebCore::writeUTF8String):
+ (WebCore::writeTime):
+ (WebCore::PluginDatabase::updatePersistentMetadataCache):
+ (WebCore::PluginDatabase::isPersistentMetadataCacheEnabled):
+ (WebCore::PluginDatabase::setPersistentMetadataCacheEnabled):
+ (WebCore::PluginDatabase::persistentMetadataCachePath):
+ (WebCore::PluginDatabase::setPersistentMetadataCachePath):
+ * Plugins/PluginDatabase.h: Renamed from Source/WebCore/plugins/PluginDatabase.h.
+ (WebCore::PluginDatabase::setPluginDirectories):
+ (WebCore::PluginDatabase::pluginDirectories):
+ * Plugins/PluginDatabaseWin.cpp: Renamed from Source/WebCore/plugins/win/PluginDatabaseWin.cpp.
+ (WebCore::addPluginPathsFromRegistry):
+ (WebCore::PluginDatabase::getPluginPathsInDirectories):
+ (WebCore::parseVersionString):
+ (WebCore::compareVersions):
+ (WebCore::addMozillaPluginDirectories):
+ (WebCore::addWindowsMediaPlayerPluginDirectory):
+ (WebCore::addAdobeAcrobatPluginDirectory):
+ (WebCore::addJavaPluginDirectory):
+ (WebCore::safariPluginsDirectory):
+ (WebCore::addMacromediaPluginDirectories):
+ (WebCore::PluginDatabase::defaultPluginDirectories):
+ (WebCore::PluginDatabase::isPreferredPluginDirectory):
+ * Plugins/PluginDebug.cpp: Renamed from Source/WebCore/plugins/PluginDebug.cpp.
+ (WebCore::prettyNameForNPError):
+ (WebCore::prettyNameForDrawingModel):
+ (WebCore::prettyNameForEventModel):
+ (WebCore::prettyNameForNPNVariable):
+ (WebCore::prettyNameForNPPVariable):
+ (WebCore::prettyNameForNPNURLVariable):
+ * Plugins/PluginDebug.h: Renamed from Source/WebCore/plugins/PluginDebug.h.
+ * Plugins/PluginMessageThrottlerWin.cpp: Renamed from Source/WebCore/plugins/win/PluginMessageThrottlerWin.cpp.
+ (WebCore::PluginMessageThrottlerWin::PluginMessageThrottlerWin):
+ (WebCore::PluginMessageThrottlerWin::~PluginMessageThrottlerWin):
+ (WebCore::PluginMessageThrottlerWin::appendMessage):
+ (WebCore::PluginMessageThrottlerWin::processQueuedMessage):
+ (WebCore::PluginMessageThrottlerWin::messageThrottleTimerFired):
+ (WebCore::PluginMessageThrottlerWin::allocateMessage):
+ (WebCore::PluginMessageThrottlerWin::isInlineMessage):
+ (WebCore::PluginMessageThrottlerWin::freeMessage):
+ * Plugins/PluginMessageThrottlerWin.h: Renamed from Source/WebCore/plugins/win/PluginMessageThrottlerWin.h.
+ * Plugins/PluginPackage.cpp: Renamed from Source/WebCore/plugins/PluginPackage.cpp.
+ (WebCore::PluginPackage::~PluginPackage):
+ (WebCore::PluginPackage::freeLibrarySoon):
+ (WebCore::PluginPackage::freeLibraryTimerFired):
+ (WebCore::PluginPackage::compare):
+ (WebCore::PluginPackage::PluginPackage):
+ (WebCore::PluginPackage::unload):
+ (WebCore::PluginPackage::unloadWithoutShutdown):
+ (WebCore::PluginPackage::setEnabled):
+ (WebCore::PluginPackage::createPackage):
+ (WebCore::PluginPackage::createPackageFromCache):
+ (WebCore::PluginPackage::determineQuirks):
+ (WebCore::PluginPackage::determineModuleVersionFromDescription):
+ (WebCore::getListFromVariantArgs):
+ (WebCore::makeSource):
+ (WebCore::NPN_Evaluate):
+ (WebCore::NPN_Invoke):
+ (WebCore::PluginPackage::initializeBrowserFuncs):
+ (WebCore::PluginPackage::hash):
+ (WebCore::PluginPackage::equal):
+ (WebCore::PluginPackage::compareFileVersion):
+ (WebCore::PluginPackage::ensurePluginLoaded):
+ * Plugins/PluginPackage.h: Renamed from Source/WebCore/plugins/PluginPackage.h.
+ (WebCore::PluginPackage::name):
+ (WebCore::PluginPackage::description):
+ (WebCore::PluginPackage::path):
+ (WebCore::PluginPackage::fileName):
+ (WebCore::PluginPackage::parentDirectory):
+ (WebCore::PluginPackage::module):
+ (WebCore::PluginPackage::lastModified):
+ (WebCore::PluginPackage::mimeToDescriptions):
+ (WebCore::PluginPackage::mimeToExtensions):
+ (WebCore::PluginPackage::isEnabled):
+ (WebCore::PluginPackage::pluginFuncs):
+ (WebCore::PluginPackage::quirks):
+ (WebCore::PluginPackage::version):
+ (WebCore::PluginPackage::fullMIMEDescription):
+ (WebCore::PluginPackageHash::hash):
+ (WebCore::PluginPackageHash::equal):
+ * Plugins/PluginPackageWin.cpp: Renamed from Source/WebCore/plugins/win/PluginPackageWin.cpp.
+ (WebCore::getVersionInfo):
+ (WebCore::PluginPackage::isPluginBlacklisted):
+ (WebCore::PluginPackage::determineQuirks):
+ (WebCore::PluginPackage::fetchInfo):
+ (WebCore::PluginPackage::load):
+ (WebCore::PluginPackage::hash):
+ (WebCore::PluginPackage::equal):
+ (WebCore::PluginPackage::NPVersion):
+ * Plugins/PluginQuirkSet.h: Renamed from Source/WebCore/plugins/PluginQuirkSet.h.
+ (WebCore::PluginQuirkSet::PluginQuirkSet):
+ (WebCore::PluginQuirkSet::add):
+ (WebCore::PluginQuirkSet::contains):
+ * Plugins/PluginStream.cpp: Renamed from Source/WebCore/plugins/PluginStream.cpp.
+ (WebCore::streams):
+ (WebCore::PluginStream::PluginStream):
+ (WebCore::PluginStream::~PluginStream):
+ (WebCore::PluginStream::start):
+ (WebCore::PluginStream::stop):
+ (WebCore::lastModifiedDate):
+ (WebCore::PluginStream::startStream):
+ (WebCore::PluginStream::ownerForStream):
+ (WebCore::PluginStream::cancelAndDestroyStream):
+ (WebCore::PluginStream::destroyStream):
+ (WebCore::PluginStream::delayDeliveryTimerFired):
+ (WebCore::PluginStream::deliverData):
+ (WebCore::PluginStream::sendJavaScriptStream):
+ (WebCore::PluginStream::didReceiveResponse):
+ (WebCore::PluginStream::didReceiveData):
+ (WebCore::PluginStream::didFail):
+ (WebCore::PluginStream::didFinishLoading):
+ (WebCore::PluginStream::wantsAllStreams):
+ * Plugins/PluginStream.h: Renamed from Source/WebCore/plugins/PluginStream.h.
+ (WebCore::PluginStreamClient::~PluginStreamClient):
+ (WebCore::PluginStreamClient::streamDidFinishLoading):
+ (WebCore::PluginStream::create):
+ (WebCore::PluginStream::setLoadManually):
+ * Plugins/PluginView.cpp: Renamed from Source/WebCore/plugins/PluginView.cpp.
+ (WebCore::instanceMap):
+ (WebCore::scriptStringIfJavaScriptURL):
+ (WebCore::PluginView::popPopupsStateTimerFired):
+ (WebCore::PluginView::windowClipRect):
+ (WebCore::PluginView::setFrameRect):
+ (WebCore::PluginView::frameRectsChanged):
+ (WebCore::PluginView::clipRectChanged):
+ (WebCore::PluginView::handleEvent):
+ (WebCore::PluginView::init):
+ (WebCore::PluginView::startOrAddToUnstartedList):
+ (WebCore::PluginView::start):
+ (WebCore::PluginView::mediaCanStart):
+ (WebCore::PluginView::~PluginView):
+ (WebCore::PluginView::stop):
+ (WebCore::PluginView::setCurrentPluginView):
+ (WebCore::PluginView::currentPluginView):
+ (WebCore::createUTF8String):
+ (WebCore::PluginView::performRequest):
+ (WebCore::PluginView::requestTimerFired):
+ (WebCore::PluginView::scheduleRequest):
+ (WebCore::PluginView::load):
+ (WebCore::makeURL):
+ (WebCore::PluginView::getURLNotify):
+ (WebCore::PluginView::getURL):
+ (WebCore::PluginView::postURLNotify):
+ (WebCore::PluginView::postURL):
+ (WebCore::PluginView::newStream):
+ (WebCore::PluginView::write):
+ (WebCore::PluginView::destroyStream):
+ (WebCore::PluginView::status):
+ (WebCore::PluginView::setValue):
+ (WebCore::PluginView::invalidateTimerFired):
+ (WebCore::PluginView::pushPopupsEnabledState):
+ (WebCore::PluginView::popPopupsEnabledState):
+ (WebCore::PluginView::arePopupsAllowed):
+ (WebCore::PluginView::setJavaScriptPaused):
+ (WebCore::PluginView::npObject):
+ (WebCore::PluginView::bindingInstance):
+ (WebCore::PluginView::disconnectStream):
+ (WebCore::PluginView::setParameters):
+ (WebCore::PluginView::PluginView):
+ (WebCore::PluginView::focusPluginElement):
+ (WebCore::PluginView::didReceiveResponse):
+ (WebCore::PluginView::didReceiveData):
+ (WebCore::PluginView::didFinishLoading):
+ (WebCore::PluginView::didFail):
+ (WebCore::PluginView::setCallingPlugin):
+ (WebCore::PluginView::isCallingPlugin):
+ (WebCore::PluginView::create):
+ (WebCore::PluginView::freeStringArray):
+ (WebCore::startsWithBlankLine):
+ (WebCore::locationAfterFirstBlankLine):
+ (WebCore::findEOL):
+ (WebCore::capitalizeRFC822HeaderFieldName):
+ (WebCore::parseRFC822HeaderFields):
+ (WebCore::PluginView::handlePost):
+ (WebCore::PluginView::invalidateWindowlessPluginRect):
+ (WebCore::PluginView::paintMissingPluginIcon):
+ (WebCore::PluginView::userAgent):
+ (WebCore::PluginView::userAgentStatic):
+ (WebCore::PluginView::lifeSupportTimerFired):
+ (WebCore::PluginView::keepAlive):
+ (WebCore::PluginView::getValueStatic):
+ (WebCore::PluginView::getValue):
+ (WebCore::getFrame):
+ (WebCore::PluginView::getValueForURL):
+ (WebCore::PluginView::setValueForURL):
+ (WebCore::PluginView::getAuthenticationInfo):
+ (WebCore::PluginView::privateBrowsingStateChanged):
+ * Plugins/PluginView.h: Renamed from Source/WebCore/plugins/PluginView.h.
+ (WebCore::PluginRequest::PluginRequest):
+ (WebCore::PluginRequest::frameLoadRequest):
+ (WebCore::PluginRequest::notifyData):
+ (WebCore::PluginRequest::sendNotification):
+ (WebCore::PluginRequest::shouldAllowPopups):
+ (WebCore::PluginManualLoader::~PluginManualLoader):
+ (WebCore::PluginView::plugin):
+ (WebCore::PluginView::instance):
+ (WebCore::PluginView::status):
+ (WebCore::PluginView::streamDidFinishLoading):
+ (WebCore::PluginView::parentFrame):
+ (WebCore::PluginView::pluginsPage):
+ (WebCore::PluginView::mimeType):
+ (WebCore::PluginView::url):
+ (WebCore::PluginView::pluginWndProc):
+ (WebCore::PluginView::platformPluginWidget):
+ (WebCore::PluginView::setPlatformPluginWidget):
+ (WebCore::toPluginView):
+ * Plugins/PluginViewWin.cpp: Renamed from Source/WebCore/plugins/win/PluginViewWin.cpp.
+ (windowHandleForPageClient):
+ (WebCore::PluginView::hookedBeginPaint):
+ (WebCore::PluginView::hookedEndPaint):
+ (WebCore::hook):
+ (WebCore::setUpOffscreenPaintingHooks):
+ (WebCore::registerPluginView):
+ (WebCore::PluginView::PluginViewWndProc):
+ (WebCore::isWindowsMessageUserGesture):
+ (WebCore::contentsToNativeWindow):
+ (WebCore::PluginView::wndProc):
+ (WebCore::PluginView::updatePluginWidget):
+ (WebCore::PluginView::setFocus):
+ (WebCore::PluginView::show):
+ (WebCore::PluginView::hide):
+ (WebCore::PluginView::dispatchNPEvent):
+ (WebCore::PluginView::paintIntoTransformedContext):
+ (WebCore::PluginView::paintWindowedPluginIntoContext):
+ (WebCore::PluginView::paint):
+ (WebCore::PluginView::handleKeyboardEvent):
+ (WebCore::PluginView::handleMouseEvent):
+ (WebCore::PluginView::setParent):
+ (WebCore::PluginView::setParentVisible):
+ (WebCore::PluginView::setNPWindowRect):
+ (WebCore::PluginView::handlePostReadFile):
+ (WebCore::PluginView::platformGetValueStatic):
+ (WebCore::PluginView::platformGetValue):
+ (WebCore::PluginView::invalidateRect):
+ (WebCore::PluginView::invalidateRegion):
+ (WebCore::PluginView::forceRedraw):
+ (WebCore::PluginView::platformStart):
+ (WebCore::PluginView::platformDestroy):
+ (WebCore::PluginView::snapshot):
+ * Plugins/npapi.cpp: Renamed from Source/WebCore/plugins/npapi.cpp.
+ (pluginViewForInstance):
+ (NPN_MemAlloc):
+ (NPN_MemFree):
+ (NPN_MemFlush):
+ (NPN_ReloadPlugins):
+ (NPN_RequestRead):
+ (NPN_GetURLNotify):
+ (NPN_GetURL):
+ (NPN_PostURLNotify):
+ (NPN_PostURL):
+ (NPN_NewStream):
+ (NPN_Write):
+ (NPN_DestroyStream):
+ (NPN_UserAgent):
+ (NPN_Status):
+ (NPN_InvalidateRect):
+ (NPN_InvalidateRegion):
+ (NPN_ForceRedraw):
+ (NPN_GetValue):
+ (NPN_SetValue):
+ (NPN_GetJavaEnv):
+ (NPN_GetJavaPeer):
+ (NPN_PushPopupsEnabledState):
+ (NPN_PopPopupsEnabledState):
+ (NPN_PluginThreadAsyncCall):
+ (NPN_GetValueForURL):
+ (NPN_SetValueForURL):
+ (NPN_GetAuthenticationInfo):
+ (NPN_PopUpContextMenu):
+
</ins><span class="cx"> 2015-01-08 Dean Jackson <dino@apple.com>
</span><span class="cx">
</span><span class="cx"> Text not drawn or white-on-white for "Close Page"/"Go Back" button on safe browsing warning page
</span></span></pre></div>
<a id="trunkSourceWebKitwinPluginsPaintHooksasmfromrev178217trunkSourceWebCorepluginswinPaintHooksasm"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebKit/win/Plugins/PaintHooks.asm (from rev 178217, trunk/Source/WebCore/plugins/win/PaintHooks.asm) (0 => 178219)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/win/Plugins/PaintHooks.asm         (rev 0)
+++ trunk/Source/WebKit/win/Plugins/PaintHooks.asm        2015-01-10 00:16:52 UTC (rev 178219)
</span><span class="lines">@@ -0,0 +1,50 @@
</span><ins>+;/*
+; Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
+;
+; This library is free software; you can redistribute it and/or
+; modify it under the terms of the GNU Library General Public
+; License as published by the Free Software Foundation; either
+; version 2 of the License, or (at your option) any later version.
+;
+; This library is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+; Library General Public License for more details.
+;
+; You should have received a copy of the GNU Library General Public License
+; along with this library; see the file COPYING.LIB. If not, write to
+; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+; Boston, MA 02110-1301, USA.
+;*/
+
+;HDC __stdcall _HBeginPaint(HWND hWnd, LPPAINTSTRUCT lpPaint);
+
+PUBLIC _HBeginPaint
+
+_TEXT SEGMENT
+
+_HBeginPaint PROC
+ mov r10,rcx
+ mov eax,1017h
+ syscall
+ ret
+_HBeginPaint ENDP
+
+_TEXT ENDS
+
+;BOOL __stdcall _HEndPaint(HWND hWnd, const PAINTSTRUCT* lpPaint);
+
+PUBLIC _HEndPaint
+
+_TEXT SEGMENT
+
+_HEndPaint PROC
+ mov r10,rcx
+ mov eax,1019h
+ syscall
+ ret
+_HEndPaint ENDP
+
+_TEXT ENDS
+
+END
</ins></span></pre></div>
<a id="trunkSourceWebKitwinPluginsPluginDatabasecppfromrev178217trunkSourceWebCorepluginsPluginDatabasecpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebKit/win/Plugins/PluginDatabase.cpp (from rev 178217, trunk/Source/WebCore/plugins/PluginDatabase.cpp) (0 => 178219)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/win/Plugins/PluginDatabase.cpp         (rev 0)
+++ trunk/Source/WebKit/win/Plugins/PluginDatabase.cpp        2015-01-10 00:16:52 UTC (rev 178219)
</span><span class="lines">@@ -0,0 +1,677 @@
</span><ins>+/*
+ * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2008 Collabora, Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "PluginDatabase.h"
+
+#include "Frame.h"
+#include "URL.h"
+#include "PluginPackage.h"
+#if ENABLE(NETSCAPE_PLUGIN_METADATA_CACHE)
+#include "FileSystem.h"
+#endif
+#include <stdlib.h>
+#include <wtf/text/CString.h>
+
+namespace WebCore {
+
+typedef HashMap<String, RefPtr<PluginPackage> > PluginPackageByNameMap;
+
+#if ENABLE(NETSCAPE_PLUGIN_METADATA_CACHE)
+static const size_t maximumPersistentPluginMetadataCacheSize = 32768;
+
+static bool gPersistentPluginMetadataCacheIsEnabled;
+
+String& persistentPluginMetadataCachePath()
+{
+ DEPRECATED_DEFINE_STATIC_LOCAL(String, cachePath, ());
+ return cachePath;
+}
+#endif
+
+PluginDatabase::PluginDatabase()
+#if ENABLE(NETSCAPE_PLUGIN_METADATA_CACHE)
+ : m_persistentMetadataCacheIsLoaded(false)
+#endif
+{
+}
+
+PluginDatabase* PluginDatabase::installedPlugins(bool populate)
+{
+ static PluginDatabase* plugins = 0;
+
+ if (!plugins) {
+ plugins = new PluginDatabase;
+
+ if (populate) {
+ plugins->setPluginDirectories(PluginDatabase::defaultPluginDirectories());
+ plugins->refresh();
+ }
+ }
+
+ return plugins;
+}
+
+bool PluginDatabase::isMIMETypeRegistered(const String& mimeType)
+{
+ if (mimeType.isNull())
+ return false;
+ if (m_registeredMIMETypes.contains(mimeType))
+ return true;
+ // No plugin was found, try refreshing the database and searching again
+ return (refresh() && m_registeredMIMETypes.contains(mimeType));
+}
+
+void PluginDatabase::addExtraPluginDirectory(const String& directory)
+{
+ m_pluginDirectories.append(directory);
+ refresh();
+}
+
+bool PluginDatabase::refresh()
+{
+#if ENABLE(NETSCAPE_PLUGIN_METADATA_CACHE)
+ if (!m_persistentMetadataCacheIsLoaded)
+ loadPersistentMetadataCache();
+#endif
+ bool pluginSetChanged = false;
+
+ if (!m_plugins.isEmpty()) {
+ PluginSet pluginsToUnload;
+ getDeletedPlugins(pluginsToUnload);
+
+ // Unload plugins
+ PluginSet::const_iterator end = pluginsToUnload.end();
+ for (PluginSet::const_iterator it = pluginsToUnload.begin(); it != end; ++it)
+ remove(it->get());
+
+ pluginSetChanged = !pluginsToUnload.isEmpty();
+ }
+
+ HashSet<String> paths;
+ getPluginPathsInDirectories(paths);
+
+ HashMap<String, time_t> pathsWithTimes;
+
+ // We should only skip unchanged files if we didn't remove any plugins above. If we did remove
+ // any plugins, we need to look at every plugin file so that, e.g., if the user has two versions
+ // of RealPlayer installed and just removed the newer one, we'll pick up the older one.
+ bool shouldSkipUnchangedFiles = !pluginSetChanged;
+
+ HashSet<String>::const_iterator pathsEnd = paths.end();
+ for (HashSet<String>::const_iterator it = paths.begin(); it != pathsEnd; ++it) {
+ time_t lastModified;
+ if (!getFileModificationTime(*it, lastModified))
+ continue;
+
+ pathsWithTimes.add(*it, lastModified);
+
+ // If the path's timestamp hasn't changed since the last time we ran refresh(), we don't have to do anything.
+ if (shouldSkipUnchangedFiles && m_pluginPathsWithTimes.get(*it) == lastModified)
+ continue;
+
+ if (RefPtr<PluginPackage> oldPackage = m_pluginsByPath.get(*it)) {
+ ASSERT(!shouldSkipUnchangedFiles || oldPackage->lastModified() != lastModified);
+ remove(oldPackage.get());
+ }
+
+ RefPtr<PluginPackage> package = PluginPackage::createPackage(*it, lastModified);
+ if (package && add(package.release()))
+ pluginSetChanged = true;
+ }
+
+ // Cache all the paths we found with their timestamps for next time.
+ pathsWithTimes.swap(m_pluginPathsWithTimes);
+
+ if (!pluginSetChanged)
+ return false;
+
+#if ENABLE(NETSCAPE_PLUGIN_METADATA_CACHE)
+ updatePersistentMetadataCache();
+#endif
+
+ m_registeredMIMETypes.clear();
+
+ // Register plug-in MIME types
+ PluginSet::const_iterator end = m_plugins.end();
+ for (PluginSet::const_iterator it = m_plugins.begin(); it != end; ++it) {
+ // Get MIME types
+ MIMEToDescriptionsMap::const_iterator map_it = (*it)->mimeToDescriptions().begin();
+ MIMEToDescriptionsMap::const_iterator map_end = (*it)->mimeToDescriptions().end();
+ for (; map_it != map_end; ++map_it)
+ m_registeredMIMETypes.add(map_it->key);
+ }
+
+ return true;
+}
+
+Vector<PluginPackage*> PluginDatabase::plugins() const
+{
+ Vector<PluginPackage*> result;
+
+ PluginSet::const_iterator end = m_plugins.end();
+ for (PluginSet::const_iterator it = m_plugins.begin(); it != end; ++it)
+ result.append((*it).get());
+
+ return result;
+}
+
+int PluginDatabase::preferredPluginCompare(const void* a, const void* b)
+{
+ PluginPackage* pluginA = *static_cast<PluginPackage* const*>(a);
+ PluginPackage* pluginB = *static_cast<PluginPackage* const*>(b);
+
+ return pluginA->compare(*pluginB);
+}
+
+PluginPackage* PluginDatabase::pluginForMIMEType(const String& mimeType)
+{
+ if (mimeType.isEmpty())
+ return 0;
+
+ String key = mimeType.lower();
+ PluginSet::const_iterator end = m_plugins.end();
+ PluginPackage* preferredPlugin = m_preferredPlugins.get(key);
+ if (preferredPlugin
+ && preferredPlugin->isEnabled()
+ && preferredPlugin->mimeToDescriptions().contains(key)) {
+ return preferredPlugin;
+ }
+
+ Vector<PluginPackage*, 2> pluginChoices;
+
+ for (PluginSet::const_iterator it = m_plugins.begin(); it != end; ++it) {
+ PluginPackage* plugin = (*it).get();
+
+ if (!plugin->isEnabled())
+ continue;
+
+ if (plugin->mimeToDescriptions().contains(key)) {
+#if ENABLE(NETSCAPE_PLUGIN_METADATA_CACHE)
+ if (!plugin->ensurePluginLoaded())
+ continue;
+#endif
+ pluginChoices.append(plugin);
+ }
+ }
+
+ if (pluginChoices.isEmpty())
+ return 0;
+
+ qsort(pluginChoices.data(), pluginChoices.size(), sizeof(PluginPackage*), PluginDatabase::preferredPluginCompare);
+
+ return pluginChoices[0];
+}
+
+String PluginDatabase::MIMETypeForExtension(const String& extension) const
+{
+ if (extension.isEmpty())
+ return String();
+
+ PluginSet::const_iterator end = m_plugins.end();
+ String mimeType;
+ Vector<PluginPackage*, 2> pluginChoices;
+ HashMap<PluginPackage*, String> mimeTypeForPlugin;
+
+ for (PluginSet::const_iterator it = m_plugins.begin(); it != end; ++it) {
+ if (!(*it)->isEnabled())
+ continue;
+
+ MIMEToExtensionsMap::const_iterator mime_end = (*it)->mimeToExtensions().end();
+
+ for (MIMEToExtensionsMap::const_iterator mime_it = (*it)->mimeToExtensions().begin(); mime_it != mime_end; ++mime_it) {
+ mimeType = mime_it->key;
+ PluginPackage* preferredPlugin = m_preferredPlugins.get(mimeType);
+ const Vector<String>& extensions = mime_it->value;
+ bool foundMapping = false;
+ for (unsigned i = 0; i < extensions.size(); i++) {
+ if (equalIgnoringCase(extensions[i], extension)) {
+ PluginPackage* plugin = (*it).get();
+
+ if (preferredPlugin && PluginPackage::equal(*plugin, *preferredPlugin))
+ return mimeType;
+
+#if ENABLE(NETSCAPE_PLUGIN_METADATA_CACHE)
+ if (!plugin->ensurePluginLoaded())
+ continue;
+#endif
+ pluginChoices.append(plugin);
+ mimeTypeForPlugin.add(plugin, mimeType);
+ foundMapping = true;
+ break;
+ }
+ }
+ if (foundMapping)
+ break;
+ }
+ }
+
+ if (pluginChoices.isEmpty())
+ return String();
+
+ qsort(pluginChoices.data(), pluginChoices.size(), sizeof(PluginPackage*), PluginDatabase::preferredPluginCompare);
+
+ return mimeTypeForPlugin.get(pluginChoices[0]);
+}
+
+PluginPackage* PluginDatabase::findPlugin(const URL& url, String& mimeType)
+{
+ if (!mimeType.isEmpty())
+ return pluginForMIMEType(mimeType);
+
+ String filename = url.lastPathComponent();
+ if (filename.endsWith('/'))
+ return 0;
+
+ int extensionPos = filename.reverseFind('.');
+ if (extensionPos == -1)
+ return 0;
+
+ String mimeTypeForExtension = MIMETypeForExtension(filename.substring(extensionPos + 1));
+ PluginPackage* plugin = pluginForMIMEType(mimeTypeForExtension);
+ if (!plugin) {
+ // FIXME: if no plugin could be found, query Windows for the mime type
+ // corresponding to the extension.
+ return 0;
+ }
+
+ mimeType = mimeTypeForExtension;
+ return plugin;
+}
+
+void PluginDatabase::setPreferredPluginForMIMEType(const String& mimeType, PluginPackage* plugin)
+{
+ if (!plugin || plugin->mimeToExtensions().contains(mimeType))
+ m_preferredPlugins.set(mimeType.lower(), plugin);
+}
+
+bool PluginDatabase::fileExistsAndIsNotDisabled(const String& filePath) const
+{
+ // Skip plugin files that are disabled by filename.
+ if (m_disabledPluginFiles.contains(pathGetFileName(filePath)))
+ return false;
+
+ return fileExists(filePath);
+}
+
+void PluginDatabase::getDeletedPlugins(PluginSet& plugins) const
+{
+ PluginSet::const_iterator end = m_plugins.end();
+ for (PluginSet::const_iterator it = m_plugins.begin(); it != end; ++it) {
+ if (!fileExistsAndIsNotDisabled((*it)->path()))
+ plugins.add(*it);
+ }
+}
+
+bool PluginDatabase::add(PassRefPtr<PluginPackage> prpPackage)
+{
+ ASSERT_ARG(prpPackage, prpPackage);
+
+ RefPtr<PluginPackage> package = prpPackage;
+
+ if (!m_plugins.add(package).isNewEntry)
+ return false;
+
+ m_pluginsByPath.add(package->path(), package);
+ return true;
+}
+
+void PluginDatabase::remove(PluginPackage* package)
+{
+ MIMEToExtensionsMap::const_iterator it = package->mimeToExtensions().begin();
+ MIMEToExtensionsMap::const_iterator end = package->mimeToExtensions().end();
+ for ( ; it != end; ++it) {
+ PluginPackageByNameMap::iterator packageInMap = m_preferredPlugins.find(it->key);
+ if (packageInMap != m_preferredPlugins.end() && packageInMap->value == package)
+ m_preferredPlugins.remove(packageInMap);
+ }
+
+ m_plugins.remove(package);
+ m_pluginsByPath.remove(package->path());
+}
+
+void PluginDatabase::clear()
+{
+ m_plugins.clear();
+ m_pluginsByPath.clear();
+ m_pluginPathsWithTimes.clear();
+ m_registeredMIMETypes.clear();
+ m_preferredPlugins.clear();
+#if ENABLE(NETSCAPE_PLUGIN_METADATA_CACHE)
+ m_persistentMetadataCacheIsLoaded = false;
+#endif
+}
+
+bool PluginDatabase::removeDisabledPluginFile(const String& fileName)
+{
+ return m_disabledPluginFiles.remove(fileName);
+}
+
+bool PluginDatabase::addDisabledPluginFile(const String& fileName)
+{
+ return m_disabledPluginFiles.add(fileName).isNewEntry;
+}
+
+#if (!OS(WINDOWS) || !ENABLE(NETSCAPE_PLUGIN_API))
+// For Safari/Win the following three methods are implemented
+// in PluginDatabaseWin.cpp, but if we can use WebCore constructs
+// for the logic we should perhaps move it here under XP_WIN?
+
+Vector<String> PluginDatabase::defaultPluginDirectories()
+{
+ Vector<String> paths;
+
+ // Add paths specific to each platform
+#if defined(XP_UNIX)
+ String userPluginPath = homeDirectoryPath();
+ userPluginPath.append(String("/.mozilla/plugins"));
+ paths.append(userPluginPath);
+
+ userPluginPath = homeDirectoryPath();
+ userPluginPath.append(String("/.netscape/plugins"));
+ paths.append(userPluginPath);
+
+ paths.append("/usr/lib/browser/plugins");
+ paths.append("/usr/local/lib/mozilla/plugins");
+ paths.append("/usr/lib/firefox/plugins");
+ paths.append("/usr/lib64/browser-plugins");
+ paths.append("/usr/lib/browser-plugins");
+ paths.append("/usr/lib/mozilla/plugins");
+ paths.append("/usr/local/netscape/plugins");
+ paths.append("/opt/mozilla/plugins");
+ paths.append("/opt/mozilla/lib/plugins");
+ paths.append("/opt/netscape/plugins");
+ paths.append("/opt/netscape/communicator/plugins");
+ paths.append("/usr/lib/netscape/plugins");
+ paths.append("/usr/lib/netscape/plugins-libc5");
+ paths.append("/usr/lib/netscape/plugins-libc6");
+ paths.append("/usr/lib64/netscape/plugins");
+ paths.append("/usr/lib64/mozilla/plugins");
+ paths.append("/usr/lib/nsbrowser/plugins");
+ paths.append("/usr/lib64/nsbrowser/plugins");
+
+ String mozHome(getenv("MOZILLA_HOME"));
+ mozHome.append("/plugins");
+ paths.append(mozHome);
+
+ Vector<String> mozPaths;
+ String mozPath(getenv("MOZ_PLUGIN_PATH"));
+ mozPath.split(UChar(':'), /* allowEmptyEntries */ false, mozPaths);
+ paths.appendVector(mozPaths);
+#elif defined(XP_MACOSX)
+ String userPluginPath = homeDirectoryPath();
+ userPluginPath.append(String("/Library/Internet Plug-Ins"));
+ paths.append(userPluginPath);
+ paths.append("/Library/Internet Plug-Ins");
+#elif defined(XP_WIN)
+ String userPluginPath = homeDirectoryPath();
+ userPluginPath.append(String("\\Application Data\\Mozilla\\plugins"));
+ paths.append(userPluginPath);
+#endif
+
+ return paths;
+}
+
+bool PluginDatabase::isPreferredPluginDirectory(const String& path)
+{
+ String preferredPath = homeDirectoryPath();
+
+#if defined(XP_UNIX)
+ preferredPath.append(String("/.mozilla/plugins"));
+#elif defined(XP_MACOSX)
+ preferredPath.append(String("/Library/Internet Plug-Ins"));
+#elif defined(XP_WIN)
+ preferredPath.append(String("\\Application Data\\Mozilla\\plugins"));
+#endif
+
+ // TODO: We should normalize the path before doing a comparison.
+ return path == preferredPath;
+}
+
+void PluginDatabase::getPluginPathsInDirectories(HashSet<String>& paths) const
+{
+ // FIXME: This should be a case insensitive set.
+ HashSet<String> uniqueFilenames;
+
+#if defined(XP_UNIX)
+ String fileNameFilter("*.so");
+#else
+ String fileNameFilter("");
+#endif
+
+ Vector<String>::const_iterator dirsEnd = m_pluginDirectories.end();
+ for (Vector<String>::const_iterator dIt = m_pluginDirectories.begin(); dIt != dirsEnd; ++dIt) {
+ Vector<String> pluginPaths = listDirectory(*dIt, fileNameFilter);
+ Vector<String>::const_iterator pluginsEnd = pluginPaths.end();
+ for (Vector<String>::const_iterator pIt = pluginPaths.begin(); pIt != pluginsEnd; ++pIt) {
+ if (!fileExistsAndIsNotDisabled(*pIt))
+ continue;
+
+ paths.add(*pIt);
+ }
+ }
+}
+
+#endif // !OS(WINDOWS)
+
+#if ENABLE(NETSCAPE_PLUGIN_METADATA_CACHE)
+
+static void fillBufferWithContentsOfFile(PlatformFileHandle file, Vector<char>& buffer)
+{
+ size_t bufferSize = 0;
+ size_t bufferCapacity = 1024;
+ buffer.resize(bufferCapacity);
+
+ do {
+ bufferSize += readFromFile(file, buffer.data() + bufferSize, bufferCapacity - bufferSize);
+ if (bufferSize == bufferCapacity) {
+ if (bufferCapacity < maximumPersistentPluginMetadataCacheSize) {
+ bufferCapacity *= 2;
+ buffer.resize(bufferCapacity);
+ } else {
+ buffer.clear();
+ return;
+ }
+ } else
+ break;
+ } while (true);
+
+ buffer.shrink(bufferSize);
+}
+
+static bool readUTF8String(String& resultString, char*& start, const char* end)
+{
+ if (start >= end)
+ return false;
+
+ int len = strlen(start);
+ resultString = String::fromUTF8(start, len);
+ start += len + 1;
+
+ return true;
+}
+
+static bool readTime(time_t& resultTime, char*& start, const char* end)
+{
+ if (start + sizeof(time_t) >= end)
+ return false;
+
+ // The stream is not necessary aligned.
+ memcpy(&resultTime, start, sizeof(time_t));
+ start += sizeof(time_t);
+
+ return true;
+}
+
+static const char schemaVersion = '1';
+static const char persistentPluginMetadataCacheFilename[] = "PluginMetadataCache.bin";
+
+void PluginDatabase::loadPersistentMetadataCache()
+{
+ if (!isPersistentMetadataCacheEnabled() || persistentMetadataCachePath().isEmpty())
+ return;
+
+ PlatformFileHandle file;
+ String absoluteCachePath = pathByAppendingComponent(persistentMetadataCachePath(), persistentPluginMetadataCacheFilename);
+ file = openFile(absoluteCachePath, OpenForRead);
+
+ if (!isHandleValid(file))
+ return;
+
+ // Mark cache as loaded regardless of success or failure. If
+ // there's error in the cache, we won't try to load it anymore.
+ m_persistentMetadataCacheIsLoaded = true;
+
+ Vector<char> fileContents;
+ fillBufferWithContentsOfFile(file, fileContents);
+ closeFile(file);
+
+ if (fileContents.size() < 2 || fileContents.first() != schemaVersion || fileContents.last() != '\0') {
+ LOG_ERROR("Unable to read plugin metadata cache: corrupt schema");
+ deleteFile(absoluteCachePath);
+ return;
+ }
+
+ char* bufferPos = fileContents.data() + 1;
+ char* end = fileContents.data() + fileContents.size();
+
+ PluginSet cachedPlugins;
+ HashMap<String, time_t> cachedPluginPathsWithTimes;
+ HashMap<String, RefPtr<PluginPackage> > cachedPluginsByPath;
+
+ while (bufferPos < end) {
+ String path;
+ time_t lastModified;
+ String name;
+ String desc;
+ String mimeDesc;
+ if (!(readUTF8String(path, bufferPos, end)
+ && readTime(lastModified, bufferPos, end)
+ && readUTF8String(name, bufferPos, end)
+ && readUTF8String(desc, bufferPos, end)
+ && readUTF8String(mimeDesc, bufferPos, end))) {
+ LOG_ERROR("Unable to read plugin metadata cache: corrupt data");
+ deleteFile(absoluteCachePath);
+ return;
+ }
+
+ // Skip metadata that points to plugins from directories that
+ // are not part of plugin directory list anymore.
+ String pluginDirectoryName = directoryName(path);
+ if (m_pluginDirectories.find(pluginDirectoryName) == WTF::notFound)
+ continue;
+
+ RefPtr<PluginPackage> package = PluginPackage::createPackageFromCache(path, lastModified, name, desc, mimeDesc);
+
+ if (package && cachedPlugins.add(package).isNewEntry) {
+ cachedPluginPathsWithTimes.add(package->path(), package->lastModified());
+ cachedPluginsByPath.add(package->path(), package);
+ }
+ }
+
+ m_plugins.swap(cachedPlugins);
+ m_pluginsByPath.swap(cachedPluginsByPath);
+ m_pluginPathsWithTimes.swap(cachedPluginPathsWithTimes);
+}
+
+static bool writeUTF8String(PlatformFileHandle file, const String& string)
+{
+ CString utf8String = string.utf8();
+ int length = utf8String.length() + 1;
+ return writeToFile(file, utf8String.data(), length) == length;
+}
+
+static bool writeTime(PlatformFileHandle file, const time_t& time)
+{
+ return writeToFile(file, reinterpret_cast<const char*>(&time), sizeof(time_t)) == sizeof(time_t);
+}
+
+void PluginDatabase::updatePersistentMetadataCache()
+{
+ if (!isPersistentMetadataCacheEnabled() || persistentMetadataCachePath().isEmpty())
+ return;
+
+ makeAllDirectories(persistentMetadataCachePath());
+ String absoluteCachePath = pathByAppendingComponent(persistentMetadataCachePath(), persistentPluginMetadataCacheFilename);
+ deleteFile(absoluteCachePath);
+
+ if (m_plugins.isEmpty())
+ return;
+
+ PlatformFileHandle file;
+ file = openFile(absoluteCachePath, OpenForWrite);
+
+ if (!isHandleValid(file)) {
+ LOG_ERROR("Unable to open plugin metadata cache for saving");
+ return;
+ }
+
+ char localSchemaVersion = schemaVersion;
+ if (writeToFile(file, &localSchemaVersion, 1) != 1) {
+ LOG_ERROR("Unable to write plugin metadata cache schema");
+ closeFile(file);
+ deleteFile(absoluteCachePath);
+ return;
+ }
+
+ PluginSet::const_iterator end = m_plugins.end();
+ for (PluginSet::const_iterator it = m_plugins.begin(); it != end; ++it) {
+ if (!(writeUTF8String(file, (*it)->path())
+ && writeTime(file, (*it)->lastModified())
+ && writeUTF8String(file, (*it)->name())
+ && writeUTF8String(file, (*it)->description())
+ && writeUTF8String(file, (*it)->fullMIMEDescription()))) {
+ LOG_ERROR("Unable to write plugin metadata to cache");
+ closeFile(file);
+ deleteFile(absoluteCachePath);
+ return;
+ }
+ }
+
+ closeFile(file);
+}
+
+bool PluginDatabase::isPersistentMetadataCacheEnabled()
+{
+ return gPersistentPluginMetadataCacheIsEnabled;
+}
+
+void PluginDatabase::setPersistentMetadataCacheEnabled(bool isEnabled)
+{
+ gPersistentPluginMetadataCacheIsEnabled = isEnabled;
+}
+
+String PluginDatabase::persistentMetadataCachePath()
+{
+ return WebCore::persistentPluginMetadataCachePath();
+}
+
+void PluginDatabase::setPersistentMetadataCachePath(const String& persistentMetadataCachePath)
+{
+ WebCore::persistentPluginMetadataCachePath() = persistentMetadataCachePath;
+}
+#endif
+}
</ins></span></pre></div>
<a id="trunkSourceWebKitwinPluginsPluginDatabasehfromrev178217trunkSourceWebCorepluginsPluginDatabaseh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebKit/win/Plugins/PluginDatabase.h (from rev 178217, trunk/Source/WebCore/plugins/PluginDatabase.h) (0 => 178219)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/win/Plugins/PluginDatabase.h         (rev 0)
+++ trunk/Source/WebKit/win/Plugins/PluginDatabase.h        2015-01-10 00:16:52 UTC (rev 178219)
</span><span class="lines">@@ -0,0 +1,118 @@
</span><ins>+/*
+ * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2008 Collabora, Ltd. All rights reserved.
+ * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef PluginDatabase_h
+#define PluginDatabase_h
+
+#include "PluginPackage.h"
+#include <wtf/HashSet.h>
+#include <wtf/Vector.h>
+#include <wtf/text/StringHash.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+ class Element;
+ class Frame;
+ class IntSize;
+ class URL;
+ class PluginDatabaseClient;
+ class PluginPackage;
+
+ typedef HashSet<RefPtr<PluginPackage>, PluginPackageHash, PluginPackageHashTraits> PluginSet;
+
+ class PluginDatabase {
+ WTF_MAKE_NONCOPYABLE(PluginDatabase); WTF_MAKE_FAST_ALLOCATED;
+ public:
+ PluginDatabase();
+
+ // The first call to installedPlugins creates the plugin database
+ // and by default populates it with the plugins installed on the system.
+ // For testing purposes, it is possible to not populate the database
+ // automatically, as the plugins might affect the DRT results by
+ // writing to a.o. stderr.
+ static PluginDatabase* installedPlugins(bool populate = true);
+
+ bool refresh();
+ void clear();
+ Vector<PluginPackage*> plugins() const;
+ bool isMIMETypeRegistered(const String& mimeType);
+ void addExtraPluginDirectory(const String&);
+
+ static bool isPreferredPluginDirectory(const String& directory);
+ static int preferredPluginCompare(const void*, const void*);
+
+ PluginPackage* findPlugin(const URL&, String& mimeType);
+ PluginPackage* pluginForMIMEType(const String& mimeType);
+ void setPreferredPluginForMIMEType(const String& mimeType, PluginPackage* plugin);
+
+ void setPluginDirectories(const Vector<String>& directories)
+ {
+ clear();
+ m_pluginDirectories = directories;
+ }
+
+ bool removeDisabledPluginFile(const String& fileName);
+ bool addDisabledPluginFile(const String& fileName);
+ static Vector<String> defaultPluginDirectories();
+ Vector<String> pluginDirectories() const { return m_pluginDirectories; }
+
+ String MIMETypeForExtension(const String& extension) const;
+#if ENABLE(NETSCAPE_PLUGIN_METADATA_CACHE)
+ static bool isPersistentMetadataCacheEnabled();
+ static void setPersistentMetadataCacheEnabled(bool isEnabled);
+ static String persistentMetadataCachePath();
+ static void setPersistentMetadataCachePath(const String& persistentMetadataCachePath);
+#endif
+
+ private:
+ void getPluginPathsInDirectories(HashSet<String>&) const;
+ void getDeletedPlugins(PluginSet&) const;
+ bool fileExistsAndIsNotDisabled(const String&) const;
+
+ // Returns whether the plugin was actually added or not (it won't be added if it's a duplicate of an existing plugin).
+ bool add(PassRefPtr<PluginPackage>);
+ void remove(PluginPackage*);
+#if ENABLE(NETSCAPE_PLUGIN_METADATA_CACHE)
+ void loadPersistentMetadataCache();
+ void updatePersistentMetadataCache();
+#endif
+
+ HashSet<String> m_disabledPluginFiles;
+ Vector<String> m_pluginDirectories;
+ HashSet<String> m_registeredMIMETypes;
+ PluginSet m_plugins;
+ HashMap<String, RefPtr<PluginPackage> > m_pluginsByPath;
+ HashMap<String, time_t> m_pluginPathsWithTimes;
+ HashMap<String, RefPtr<PluginPackage> > m_preferredPlugins;
+#if ENABLE(NETSCAPE_PLUGIN_METADATA_CACHE)
+ bool m_persistentMetadataCacheIsLoaded;
+#endif
+ };
+
+} // namespace WebCore
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebKitwinPluginsPluginDatabaseWincppfromrev178217trunkSourceWebCorepluginswinPluginDatabaseWincpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebKit/win/Plugins/PluginDatabaseWin.cpp (from rev 178217, trunk/Source/WebCore/plugins/win/PluginDatabaseWin.cpp) (0 => 178219)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/win/Plugins/PluginDatabaseWin.cpp         (rev 0)
+++ trunk/Source/WebKit/win/Plugins/PluginDatabaseWin.cpp        2015-01-10 00:16:52 UTC (rev 178219)
</span><span class="lines">@@ -0,0 +1,385 @@
</span><ins>+/*
+ * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2008 Collabora, Ltd. All rights reserved.
+ * Copyright (C) 2008-2009 Torch Mobile, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "PluginDatabase.h"
+
+#include "Frame.h"
+#include "URL.h"
+#include "PluginPackage.h"
+#include <wtf/WindowsExtras.h>
+
+namespace WebCore {
+
+static inline void addPluginPathsFromRegistry(HKEY rootKey, HashSet<String>& paths)
+{
+ HKEY key;
+ HRESULT result = RegOpenKeyExW(rootKey, L"Software\\MozillaPlugins", 0, KEY_ENUMERATE_SUB_KEYS, &key);
+
+ if (result != ERROR_SUCCESS)
+ return;
+
+ wchar_t name[128];
+ FILETIME lastModified;
+
+ // Enumerate subkeys
+ for (int i = 0;; i++) {
+ DWORD nameLen = WTF_ARRAY_LENGTH(name);
+ result = RegEnumKeyExW(key, i, name, &nameLen, 0, 0, 0, &lastModified);
+
+ if (result != ERROR_SUCCESS)
+ break;
+
+ WCHAR pathStr[_MAX_PATH];
+ DWORD pathStrSize = sizeof(pathStr);
+ DWORD type;
+
+ result = getRegistryValue(key, name, L"Path", &type, pathStr, &pathStrSize);
+ if (result != ERROR_SUCCESS || type != REG_SZ)
+ continue;
+
+ paths.add(String(pathStr, pathStrSize / sizeof(WCHAR) - 1));
+ }
+
+ RegCloseKey(key);
+}
+
+void PluginDatabase::getPluginPathsInDirectories(HashSet<String>& paths) const
+{
+ // FIXME: This should be a case insensitive set.
+ HashSet<String> uniqueFilenames;
+
+ HANDLE hFind = INVALID_HANDLE_VALUE;
+ WIN32_FIND_DATAW findFileData;
+
+ String oldWMPPluginPath;
+ String newWMPPluginPath;
+
+ Vector<String>::const_iterator end = m_pluginDirectories.end();
+ for (Vector<String>::const_iterator it = m_pluginDirectories.begin(); it != end; ++it) {
+ String pattern = *it + "\\*";
+
+ hFind = FindFirstFileW(pattern.charactersWithNullTermination().data(), &findFileData);
+
+ if (hFind == INVALID_HANDLE_VALUE)
+ continue;
+
+ do {
+ if (findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+ continue;
+
+ String filename = String(findFileData.cFileName, wcslen(findFileData.cFileName));
+ if ((!filename.startsWith("np", false) || !filename.endsWith("dll", false)) &&
+ (!equalIgnoringCase(filename, "Plugin.dll") || !it->endsWith("Shockwave 10", false)))
+ continue;
+
+ String fullPath = *it + "\\" + filename;
+ if (!uniqueFilenames.add(fullPath).isNewEntry)
+ continue;
+
+ paths.add(fullPath);
+
+ if (equalIgnoringCase(filename, "npdsplay.dll"))
+ oldWMPPluginPath = fullPath;
+ else if (equalIgnoringCase(filename, "np-mswmp.dll"))
+ newWMPPluginPath = fullPath;
+
+ } while (FindNextFileW(hFind, &findFileData) != 0);
+
+ FindClose(hFind);
+ }
+
+ addPluginPathsFromRegistry(HKEY_LOCAL_MACHINE, paths);
+ addPluginPathsFromRegistry(HKEY_CURRENT_USER, paths);
+
+ // If both the old and new WMP plugin are present in the plugins set,
+ // we remove the old one so we don't end up choosing the old one.
+ if (!oldWMPPluginPath.isEmpty() && !newWMPPluginPath.isEmpty())
+ paths.remove(oldWMPPluginPath);
+}
+
+static inline Vector<int> parseVersionString(const String& versionString)
+{
+ Vector<int> version;
+
+ unsigned startPos = 0;
+ unsigned endPos;
+
+ while (startPos < versionString.length()) {
+ for (endPos = startPos; endPos < versionString.length(); ++endPos)
+ if (versionString[endPos] == '.' || versionString[endPos] == '_')
+ break;
+
+ int versionComponent = versionString.substring(startPos, endPos - startPos).toInt();
+ version.append(versionComponent);
+
+ startPos = endPos + 1;
+ }
+
+ return version;
+}
+
+// This returns whether versionA is higher than versionB
+static inline bool compareVersions(const Vector<int>& versionA, const Vector<int>& versionB)
+{
+ for (unsigned i = 0; i < versionA.size(); i++) {
+ if (i >= versionB.size())
+ return true;
+
+ if (versionA[i] > versionB[i])
+ return true;
+ else if (versionA[i] < versionB[i])
+ return false;
+ }
+
+ // If we come here, the versions are either the same or versionB has an extra component, just return false
+ return false;
+}
+
+static inline void addMozillaPluginDirectories(Vector<String>& directories)
+{
+ // Enumerate all Mozilla plugin directories in the registry
+ HKEY key;
+ LONG result;
+
+ result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("Software\\Mozilla"), 0, KEY_READ, &key);
+ if (result == ERROR_SUCCESS) {
+ WCHAR name[128];
+ FILETIME lastModified;
+
+ // Enumerate subkeys
+ for (int i = 0;; i++) {
+ DWORD nameLen = sizeof(name) / sizeof(WCHAR);
+ result = RegEnumKeyExW(key, i, name, &nameLen, 0, 0, 0, &lastModified);
+
+ if (result != ERROR_SUCCESS)
+ break;
+
+ String extensionsPath = String(name, nameLen) + "\\Extensions";
+ HKEY extensionsKey;
+
+ // Try opening the key
+ result = RegOpenKeyEx(key, extensionsPath.charactersWithNullTermination().data(), 0, KEY_READ, &extensionsKey);
+
+ if (result == ERROR_SUCCESS) {
+ // Now get the plugins directory
+ WCHAR pluginsDirectoryStr[_MAX_PATH];
+ DWORD pluginsDirectorySize = sizeof(pluginsDirectoryStr);
+ DWORD type;
+
+ result = RegQueryValueEx(extensionsKey, TEXT("Plugins"), 0, &type, (LPBYTE)&pluginsDirectoryStr, &pluginsDirectorySize);
+
+ if (result == ERROR_SUCCESS && type == REG_SZ)
+ directories.append(String(pluginsDirectoryStr, pluginsDirectorySize / sizeof(WCHAR) - 1));
+
+ RegCloseKey(extensionsKey);
+ }
+ }
+
+ RegCloseKey(key);
+ }
+}
+
+static inline void addWindowsMediaPlayerPluginDirectory(Vector<String>& directories)
+{
+ // The new WMP Firefox plugin is installed in \PFiles\Plugins if it can't find any Firefox installs
+ WCHAR pluginDirectoryStr[_MAX_PATH + 1];
+ DWORD pluginDirectorySize = ::ExpandEnvironmentStringsW(TEXT("%SYSTEMDRIVE%\\PFiles\\Plugins"), pluginDirectoryStr, WTF_ARRAY_LENGTH(pluginDirectoryStr));
+
+ if (pluginDirectorySize > 0 && pluginDirectorySize <= WTF_ARRAY_LENGTH(pluginDirectoryStr))
+ directories.append(String(pluginDirectoryStr, pluginDirectorySize - 1));
+
+ DWORD type;
+ WCHAR installationDirectoryStr[_MAX_PATH];
+ DWORD installationDirectorySize = sizeof(installationDirectoryStr);
+
+ HRESULT result = getRegistryValue(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\MediaPlayer", L"Installation Directory", &type, &installationDirectoryStr, &installationDirectorySize);
+
+ if (result == ERROR_SUCCESS && type == REG_SZ)
+ directories.append(String(installationDirectoryStr, installationDirectorySize / sizeof(WCHAR) - 1));
+}
+
+static inline void addAdobeAcrobatPluginDirectory(Vector<String>& directories)
+{
+ HKEY key;
+ HRESULT result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("Software\\Adobe\\Acrobat Reader"), 0, KEY_READ, &key);
+ if (result != ERROR_SUCCESS)
+ return;
+
+ WCHAR name[128];
+ FILETIME lastModified;
+
+ Vector<int> latestAcrobatVersion;
+ String latestAcrobatVersionString;
+
+ // Enumerate subkeys
+ for (int i = 0;; i++) {
+ DWORD nameLen = sizeof(name) / sizeof(WCHAR);
+ result = RegEnumKeyExW(key, i, name, &nameLen, 0, 0, 0, &lastModified);
+
+ if (result != ERROR_SUCCESS)
+ break;
+
+ Vector<int> acrobatVersion = parseVersionString(String(name, nameLen));
+ if (compareVersions(acrobatVersion, latestAcrobatVersion)) {
+ latestAcrobatVersion = acrobatVersion;
+ latestAcrobatVersionString = String(name, nameLen);
+ }
+ }
+
+ if (!latestAcrobatVersionString.isNull()) {
+ DWORD type;
+ WCHAR acrobatInstallPathStr[_MAX_PATH];
+ DWORD acrobatInstallPathSize = sizeof(acrobatInstallPathStr);
+
+ String acrobatPluginKeyPath = "Software\\Adobe\\Acrobat Reader\\" + latestAcrobatVersionString + "\\InstallPath";
+ result = getRegistryValue(HKEY_LOCAL_MACHINE, acrobatPluginKeyPath.charactersWithNullTermination().data(), 0, &type, acrobatInstallPathStr, &acrobatInstallPathSize);
+
+ if (result == ERROR_SUCCESS) {
+ String acrobatPluginDirectory = String(acrobatInstallPathStr, acrobatInstallPathSize / sizeof(WCHAR) - 1) + "\\browser";
+ directories.append(acrobatPluginDirectory);
+ }
+ }
+
+ RegCloseKey(key);
+}
+
+static inline void addJavaPluginDirectory(Vector<String>& directories)
+{
+ HKEY key;
+ HRESULT result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("Software\\JavaSoft\\Java Plug-in"), 0, KEY_READ, &key);
+ if (result != ERROR_SUCCESS)
+ return;
+
+ WCHAR name[128];
+ FILETIME lastModified;
+
+ Vector<int> latestJavaVersion;
+ String latestJavaVersionString;
+
+ // Enumerate subkeys
+ for (int i = 0;; i++) {
+ DWORD nameLen = sizeof(name) / sizeof(WCHAR);
+ result = RegEnumKeyExW(key, i, name, &nameLen, 0, 0, 0, &lastModified);
+
+ if (result != ERROR_SUCCESS)
+ break;
+
+ Vector<int> javaVersion = parseVersionString(String(name, nameLen));
+ if (compareVersions(javaVersion, latestJavaVersion)) {
+ latestJavaVersion = javaVersion;
+ latestJavaVersionString = String(name, nameLen);
+ }
+ }
+
+ if (!latestJavaVersionString.isEmpty()) {
+ DWORD type;
+ WCHAR javaInstallPathStr[_MAX_PATH];
+ DWORD javaInstallPathSize = sizeof(javaInstallPathStr);
+ DWORD useNewPluginValue;
+ DWORD useNewPluginSize;
+
+ String javaPluginKeyPath = "Software\\JavaSoft\\Java Plug-in\\" + latestJavaVersionString;
+ result = getRegistryValue(HKEY_LOCAL_MACHINE, javaPluginKeyPath.charactersWithNullTermination().data(), L"UseNewJavaPlugin", &type, &useNewPluginValue, &useNewPluginSize);
+
+ if (result == ERROR_SUCCESS && useNewPluginValue == 1) {
+ result = getRegistryValue(HKEY_LOCAL_MACHINE, javaPluginKeyPath.charactersWithNullTermination().data(), L"JavaHome", &type, javaInstallPathStr, &javaInstallPathSize);
+ if (result == ERROR_SUCCESS) {
+ String javaPluginDirectory = String(javaInstallPathStr, javaInstallPathSize / sizeof(WCHAR) - 1) + "\\bin\\new_plugin";
+ directories.append(javaPluginDirectory);
+ }
+ }
+ }
+
+ RegCloseKey(key);
+}
+
+static inline String safariPluginsDirectory()
+{
+ WCHAR moduleFileNameStr[_MAX_PATH];
+ static String pluginsDirectory;
+ static bool cachedPluginDirectory = false;
+
+ if (!cachedPluginDirectory) {
+ cachedPluginDirectory = true;
+
+ int moduleFileNameLen = GetModuleFileName(0, moduleFileNameStr, _MAX_PATH);
+
+ if (!moduleFileNameLen || moduleFileNameLen == _MAX_PATH)
+ goto exit;
+
+ if (!PathRemoveFileSpec(moduleFileNameStr))
+ goto exit;
+
+ pluginsDirectory = String(moduleFileNameStr) + "\\Plugins";
+ }
+exit:
+ return pluginsDirectory;
+}
+
+static inline void addMacromediaPluginDirectories(Vector<String>& directories)
+{
+ WCHAR systemDirectoryStr[MAX_PATH];
+
+ if (!GetSystemDirectory(systemDirectoryStr, WTF_ARRAY_LENGTH(systemDirectoryStr)))
+ return;
+
+ WCHAR macromediaDirectoryStr[MAX_PATH];
+
+ PathCombine(macromediaDirectoryStr, systemDirectoryStr, TEXT("macromed\\Flash"));
+ directories.append(macromediaDirectoryStr);
+
+ PathCombine(macromediaDirectoryStr, systemDirectoryStr, TEXT("macromed\\Shockwave 10"));
+ directories.append(macromediaDirectoryStr);
+}
+
+Vector<String> PluginDatabase::defaultPluginDirectories()
+{
+ Vector<String> directories;
+ String ourDirectory = safariPluginsDirectory();
+
+ if (!ourDirectory.isNull())
+ directories.append(ourDirectory);
+ addAdobeAcrobatPluginDirectory(directories);
+ addMozillaPluginDirectories(directories);
+ addWindowsMediaPlayerPluginDirectory(directories);
+ addMacromediaPluginDirectories(directories);
+
+ return directories;
+}
+
+bool PluginDatabase::isPreferredPluginDirectory(const String& directory)
+{
+ String ourDirectory = safariPluginsDirectory();
+
+ if (!ourDirectory.isNull() && !directory.isNull())
+ return ourDirectory == directory;
+
+ return false;
+}
+
+}
</ins></span></pre></div>
<a id="trunkSourceWebKitwinPluginsPluginDebugcppfromrev178217trunkSourceWebCorepluginsPluginDebugcpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebKit/win/Plugins/PluginDebug.cpp (from rev 178217, trunk/Source/WebCore/plugins/PluginDebug.cpp) (0 => 178219)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/win/Plugins/PluginDebug.cpp         (rev 0)
+++ trunk/Source/WebKit/win/Plugins/PluginDebug.cpp        2015-01-10 00:16:52 UTC (rev 178219)
</span><span class="lines">@@ -0,0 +1,179 @@
</span><ins>+/*
+ * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "PluginDebug.h"
+
+#include <wtf/text/WTFString.h>
+
+#if !LOG_DISABLED
+
+namespace WebCore {
+
+static const char* const errorStrings[] = {
+ "No errors occurred.", /* NPERR_NO_ERROR */
+ "Error with no specific error code occurred.", /* NPERR_GENERIC_ERROR */
+ "Invalid instance passed to the plug-in.", /* NPERR_INVALID_INSTANCE_ERROR */
+ "Function table invalid.", /* NPERR_INVALID_FUNCTABLE_ERROR */
+ "Loading of plug-in failed.", /* NPERR_MODULE_LOAD_FAILED_ERROR */
+ "Memory allocation failed.", /* NPERR_OUT_OF_MEMORY_ERROR */
+ "Plug-in missing or invalid.", /* NPERR_INVALID_PLUGIN_ERROR */
+ "Plug-in directory missing or invalid.", /* NPERR_INVALID_PLUGIN_DIR_ERROR */
+ "Versions of plug-in and Communicator do not match.", /* NPERR_INCOMPATIBLE_VERSION_ERROR */
+ "Parameter missing or invalid.", /* NPERR_INVALID_PARAM */
+ "URL missing or invalid.", /* NPERR_INVALID_URL */
+ "File missing or invalid.", /* NPERR_FILE_NOT_FOUND */
+ "Stream contains no data.", /* NPERR_NO_DATA */
+ "Seekable stream expected.", /* NPERR_STREAM_NOT_SEEKABLE */
+ "Unknown error code"
+};
+
+#ifdef XP_MACOSX
+static const char* const drawingModels[] = {
+ "NPDrawingModelQuickDraw",
+ "NPDrawingModelCoreGraphics",
+ "NPDrawingModelOpenGL",
+ "NPDrawingModelCoreAnimation"
+};
+
+static const char* const eventModels[] = {
+ "NPEventModelCarbon",
+ "NPEventModelCocoa"
+};
+#endif //XP_MACOSX
+
+const char* prettyNameForNPError(NPError error)
+{
+ return errorStrings[error];
+}
+
+#ifdef XP_MACOSX
+const char* prettyNameForDrawingModel(NPDrawingModel drawingModel)
+{
+ return drawingModels[drawingModel];
+}
+
+const char* prettyNameForEventModel(NPEventModel eventModel)
+{
+ return eventModels[eventModel];
+}
+#endif //XP_MACOSX
+
+CString prettyNameForNPNVariable(NPNVariable variable)
+{
+ switch (variable) {
+ case NPNVxDisplay: return "NPNVxDisplay";
+ case NPNVxtAppContext: return "NPNVxtAppContext";
+ case NPNVnetscapeWindow: return "NPNVnetscapeWindow";
+ case NPNVjavascriptEnabledBool: return "NPNVjavascriptEnabledBool";
+ case NPNVasdEnabledBool: return "NPNVasdEnabledBool";
+ case NPNVisOfflineBool: return "NPNVisOfflineBool";
+
+ case NPNVserviceManager: return "NPNVserviceManager (not supported)";
+ case NPNVDOMElement: return "NPNVDOMElement (not supported)";
+ case NPNVDOMWindow: return "NPNVDOMWindow (not supported)";
+ case NPNVToolkit: return "NPNVToolkit (not supported)";
+ case NPNVSupportsXEmbedBool: return "NPNVSupportsXEmbedBool (not supported)";
+
+ case NPNVWindowNPObject: return "NPNVWindowNPObject";
+ case NPNVPluginElementNPObject: return "NPNVPluginElementNPObject";
+ case NPNVSupportsWindowless: return "NPNVSupportsWindowless";
+ case NPNVprivateModeBool: return "NPNVprivateModeBool";
+
+#ifdef XP_MACOSX
+ case NPNVpluginDrawingModel: return "NPNVpluginDrawingModel";
+#ifndef NP_NO_QUICKDRAW
+ case NPNVsupportsQuickDrawBool: return "NPNVsupportsQuickDrawBool";
+#endif
+ case NPNVsupportsCoreGraphicsBool: return "NPNVsupportsCoreGraphicsBool";
+ case NPNVsupportsOpenGLBool: return "NPNVsupportsOpenGLBool";
+ case NPNVsupportsCoreAnimationBool: return "NPNVsupportsCoreAnimationBool";
+#ifndef NP_NO_CARBON
+ case NPNVsupportsCarbonBool: return "NPNVsupportsCarbonBool";
+#endif
+ case NPNVsupportsCocoaBool: return "NPNVsupportsCocoaBool";
+#endif
+
+ default: return "Unknown variable";
+ }
+}
+
+CString prettyNameForNPPVariable(NPPVariable variable, void* value)
+{
+ switch (variable) {
+ case NPPVpluginNameString: return "NPPVpluginNameString";
+ case NPPVpluginDescriptionString: return "NPPVpluginDescriptionString";
+ case NPPVpluginWindowBool: return "NPPVpluginWindowBool";
+ case NPPVpluginTransparentBool: return "NPPVpluginTransparentBool";
+
+ case NPPVjavaClass: return "NPPVjavaClass (not supported)";
+ case NPPVpluginWindowSize: return "NPPVpluginWindowSize (not supported)";
+ case NPPVpluginTimerInterval: return "NPPVpluginTimerInterval (not supported)";
+ case NPPVpluginScriptableInstance: return "NPPVpluginScriptableInstance (not supported)";
+ case NPPVpluginScriptableIID: return "NPPVpluginScriptableIID (not supported)";
+ case NPPVjavascriptPushCallerBool: return "NPPVjavascriptPushCallerBool (not supported)";
+ case NPPVpluginKeepLibraryInMemory: return "NPPVpluginKeepLibraryInMemory (not supported)";
+ case NPPVpluginNeedsXEmbed: return "NPPVpluginNeedsXEmbed (not supported)";
+
+ case NPPVpluginScriptableNPObject: return "NPPVpluginScriptableNPObject";
+
+ case NPPVformValue: return "NPPVformValue (not supported)";
+ case NPPVpluginUrlRequestsDisplayedBool: return "NPPVpluginUrlRequestsDisplayedBool (not supported)";
+
+ case NPPVpluginWantsAllNetworkStreams: return "NPPVpluginWantsAllNetworkStreams";
+ case NPPVpluginCancelSrcStream: return "NPPVpluginCancelSrcStream";
+
+#ifdef XP_MACOSX
+ case NPPVpluginDrawingModel: {
+ String result("NPPVpluginDrawingModel, ");
+ result.append(prettyNameForDrawingModel(NPDrawingModel(uintptr_t(value))));
+ return result.latin1();
+ }
+ case NPPVpluginEventModel: {
+ String result("NPPVpluginEventModel, ");
+ result.append(prettyNameForEventModel(NPEventModel(uintptr_t(value))));
+ return result.latin1();
+ }
+ case NPPVpluginCoreAnimationLayer: return "NPPVpluginCoreAnimationLayer";
+#else
+ UNUSED_PARAM(value);
+#endif
+
+ default: return "Unknown variable";
+ }
+}
+
+CString prettyNameForNPNURLVariable(NPNURLVariable variable)
+{
+ switch (variable) {
+ case NPNURLVCookie: return "NPNURLVCookie";
+ case NPNURLVProxy: return "NPNURLVProxy";
+ default: return "Unknown variable";
+ }
+}
+} // namespace WebCore
+
+#endif // !LOG_DISABLED
</ins></span></pre></div>
<a id="trunkSourceWebKitwinPluginsPluginDebughfromrev178217trunkSourceWebCorepluginsPluginDebugh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebKit/win/Plugins/PluginDebug.h (from rev 178217, trunk/Source/WebCore/plugins/PluginDebug.h) (0 => 178219)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/win/Plugins/PluginDebug.h         (rev 0)
+++ trunk/Source/WebKit/win/Plugins/PluginDebug.h        2015-01-10 00:16:52 UTC (rev 178219)
</span><span class="lines">@@ -0,0 +1,55 @@
</span><ins>+/*
+ * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef PluginDebug_h
+#define PluginDebug_h
+
+#include "Logging.h"
+#include "npruntime_internal.h"
+#include <wtf/text/CString.h>
+
+#define LOG_NPERROR(err) if (err != NPERR_NO_ERROR) LOG_VERBOSE(Plugins, "%s\n", prettyNameForNPError(err))
+#define LOG_PLUGIN_NET_ERROR() LOG_VERBOSE(Plugins, "Stream failed due to problems with network, disk I/O, lack of memory, or other problems.\n")
+
+#if !LOG_DISABLED
+
+namespace WebCore {
+
+const char* prettyNameForNPError(NPError error);
+
+CString prettyNameForNPNVariable(NPNVariable variable);
+CString prettyNameForNPPVariable(NPPVariable variable, void* value);
+CString prettyNameForNPNURLVariable(NPNURLVariable variable);
+
+#ifdef XP_MACOSX
+const char* prettyNameForDrawingModel(NPDrawingModel drawingModel);
+const char* prettyNameForEventModel(NPEventModel eventModel);
+#endif
+
+} // namespace WebCore
+
+#endif // !LOG_DISABLED
+
+#endif // PluginDebug_h
</ins></span></pre></div>
<a id="trunkSourceWebKitwinPluginsPluginMessageThrottlerWincppfromrev178217trunkSourceWebCorepluginswinPluginMessageThrottlerWincpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebKit/win/Plugins/PluginMessageThrottlerWin.cpp (from rev 178217, trunk/Source/WebCore/plugins/win/PluginMessageThrottlerWin.cpp) (0 => 178219)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/win/Plugins/PluginMessageThrottlerWin.cpp         (rev 0)
+++ trunk/Source/WebKit/win/Plugins/PluginMessageThrottlerWin.cpp        2015-01-10 00:16:52 UTC (rev 178219)
</span><span class="lines">@@ -0,0 +1,151 @@
</span><ins>+/*
+ * Copyright (C) 2006, 2007, 2008 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2008 Collabora, Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "PluginMessageThrottlerWin.h"
+
+#include "PluginView.h"
+#include <wtf/ASCIICType.h>
+#include <wtf/CurrentTime.h>
+
+using namespace WTF;
+
+namespace WebCore {
+
+// Set a timer to make sure we process any queued messages at least every 16ms.
+// This value allows Flash 60 messages/second, which should be enough for video
+// playback, and also gets us over the limit for kicking into high-resolution
+// timer mode (see SharedTimerWin.cpp).
+static const double MessageThrottleTimeInterval = 0.016;
+
+// During a continuous stream of messages, process one every 5ms.
+static const double MessageDirectProcessingInterval = 0.005;
+
+PluginMessageThrottlerWin::PluginMessageThrottlerWin(PluginView* pluginView)
+ : m_pluginView(pluginView)
+ , m_back(0)
+ , m_front(0)
+ , m_messageThrottleTimer(*this, &PluginMessageThrottlerWin::messageThrottleTimerFired)
+ , m_lastMessageTime(0)
+{
+ // Initialize the free list with our inline messages
+ for (unsigned i = 0; i < NumInlineMessages - 1; i++)
+ m_inlineMessages[i].next = &m_inlineMessages[i + 1];
+ m_inlineMessages[NumInlineMessages - 1].next = 0;
+ m_freeInlineMessages = &m_inlineMessages[0];
+}
+
+PluginMessageThrottlerWin::~PluginMessageThrottlerWin()
+{
+ PluginMessage* next;
+
+ for (PluginMessage* message = m_front; message; message = next) {
+ next = message->next;
+ freeMessage(message);
+ }
+}
+
+void PluginMessageThrottlerWin::appendMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ PluginMessage* message = allocateMessage();
+
+ message->hWnd = hWnd;
+ message->msg = msg;
+ message->wParam = wParam;
+ message->lParam = lParam;
+ message->next = 0;
+
+ if (m_back)
+ m_back->next = message;
+ m_back = message;
+ if (!m_front)
+ m_front = message;
+
+ // If it has been more than MessageDirectProcessingInterval between throttled messages,
+ // go ahead and process a message directly.
+ double currentTime = monotonicallyIncreasingTime();
+ if (currentTime - m_lastMessageTime > MessageDirectProcessingInterval) {
+ processQueuedMessage();
+ m_lastMessageTime = currentTime;
+ if (!m_front)
+ return;
+ }
+
+ if (!m_messageThrottleTimer.isActive())
+ m_messageThrottleTimer.startOneShot(MessageThrottleTimeInterval);
+}
+
+void PluginMessageThrottlerWin::processQueuedMessage()
+{
+ PluginMessage* message = m_front;
+ m_front = m_front->next;
+ if (message == m_back)
+ m_back = 0;
+
+ // Protect the PluginView from destruction while calling its window proc.
+ // <rdar://problem/6930280>
+ RefPtr<PluginView> protect(m_pluginView);
+ ::CallWindowProc(m_pluginView->pluginWndProc(), message->hWnd, message->msg, message->wParam, message->lParam);
+
+ freeMessage(message);
+}
+
+void PluginMessageThrottlerWin::messageThrottleTimerFired()
+{
+ processQueuedMessage();
+
+ if (m_front)
+ m_messageThrottleTimer.startOneShot(MessageThrottleTimeInterval);
+}
+
+PluginMessage* PluginMessageThrottlerWin::allocateMessage()
+{
+ PluginMessage *message;
+
+ if (m_freeInlineMessages) {
+ message = m_freeInlineMessages;
+ m_freeInlineMessages = message->next;
+ } else
+ message = new PluginMessage;
+
+ return message;
+}
+
+bool PluginMessageThrottlerWin::isInlineMessage(PluginMessage* message)
+{
+ return message >= &m_inlineMessages[0] && message <= &m_inlineMessages[NumInlineMessages - 1];
+}
+
+void PluginMessageThrottlerWin::freeMessage(PluginMessage* message)
+{
+ if (isInlineMessage(message)) {
+ message->next = m_freeInlineMessages;
+ m_freeInlineMessages = message;
+ } else
+ delete message;
+}
+
+} // namespace WebCore
</ins></span></pre></div>
<a id="trunkSourceWebKitwinPluginsPluginMessageThrottlerWinhfromrev178217trunkSourceWebCorepluginswinPluginMessageThrottlerWinh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebKit/win/Plugins/PluginMessageThrottlerWin.h (from rev 178217, trunk/Source/WebCore/plugins/win/PluginMessageThrottlerWin.h) (0 => 178219)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/win/Plugins/PluginMessageThrottlerWin.h         (rev 0)
+++ trunk/Source/WebKit/win/Plugins/PluginMessageThrottlerWin.h        2015-01-10 00:16:52 UTC (rev 178219)
</span><span class="lines">@@ -0,0 +1,74 @@
</span><ins>+/*
+ * Copyright (C) 2006, 2007, 2008 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2008 Collabora, Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef PluginMessageThrottlerWin_h
+#define PluginMessageThrottlerWin_h
+
+#include "Timer.h"
+
+#include <windows.h>
+
+namespace WebCore {
+ class PluginView;
+
+ struct PluginMessage {
+ HWND hWnd;
+ UINT msg;
+ WPARAM wParam;
+ LPARAM lParam;
+
+ struct PluginMessage* next;
+ };
+
+ class PluginMessageThrottlerWin {
+ public:
+ PluginMessageThrottlerWin(PluginView*);
+ ~PluginMessageThrottlerWin();
+
+ void appendMessage(HWND, UINT msg, WPARAM, LPARAM);
+
+ private:
+ void processQueuedMessage();
+ void messageThrottleTimerFired();
+ PluginMessage* allocateMessage();
+ bool isInlineMessage(PluginMessage* message);
+ void freeMessage(PluginMessage* message);
+
+ PluginView* m_pluginView;
+ PluginMessage* m_back;
+ PluginMessage* m_front;
+
+ static const int NumInlineMessages = 4;
+ PluginMessage m_inlineMessages[NumInlineMessages];
+ PluginMessage* m_freeInlineMessages;
+
+ Timer m_messageThrottleTimer;
+ double m_lastMessageTime;
+ };
+
+} // namespace WebCore
+
+#endif // PluginMessageThrottlerWin_h
</ins></span></pre></div>
<a id="trunkSourceWebKitwinPluginsPluginPackagecppfromrev178217trunkSourceWebCorepluginsPluginPackagecpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebKit/win/Plugins/PluginPackage.cpp (from rev 178217, trunk/Source/WebCore/plugins/PluginPackage.cpp) (0 => 178219)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/win/Plugins/PluginPackage.cpp         (rev 0)
+++ trunk/Source/WebKit/win/Plugins/PluginPackage.cpp        2015-01-10 00:16:52 UTC (rev 178219)
</span><span class="lines">@@ -0,0 +1,478 @@
</span><ins>+/*
+ * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2008 Collabora Ltd. All rights reserved.
+ * Copyright (C) 2009 Holger Hans Peter Freyther
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "PluginPackage.h"
+
+#include "PluginDatabase.h"
+#include "PluginDebug.h"
+#include "PluginView.h"
+#include <JavaScriptCore/Completion.h>
+#include <JavaScriptCore/JSGlobalObject.h>
+#include <WebCore/IdentifierRep.h>
+#include <WebCore/MIMETypeRegistry.h>
+#include <WebCore/NP_jsobject.h>
+#include <WebCore/Timer.h>
+#include <WebCore/c_utility.h>
+#include <WebCore/npruntime_impl.h>
+#include <WebCore/runtime_root.h>
+#include <string.h>
+#include <wtf/text/CString.h>
+
+namespace WebCore {
+
+PluginPackage::~PluginPackage()
+{
+ // This destructor gets called during refresh() if PluginDatabase's
+ // PluginSet hash is already populated, as it removes items from
+ // the hash table. Calling the destructor on a loaded plug-in of
+ // course would cause a crash, so we check to call unload before we
+ // ASSERT.
+ // FIXME: There is probably a better way to fix this.
+ if (!m_loadCount)
+ unloadWithoutShutdown();
+ else
+ unload();
+
+ ASSERT(!m_isLoaded);
+}
+
+void PluginPackage::freeLibrarySoon()
+{
+ ASSERT(!m_freeLibraryTimer.isActive());
+ ASSERT(m_module);
+ ASSERT(!m_loadCount);
+
+ m_freeLibraryTimer.startOneShot(0);
+}
+
+void PluginPackage::freeLibraryTimerFired()
+{
+ ASSERT(m_module);
+ // Do nothing if the module got loaded again meanwhile
+ if (!m_loadCount) {
+ unloadModule(m_module);
+ m_module = 0;
+ }
+}
+
+
+int PluginPackage::compare(const PluginPackage& compareTo) const
+{
+ // Sort plug-ins that allow multiple instances first.
+ bool AallowsMultipleInstances = !quirks().contains(PluginQuirkDontAllowMultipleInstances);
+ bool BallowsMultipleInstances = !compareTo.quirks().contains(PluginQuirkDontAllowMultipleInstances);
+ if (AallowsMultipleInstances != BallowsMultipleInstances)
+ return AallowsMultipleInstances ? -1 : 1;
+
+ // Sort plug-ins in a preferred path first.
+ bool AisInPreferredDirectory = PluginDatabase::isPreferredPluginDirectory(parentDirectory());
+ bool BisInPreferredDirectory = PluginDatabase::isPreferredPluginDirectory(compareTo.parentDirectory());
+ if (AisInPreferredDirectory != BisInPreferredDirectory)
+ return AisInPreferredDirectory ? -1 : 1;
+
+ int diff = strcmp(name().utf8().data(), compareTo.name().utf8().data());
+ if (diff)
+ return diff;
+
+ diff = compareFileVersion(compareTo.version());
+ if (diff)
+ return diff;
+
+ return strcmp(parentDirectory().utf8().data(), compareTo.parentDirectory().utf8().data());
+}
+
+PluginPackage::PluginPackage(const String& path, const time_t& lastModified)
+ : m_isEnabled(true)
+ , m_isLoaded(false)
+ , m_loadCount(0)
+ , m_path(path)
+ , m_moduleVersion(0)
+ , m_module(0)
+ , m_lastModified(lastModified)
+ , m_freeLibraryTimer(*this, &PluginPackage::freeLibraryTimerFired)
+#if ENABLE(NETSCAPE_PLUGIN_METADATA_CACHE)
+ , m_infoIsFromCache(true)
+#endif
+{
+ m_fileName = pathGetFileName(m_path);
+ m_parentDirectory = m_path.left(m_path.length() - m_fileName.length() - 1);
+}
+
+void PluginPackage::unload()
+{
+ if (!m_isLoaded)
+ return;
+
+ if (--m_loadCount > 0)
+ return;
+
+#if ENABLE(NETSCAPE_PLUGIN_API)
+ m_NPP_Shutdown();
+#endif
+
+ unloadWithoutShutdown();
+}
+
+void PluginPackage::unloadWithoutShutdown()
+{
+ if (!m_isLoaded)
+ return;
+
+ ASSERT(!m_loadCount);
+ ASSERT(m_module);
+
+ // <rdar://5530519>: Crash when closing tab with pdf file (Reader 7 only)
+ // If the plugin has subclassed its parent window, as with Reader 7, we may have
+ // gotten here by way of the plugin's internal window proc forwarding a message to our
+ // original window proc. If we free the plugin library from here, we will jump back
+ // to code we just freed when we return, so delay calling FreeLibrary at least until
+ // the next message loop
+ freeLibrarySoon();
+
+ m_isLoaded = false;
+}
+
+void PluginPackage::setEnabled(bool enabled)
+{
+ m_isEnabled = enabled;
+}
+
+PassRefPtr<PluginPackage> PluginPackage::createPackage(const String& path, const time_t& lastModified)
+{
+ RefPtr<PluginPackage> package = adoptRef(new PluginPackage(path, lastModified));
+
+ if (!package->fetchInfo())
+ return 0;
+
+ return package.release();
+}
+
+#if ENABLE(NETSCAPE_PLUGIN_METADATA_CACHE)
+PassRefPtr<PluginPackage> PluginPackage::createPackageFromCache(const String& path, const time_t& lastModified, const String& name, const String& description, const String& mimeDescription)
+{
+ RefPtr<PluginPackage> package = adoptRef(new PluginPackage(path, lastModified));
+ package->m_name = name;
+ package->m_description = description;
+ package->determineModuleVersionFromDescription();
+ package->setMIMEDescription(mimeDescription);
+ package->m_infoIsFromCache = true;
+ return package.release();
+}
+#endif
+
+#if defined(XP_UNIX)
+void PluginPackage::determineQuirks(const String& mimeType)
+{
+ if (MIMETypeRegistry::isJavaAppletMIMEType(mimeType)) {
+ // Because a single process cannot create multiple VMs, and we cannot reliably unload a
+ // Java VM, we cannot unload the Java plugin, or we'll lose reference to our only VM
+ m_quirks.add(PluginQuirkDontUnloadPlugin);
+
+ // Setting the window region to an empty region causes bad scrolling repaint problems
+ // with the Java plug-in.
+ m_quirks.add(PluginQuirkDontClipToZeroRectWhenScrolling);
+ return;
+ }
+
+ if (mimeType == "application/x-shockwave-flash") {
+ static const PlatformModuleVersion flashTenVersion(0x0a000000);
+
+ if (compareFileVersion(flashTenVersion) >= 0) {
+ // Flash 10.0 b218 doesn't like having a NULL window handle
+ m_quirks.add(PluginQuirkDontSetNullWindowHandleOnDestroy);
+ } else {
+ // Flash 9 and older requests windowless plugins if we return a mozilla user agent
+ m_quirks.add(PluginQuirkWantsMozillaUserAgent);
+ }
+
+#if CPU(X86_64)
+ // 64-bit Flash freezes if right-click is sent in windowless mode
+ m_quirks.add(PluginQuirkIgnoreRightClickInWindowlessMode);
+#endif
+
+ m_quirks.add(PluginQuirkRequiresDefaultScreenDepth);
+ m_quirks.add(PluginQuirkThrottleInvalidate);
+ m_quirks.add(PluginQuirkThrottleWMUserPlusOneMessages);
+ m_quirks.add(PluginQuirkFlashURLNotifyBug);
+ }
+}
+#endif
+
+#if !OS(WINDOWS)
+void PluginPackage::determineModuleVersionFromDescription()
+{
+ // It's a bit lame to detect the plugin version by parsing it
+ // from the plugin description string, but it doesn't seem that
+ // version information is available in any standardized way at
+ // the module level, like in Windows
+
+ if (m_description.isEmpty())
+ return;
+
+ if (m_description.startsWith("Shockwave Flash") && m_description.length() >= 19) {
+ // The flash version as a PlatformModuleVersion differs on Unix from Windows
+ // since the revision can be larger than a 8 bits, so we allow it 16 here and
+ // push the major/minor up 8 bits. Thus on Unix, Flash's version may be
+ // 0x0a000000 instead of 0x000a0000.
+
+ Vector<String> versionParts;
+ m_description.substring(16).split(' ', /*allowEmptyEntries =*/ false, versionParts);
+ if (versionParts.isEmpty())
+ return;
+
+ if (versionParts.size() >= 1) {
+ Vector<String> majorMinorParts;
+ versionParts[0].split('.', majorMinorParts);
+ if (majorMinorParts.size() >= 1) {
+ bool converted = false;
+ unsigned major = majorMinorParts[0].toUInt(&converted);
+ if (converted)
+ m_moduleVersion = (major & 0xff) << 24;
+ }
+ if (majorMinorParts.size() == 2) {
+ bool converted = false;
+ unsigned minor = majorMinorParts[1].toUInt(&converted);
+ if (converted)
+ m_moduleVersion |= (minor & 0xff) << 16;
+ }
+ }
+
+ if (versionParts.size() >= 2) {
+ String revision = versionParts[1];
+ if (revision.length() > 1 && (revision[0] == 'r' || revision[0] == 'b')) {
+ revision.remove(0, 1);
+ m_moduleVersion |= revision.toInt() & 0xffff;
+ }
+ }
+ }
+}
+#endif
+
+#if ENABLE(NETSCAPE_PLUGIN_API)
+static void getListFromVariantArgs(JSC::ExecState* exec, const NPVariant* args, unsigned argCount, JSC::Bindings::RootObject* rootObject, JSC::MarkedArgumentBuffer& aList)
+{
+ for (unsigned i = 0; i < argCount; ++i)
+ aList.append(JSC::Bindings::convertNPVariantToValue(exec, &args[i], rootObject));
+}
+
+static inline JSC::SourceCode makeSource(const String& source, const String& url = String(), const TextPosition& startPosition = TextPosition::minimumPosition())
+{
+ return JSC::SourceCode(JSC::StringSourceProvider::create(source, url, startPosition), startPosition.m_line.oneBasedInt(), startPosition.m_column.oneBasedInt());
+}
+
+static bool NPN_Evaluate(NPP instance, NPObject* o, NPString* s, NPVariant* variant)
+{
+ if (o->_class == NPScriptObjectClass) {
+ JavaScriptObject* obj = reinterpret_cast<JavaScriptObject*>(o);
+
+ JSC::Bindings::RootObject* rootObject = obj->rootObject;
+ if (!rootObject || !rootObject->isValid())
+ return false;
+
+ // There is a crash in Flash when evaluating a script that destroys the
+ // PluginView, so we destroy it asynchronously.
+ PluginView::keepAlive(instance);
+
+ JSC::ExecState* exec = rootObject->globalObject()->globalExec();
+ JSC::JSLockHolder lock(exec);
+ String scriptString = JSC::Bindings::convertNPStringToUTF16(s);
+
+ JSC::JSValue returnValue = JSC::evaluate(rootObject->globalObject()->globalExec(), makeSource(scriptString), JSC::JSValue());
+
+ JSC::Bindings::convertValueToNPVariant(exec, returnValue, variant);
+ exec->clearException();
+ return true;
+ }
+
+ VOID_TO_NPVARIANT(*variant);
+ return false;
+}
+
+static bool NPN_Invoke(NPP npp, NPObject* o, NPIdentifier methodName, const NPVariant* args, uint32_t argCount, NPVariant* result)
+{
+ if (o->_class == NPScriptObjectClass) {
+ JavaScriptObject* obj = reinterpret_cast<JavaScriptObject*>(o);
+
+ IdentifierRep* i = static_cast<IdentifierRep*>(methodName);
+ if (!i->isString())
+ return false;
+
+ // Special case the "eval" method.
+ if (methodName == _NPN_GetStringIdentifier("eval")) {
+ if (argCount != 1)
+ return false;
+ if (args[0].type != NPVariantType_String)
+ return false;
+ return WebCore::NPN_Evaluate(npp, o, const_cast<NPString*>(&args[0].value.stringValue), result);
+ }
+
+ // Look up the function object.
+ JSC::Bindings::RootObject* rootObject = obj->rootObject;
+ if (!rootObject || !rootObject->isValid())
+ return false;
+ JSC::ExecState* exec = rootObject->globalObject()->globalExec();
+ JSC::JSLockHolder lock(exec);
+ JSC::JSValue function = obj->imp->get(exec, JSC::Bindings::identifierFromNPIdentifier(exec, i->string()));
+ JSC::CallData callData;
+ JSC::CallType callType = getCallData(function, callData);
+ if (callType == JSC::CallTypeNone)
+ return false;
+
+ // Call the function object.
+ JSC::MarkedArgumentBuffer argList;
+ getListFromVariantArgs(exec, args, argCount, rootObject, argList);
+ JSC::JSValue resultV = JSC::call(exec, function, callType, callData, obj->imp, argList);
+
+ // Convert and return the result of the function call.
+ JSC::Bindings::convertValueToNPVariant(exec, resultV, result);
+ exec->clearException();
+ return true;
+ }
+
+ if (o->_class->invoke)
+ return o->_class->invoke(o, methodName, args, argCount, result);
+
+ VOID_TO_NPVARIANT(*result);
+ return true;
+}
+
+void PluginPackage::initializeBrowserFuncs()
+{
+ memset(&m_browserFuncs, 0, sizeof(m_browserFuncs));
+ m_browserFuncs.size = sizeof(m_browserFuncs);
+ m_browserFuncs.version = NPVersion();
+
+ m_browserFuncs.geturl = NPN_GetURL;
+ m_browserFuncs.posturl = NPN_PostURL;
+ m_browserFuncs.requestread = NPN_RequestRead;
+ m_browserFuncs.newstream = NPN_NewStream;
+ m_browserFuncs.write = NPN_Write;
+ m_browserFuncs.destroystream = NPN_DestroyStream;
+ m_browserFuncs.status = NPN_Status;
+ m_browserFuncs.uagent = NPN_UserAgent;
+ m_browserFuncs.memalloc = NPN_MemAlloc;
+ m_browserFuncs.memfree = NPN_MemFree;
+ m_browserFuncs.memflush = NPN_MemFlush;
+ m_browserFuncs.reloadplugins = NPN_ReloadPlugins;
+ m_browserFuncs.geturlnotify = NPN_GetURLNotify;
+ m_browserFuncs.posturlnotify = NPN_PostURLNotify;
+ m_browserFuncs.getvalue = NPN_GetValue;
+ m_browserFuncs.setvalue = NPN_SetValue;
+ m_browserFuncs.invalidaterect = NPN_InvalidateRect;
+ m_browserFuncs.invalidateregion = NPN_InvalidateRegion;
+ m_browserFuncs.forceredraw = NPN_ForceRedraw;
+ m_browserFuncs.getJavaEnv = NPN_GetJavaEnv;
+ m_browserFuncs.getJavaPeer = NPN_GetJavaPeer;
+ m_browserFuncs.pushpopupsenabledstate = NPN_PushPopupsEnabledState;
+ m_browserFuncs.poppopupsenabledstate = NPN_PopPopupsEnabledState;
+ m_browserFuncs.pluginthreadasynccall = NPN_PluginThreadAsyncCall;
+
+ m_browserFuncs.releasevariantvalue = _NPN_ReleaseVariantValue;
+ m_browserFuncs.getstringidentifier = _NPN_GetStringIdentifier;
+ m_browserFuncs.getstringidentifiers = _NPN_GetStringIdentifiers;
+ m_browserFuncs.getintidentifier = _NPN_GetIntIdentifier;
+ m_browserFuncs.identifierisstring = _NPN_IdentifierIsString;
+ m_browserFuncs.utf8fromidentifier = _NPN_UTF8FromIdentifier;
+ m_browserFuncs.intfromidentifier = _NPN_IntFromIdentifier;
+ m_browserFuncs.createobject = _NPN_CreateObject;
+ m_browserFuncs.retainobject = _NPN_RetainObject;
+ m_browserFuncs.releaseobject = _NPN_ReleaseObject;
+ m_browserFuncs.invoke = WebCore::NPN_Invoke;
+ m_browserFuncs.invokeDefault = _NPN_InvokeDefault;
+ m_browserFuncs.evaluate = WebCore::NPN_Evaluate;
+ m_browserFuncs.getproperty = _NPN_GetProperty;
+ m_browserFuncs.setproperty = _NPN_SetProperty;
+ m_browserFuncs.removeproperty = _NPN_RemoveProperty;
+ m_browserFuncs.hasproperty = _NPN_HasProperty;
+ m_browserFuncs.hasmethod = _NPN_HasMethod;
+ m_browserFuncs.setexception = _NPN_SetException;
+ m_browserFuncs.enumerate = _NPN_Enumerate;
+ m_browserFuncs.construct = _NPN_Construct;
+ m_browserFuncs.getvalueforurl = NPN_GetValueForURL;
+ m_browserFuncs.setvalueforurl = NPN_SetValueForURL;
+ m_browserFuncs.getauthenticationinfo = NPN_GetAuthenticationInfo;
+
+ m_browserFuncs.popupcontextmenu = NPN_PopUpContextMenu;
+}
+#endif // ENABLE(NETSCAPE_PLUGIN_API)
+
+#if ENABLE(PLUGIN_PACKAGE_SIMPLE_HASH)
+unsigned PluginPackage::hash() const
+{
+ struct HashCodes {
+ unsigned hash;
+ time_t modifiedDate;
+ } hashCodes;
+
+ hashCodes.hash = m_path.impl()->hash();
+ hashCodes.modifiedDate = m_lastModified;
+
+ return StringHasher::hashMemory<sizeof(hashCodes)>(&hashCodes);
+}
+
+bool PluginPackage::equal(const PluginPackage& a, const PluginPackage& b)
+{
+ return a.m_description == b.m_description;
+}
+#endif
+
+int PluginPackage::compareFileVersion(const PlatformModuleVersion& compareVersion) const
+{
+ // return -1, 0, or 1 if plug-in version is less than, equal to, or greater than
+ // the passed version
+
+#if OS(WINDOWS)
+ if (m_moduleVersion.mostSig != compareVersion.mostSig)
+ return m_moduleVersion.mostSig > compareVersion.mostSig ? 1 : -1;
+ if (m_moduleVersion.leastSig != compareVersion.leastSig)
+ return m_moduleVersion.leastSig > compareVersion.leastSig ? 1 : -1;
+#else
+ if (m_moduleVersion != compareVersion)
+ return m_moduleVersion > compareVersion ? 1 : -1;
+#endif
+
+ return 0;
+}
+
+#if ENABLE(NETSCAPE_PLUGIN_METADATA_CACHE)
+bool PluginPackage::ensurePluginLoaded()
+{
+ if (!m_infoIsFromCache)
+ return m_isLoaded;
+
+ m_quirks = PluginQuirkSet();
+ m_name = String();
+ m_description = String();
+ m_fullMIMEDescription = String();
+ m_moduleVersion = 0;
+
+ return fetchInfo();
+}
+#endif
+
+}
</ins></span></pre></div>
<a id="trunkSourceWebKitwinPluginsPluginPackagehfromrev178217trunkSourceWebCorepluginsPluginPackageh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebKit/win/Plugins/PluginPackage.h (from rev 178217, trunk/Source/WebCore/plugins/PluginPackage.h) (0 => 178219)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/win/Plugins/PluginPackage.h         (rev 0)
+++ trunk/Source/WebKit/win/Plugins/PluginPackage.h        2015-01-10 00:16:52 UTC (rev 178219)
</span><span class="lines">@@ -0,0 +1,149 @@
</span><ins>+/*
+ * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2008 Collabora, Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef PluginPackage_h
+#define PluginPackage_h
+
+#include "FileSystem.h"
+#include "PluginQuirkSet.h"
+#include "Timer.h"
+#if ENABLE(NETSCAPE_PLUGIN_API)
+#include "npruntime_internal.h"
+#endif
+#include <wtf/HashMap.h>
+#include <wtf/RefCounted.h>
+#include <wtf/text/StringHash.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+ typedef HashMap<String, String> MIMEToDescriptionsMap;
+ typedef HashMap<String, Vector<String> > MIMEToExtensionsMap;
+
+ class PluginPackage : public RefCounted<PluginPackage> {
+ public:
+ ~PluginPackage();
+ static PassRefPtr<PluginPackage> createPackage(const String& path, const time_t& lastModified);
+#if ENABLE(NETSCAPE_PLUGIN_METADATA_CACHE)
+ static PassRefPtr<PluginPackage> createPackageFromCache(const String& path, const time_t& lastModified, const String& name, const String& description, const String& mimeDescription);
+#endif
+
+ const String& name() const { return m_name; }
+ const String& description() const { return m_description; }
+ const String& path() const { return m_path; }
+ const String& fileName() const { return m_fileName; }
+ const String& parentDirectory() const { return m_parentDirectory; }
+ PlatformModule module() const { return m_module; }
+ uint16_t NPVersion() const;
+ time_t lastModified() const { return m_lastModified; }
+
+ const MIMEToDescriptionsMap& mimeToDescriptions() const { return m_mimeToDescriptions; }
+ const MIMEToExtensionsMap& mimeToExtensions() const { return m_mimeToExtensions; }
+
+ unsigned hash() const;
+ static bool equal(const PluginPackage& a, const PluginPackage& b);
+
+ bool load();
+ void unload();
+ void unloadWithoutShutdown();
+
+ bool isEnabled() const { return m_isEnabled; }
+ void setEnabled(bool);
+
+#if ENABLE(NETSCAPE_PLUGIN_API)
+ const NPPluginFuncs* pluginFuncs() const { return &m_pluginFuncs; }
+#endif
+ int compareFileVersion(const PlatformModuleVersion&) const;
+ int compare(const PluginPackage&) const;
+ PluginQuirkSet quirks() const { return m_quirks; }
+ const PlatformModuleVersion& version() const { return m_moduleVersion; }
+
+#if ENABLE(NETSCAPE_PLUGIN_METADATA_CACHE)
+ bool ensurePluginLoaded();
+ void setMIMEDescription(const String& mimeDescription);
+ String fullMIMEDescription() const { return m_fullMIMEDescription;}
+#endif
+ private:
+ PluginPackage(const String& path, const time_t& lastModified);
+
+ bool fetchInfo();
+ bool isPluginBlacklisted();
+ void determineQuirks(const String& mimeType);
+
+ void determineModuleVersionFromDescription();
+ void initializeBrowserFuncs();
+
+ bool m_isEnabled;
+ bool m_isLoaded;
+ int m_loadCount;
+
+ String m_description;
+ String m_path;
+ String m_fileName;
+ String m_name;
+ String m_parentDirectory;
+
+ PlatformModuleVersion m_moduleVersion;
+
+ MIMEToDescriptionsMap m_mimeToDescriptions;
+ MIMEToExtensionsMap m_mimeToExtensions;
+
+ PlatformModule m_module;
+ time_t m_lastModified;
+
+#if ENABLE(NETSCAPE_PLUGIN_API)
+ NPP_ShutdownProcPtr m_NPP_Shutdown;
+ NPPluginFuncs m_pluginFuncs;
+ NPNetscapeFuncs m_browserFuncs;
+#endif
+
+ void freeLibrarySoon();
+ void freeLibraryTimerFired();
+ Timer m_freeLibraryTimer;
+
+ PluginQuirkSet m_quirks;
+#if ENABLE(NETSCAPE_PLUGIN_METADATA_CACHE)
+ String m_fullMIMEDescription;
+ bool m_infoIsFromCache;
+#endif
+ };
+
+ // FIXME: This is a workaround because PluginPackageHash is broken and may consider keys with different hashes as equal.
+ struct PluginPackageHashTraits : HashTraits<RefPtr<PluginPackage> > {
+ static const int minimumTableSize = 64;
+ };
+
+ struct PluginPackageHash {
+ static unsigned hash(const uintptr_t key) { return reinterpret_cast<PluginPackage*>(key)->hash(); }
+ static unsigned hash(const RefPtr<PluginPackage>& key) { return key->hash(); }
+
+ static bool equal(const uintptr_t a, const uintptr_t b) { return equal(reinterpret_cast<PluginPackage*>(a), reinterpret_cast<PluginPackage*>(b)); }
+ static bool equal(const RefPtr<PluginPackage>& a, const RefPtr<PluginPackage>& b) { return PluginPackage::equal(*a.get(), *b.get()); }
+ static const bool safeToCompareToEmptyOrDeleted = false;
+ };
+
+} // namespace WebCore
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebKitwinPluginsPluginPackageWincppfromrev178217trunkSourceWebCorepluginswinPluginPackageWincpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebKit/win/Plugins/PluginPackageWin.cpp (from rev 178217, trunk/Source/WebCore/plugins/win/PluginPackageWin.cpp) (0 => 178219)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/win/Plugins/PluginPackageWin.cpp         (rev 0)
+++ trunk/Source/WebKit/win/Plugins/PluginPackageWin.cpp        2015-01-10 00:16:52 UTC (rev 178219)
</span><span class="lines">@@ -0,0 +1,335 @@
</span><ins>+/*
+ * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2008 Collabora, Ltd. All rights reserved.
+ * Copyright (C) 2009 Torch Mobile, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "config.h"
+#include "PluginPackage.h"
+
+#include "MIMETypeRegistry.h"
+#include "PluginDatabase.h"
+#include "PluginDebug.h"
+#include "Timer.h"
+#include "npruntime_impl.h"
+#include <string.h>
+#include <wtf/StdLibExtras.h>
+#include <wtf/text/CString.h>
+#include <shlwapi.h>
+
+namespace WebCore {
+
+static String getVersionInfo(const LPVOID versionInfoData, const String& info)
+{
+ LPVOID buffer;
+ UINT bufferLength;
+ String subInfo = "\\StringfileInfo\\040904E4\\" + info;
+ bool retval = VerQueryValueW(versionInfoData,
+ const_cast<UChar*>(subInfo.charactersWithNullTermination().data()),
+ &buffer, &bufferLength);
+ if (!retval || bufferLength == 0)
+ return String();
+
+ // Subtract 1 from the length; we don't want the trailing null character.
+ return String(reinterpret_cast<UChar*>(buffer), bufferLength - 1);
+}
+
+bool PluginPackage::isPluginBlacklisted()
+{
+ if (name() == "Citrix ICA Client") {
+ // The Citrix ICA Client plug-in requires a Mozilla-based browser; see <rdar://6418681>.
+ return true;
+ }
+
+ if (name() == "Silverlight Plug-In") {
+ // workaround for <rdar://5557379> Crash in Silverlight when opening microsoft.com.
+ // the latest 1.0 version of Silverlight does not reproduce this crash, so allow it
+ // and any newer versions
+ static const PlatformModuleVersion slPluginMinRequired(0x51BE0000, 0x00010000);
+
+ if (compareFileVersion(slPluginMinRequired) < 0)
+ return true;
+ } else if (equalIgnoringCase(fileName(), "npmozax.dll")) {
+ // Bug 15217: Mozilla ActiveX control complains about missing xpcom_core.dll
+ return true;
+ } else if (equalIgnoringCase(fileName(), "npwpf.dll")) {
+ // Bug 57119: Microsoft Windows Presentation Foundation (WPF) plug-in complains about missing xpcom.dll
+ return true;
+ } else if (name() == "Yahoo Application State Plugin") {
+ // https://bugs.webkit.org/show_bug.cgi?id=26860
+ // Bug in Yahoo Application State plug-in earlier than 1.0.0.6 leads to heap corruption.
+ static const PlatformModuleVersion yahooAppStatePluginMinRequired(0x00000006, 0x00010000);
+ if (compareFileVersion(yahooAppStatePluginMinRequired) < 0)
+ return true;
+ }
+
+ return false;
+}
+
+void PluginPackage::determineQuirks(const String& mimeType)
+{
+ if (mimeType == "application/x-shockwave-flash") {
+ static const PlatformModuleVersion flashTenVersion(0x00000000, 0x000a0000);
+
+ // Pre 10 Flash only requests windowless plugins if we return a mozilla user agent
+ if (compareFileVersion(flashTenVersion) < 0)
+ m_quirks.add(PluginQuirkWantsMozillaUserAgent);
+
+ m_quirks.add(PluginQuirkThrottleInvalidate);
+ m_quirks.add(PluginQuirkThrottleWMUserPlusOneMessages);
+ m_quirks.add(PluginQuirkFlashURLNotifyBug);
+ }
+
+ if (name().contains("Microsoft") && name().contains("Windows Media")) {
+ // The WMP plugin sets its size on the first NPP_SetWindow call and never updates its size, so
+ // call SetWindow when the plugin view has a correct size
+ m_quirks.add(PluginQuirkDeferFirstSetWindowCall);
+
+ // Windowless mode does not work at all with the WMP plugin so just remove that parameter
+ // and don't pass it to the plug-in.
+ m_quirks.add(PluginQuirkRemoveWindowlessVideoParam);
+
+ // WMP has a modal message loop that it enters whenever we call it or
+ // ask it to paint. This modal loop can deliver messages to other
+ // windows in WebKit at times when they are not expecting them (for
+ // example, delivering a WM_PAINT message during a layout), and these
+ // can cause crashes.
+ m_quirks.add(PluginQuirkHasModalMessageLoop);
+ }
+
+ if (name() == "VLC Multimedia Plugin" || name() == "VLC Multimedia Plug-in") {
+ // VLC hangs on NPP_Destroy if we call NPP_SetWindow with a null window handle
+ m_quirks.add(PluginQuirkDontSetNullWindowHandleOnDestroy);
+
+ // VLC 0.8.6d and 0.8.6e crash if multiple instances are created.
+ // <rdar://problem/5773070> tracks allowing multiple instances when this
+ // bug is fixed.
+ m_quirks.add(PluginQuirkDontAllowMultipleInstances);
+ }
+
+ // The DivX plugin sets its size on the first NPP_SetWindow call and never updates its size, so
+ // call SetWindow when the plugin view has a correct size
+ if (mimeType == "video/divx")
+ m_quirks.add(PluginQuirkDeferFirstSetWindowCall);
+
+ // FIXME: This is a workaround for a problem in our NPRuntime bindings; if a plug-in creates an
+ // NPObject and passes it to a function it's not possible to see what root object that NPObject belongs to.
+ // Thus, we don't know that the object should be invalidated when the plug-in instance goes away.
+ // See <rdar://problem/5487742>.
+ if (mimeType == "application/x-silverlight")
+ m_quirks.add(PluginQuirkDontUnloadPlugin);
+
+ if (MIMETypeRegistry::isJavaAppletMIMEType(mimeType)) {
+ // Because a single process cannot create multiple VMs, and we cannot reliably unload a
+ // Java VM, we cannot unload the Java plugin, or we'll lose reference to our only VM
+ m_quirks.add(PluginQuirkDontUnloadPlugin);
+
+ // Setting the window region to an empty region causes bad scrolling repaint problems
+ // with the Java plug-in.
+ m_quirks.add(PluginQuirkDontClipToZeroRectWhenScrolling);
+ }
+
+ if (mimeType == "audio/x-pn-realaudio-plugin") {
+ // Prevent the Real plugin from calling the Window Proc recursively, causing the stack to overflow.
+ m_quirks.add(PluginQuirkDontCallWndProcForSameMessageRecursively);
+
+ static const PlatformModuleVersion lastKnownUnloadableRealPlayerVersion(0x000B0B24, 0x00060000);
+
+ // Unloading RealPlayer versions newer than 10.5 can cause a hang; see rdar://5669317.
+ // FIXME: Resume unloading when this bug in the RealPlayer Plug-In is fixed (rdar://5713147)
+ if (compareFileVersion(lastKnownUnloadableRealPlayerVersion) > 0)
+ m_quirks.add(PluginQuirkDontUnloadPlugin);
+ }
+}
+
+bool PluginPackage::fetchInfo()
+{
+ DWORD versionInfoSize, zeroHandle;
+ versionInfoSize = GetFileVersionInfoSizeW(const_cast<UChar*>(m_path.charactersWithNullTermination().data()), &zeroHandle);
+ if (versionInfoSize == 0)
+ return false;
+
+ auto versionInfoData = std::make_unique<char[]>(versionInfoSize);
+
+ if (!GetFileVersionInfoW(const_cast<UChar*>(m_path.charactersWithNullTermination().data()),
+ 0, versionInfoSize, versionInfoData.get()))
+ return false;
+
+ m_name = getVersionInfo(versionInfoData.get(), "ProductName");
+ m_description = getVersionInfo(versionInfoData.get(), "FileDescription");
+ if (m_name.isNull() || m_description.isNull())
+ return false;
+
+ VS_FIXEDFILEINFO* info;
+ UINT infoSize;
+ if (!VerQueryValueW(versionInfoData.get(), L"\\", (LPVOID*) &info, &infoSize) || infoSize < sizeof(VS_FIXEDFILEINFO))
+ return false;
+ m_moduleVersion.leastSig = info->dwFileVersionLS;
+ m_moduleVersion.mostSig = info->dwFileVersionMS;
+
+ if (isPluginBlacklisted())
+ return false;
+
+ Vector<String> types;
+ getVersionInfo(versionInfoData.get(), "MIMEType").split('|', types);
+ Vector<String> extensionLists;
+ getVersionInfo(versionInfoData.get(), "FileExtents").split('|', extensionLists);
+ Vector<String> descriptions;
+ getVersionInfo(versionInfoData.get(), "FileOpenName").split('|', descriptions);
+
+ for (unsigned i = 0; i < types.size(); i++) {
+ String type = types[i].lower();
+ String description = i < descriptions.size() ? descriptions[i] : "";
+ String extensionList = i < extensionLists.size() ? extensionLists[i] : "";
+
+ Vector<String> extensionsVector;
+ extensionList.split(',', extensionsVector);
+
+ // Get rid of the extension list that may be at the end of the description string.
+ int pos = description.find("(*");
+ if (pos != -1) {
+ // There might be a space that we need to get rid of.
+ if (pos > 1 && description[pos - 1] == ' ')
+ pos--;
+ description = description.left(pos);
+ }
+
+ // Determine the quirks for the MIME types this plug-in supports
+ determineQuirks(type);
+
+ m_mimeToExtensions.add(type, extensionsVector);
+ m_mimeToDescriptions.add(type, description);
+ }
+
+ return true;
+}
+
+bool PluginPackage::load()
+{
+ if (m_freeLibraryTimer.isActive()) {
+ ASSERT(m_module);
+ m_freeLibraryTimer.stop();
+ } else if (m_isLoaded) {
+ if (m_quirks.contains(PluginQuirkDontAllowMultipleInstances))
+ return false;
+ m_loadCount++;
+ return true;
+ } else {
+ WCHAR currentPath[MAX_PATH];
+
+ if (!::GetCurrentDirectoryW(MAX_PATH, currentPath))
+ return false;
+
+ String path = m_path.substring(0, m_path.reverseFind('\\'));
+
+ if (!::SetCurrentDirectoryW(path.charactersWithNullTermination().data()))
+ return false;
+
+ // Load the library
+ m_module = ::LoadLibraryExW(m_path.charactersWithNullTermination().data(), 0, LOAD_WITH_ALTERED_SEARCH_PATH);
+
+ if (!::SetCurrentDirectoryW(currentPath)) {
+ if (m_module)
+ ::FreeLibrary(m_module);
+ return false;
+ }
+ }
+
+ if (!m_module)
+ return false;
+
+ m_isLoaded = true;
+
+ NP_GetEntryPointsFuncPtr NP_GetEntryPoints = 0;
+ NP_InitializeFuncPtr NP_Initialize = 0;
+ NPError npErr;
+
+ NP_Initialize = (NP_InitializeFuncPtr)GetProcAddress(m_module, "NP_Initialize");
+ NP_GetEntryPoints = (NP_GetEntryPointsFuncPtr)GetProcAddress(m_module, "NP_GetEntryPoints");
+ m_NPP_Shutdown = (NPP_ShutdownProcPtr)GetProcAddress(m_module, "NP_Shutdown");
+
+ if (!NP_Initialize || !NP_GetEntryPoints || !m_NPP_Shutdown)
+ goto abort;
+
+ memset(&m_pluginFuncs, 0, sizeof(m_pluginFuncs));
+ m_pluginFuncs.size = sizeof(m_pluginFuncs);
+
+ npErr = NP_GetEntryPoints(&m_pluginFuncs);
+ LOG_NPERROR(npErr);
+ if (npErr != NPERR_NO_ERROR)
+ goto abort;
+
+ initializeBrowserFuncs();
+
+ npErr = NP_Initialize(&m_browserFuncs);
+ LOG_NPERROR(npErr);
+
+ if (npErr != NPERR_NO_ERROR)
+ goto abort;
+
+ m_loadCount++;
+ return true;
+
+abort:
+ unloadWithoutShutdown();
+ return false;
+}
+
+unsigned PluginPackage::hash() const
+{
+ const unsigned hashCodes[] = {
+ m_name.impl()->hash(),
+ m_description.impl()->hash(),
+ m_mimeToExtensions.size()
+ };
+
+ return StringHasher::hashMemory<sizeof(hashCodes)>(hashCodes);
+}
+
+bool PluginPackage::equal(const PluginPackage& a, const PluginPackage& b)
+{
+ if (a.m_name != b.m_name)
+ return false;
+
+ if (a.m_description != b.m_description)
+ return false;
+
+ if (a.m_mimeToExtensions.size() != b.m_mimeToExtensions.size())
+ return false;
+
+ MIMEToExtensionsMap::const_iterator::Keys end = a.m_mimeToExtensions.end().keys();
+ for (MIMEToExtensionsMap::const_iterator::Keys it = a.m_mimeToExtensions.begin().keys(); it != end; ++it) {
+ if (!b.m_mimeToExtensions.contains(*it))
+ return false;
+ }
+
+ return true;
+}
+
+uint16_t PluginPackage::NPVersion() const
+{
+ return NP_VERSION_MINOR;
+}
+}
</ins></span></pre></div>
<a id="trunkSourceWebKitwinPluginsPluginQuirkSethfromrev178217trunkSourceWebCorepluginsPluginQuirkSeth"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebKit/win/Plugins/PluginQuirkSet.h (from rev 178217, trunk/Source/WebCore/plugins/PluginQuirkSet.h) (0 => 178219)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/win/Plugins/PluginQuirkSet.h         (rev 0)
+++ trunk/Source/WebKit/win/Plugins/PluginQuirkSet.h        2015-01-10 00:16:52 UTC (rev 178219)
</span><span class="lines">@@ -0,0 +1,66 @@
</span><ins>+/*
+ * Copyright (C) 2008 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef PluginQuirkSet_h
+#define PluginQuirkSet_h
+
+
+namespace WebCore {
+
+ enum PluginQuirk {
+ PluginQuirkWantsMozillaUserAgent = 1 << 0,
+ PluginQuirkDeferFirstSetWindowCall = 1 << 1,
+ PluginQuirkThrottleInvalidate = 1 << 2,
+ PluginQuirkRemoveWindowlessVideoParam = 1 << 3,
+ PluginQuirkThrottleWMUserPlusOneMessages = 1 << 4,
+ PluginQuirkDontUnloadPlugin = 1 << 5,
+ PluginQuirkDontCallWndProcForSameMessageRecursively = 1 << 6,
+ PluginQuirkHasModalMessageLoop = 1 << 7,
+ PluginQuirkFlashURLNotifyBug = 1 << 8,
+ PluginQuirkDontClipToZeroRectWhenScrolling = 1 << 9,
+ PluginQuirkDontSetNullWindowHandleOnDestroy = 1 << 10,
+ PluginQuirkDontAllowMultipleInstances = 1 << 11,
+ PluginQuirkRequiresGtkToolKit = 1 << 12,
+ PluginQuirkRequiresDefaultScreenDepth = 1 << 13,
+ PluginQuirkDontCallSetWindowMoreThanOnce = 1 << 14,
+ PluginQuirkIgnoreRightClickInWindowlessMode = 1 << 15,
+ PluginQuirkWantsChromeUserAgent = 1 << 16
+ };
+
+ class PluginQuirkSet {
+ public:
+ PluginQuirkSet() : m_quirks(0) { }
+ void add(PluginQuirk quirk) { m_quirks |= quirk; }
+ bool contains(PluginQuirk quirk) const { return m_quirks & quirk; }
+ private:
+ unsigned m_quirks;
+ };
+
+} // namespace WebCore
+
+#endif // PluginQuirkSet_h
</ins></span></pre></div>
<a id="trunkSourceWebKitwinPluginsPluginStreamcppfromrev178217trunkSourceWebCorepluginsPluginStreamcpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebKit/win/Plugins/PluginStream.cpp (from rev 178217, trunk/Source/WebCore/plugins/PluginStream.cpp) (0 => 178219)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/win/Plugins/PluginStream.cpp         (rev 0)
+++ trunk/Source/WebKit/win/Plugins/PluginStream.cpp        2015-01-10 00:16:52 UTC (rev 178219)
</span><span class="lines">@@ -0,0 +1,482 @@
</span><ins>+/*
+ * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2008 Collabora, Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "PluginStream.h"
+
+#include "DocumentLoader.h"
+#include "Frame.h"
+#include "FrameLoader.h"
+#include "HTTPHeaderNames.h"
+#include "PluginDebug.h"
+#include "ResourceLoadScheduler.h"
+#include "SharedBuffer.h"
+#include "SubresourceLoader.h"
+#include <wtf/StringExtras.h>
+#include <wtf/text/CString.h>
+#include <wtf/text/StringBuilder.h>
+#include <wtf/text/WTFString.h>
+
+// We use -2 here because some plugins like to return -1 to indicate error
+// and this way we won't clash with them.
+static const int WebReasonNone = -2;
+
+using std::max;
+using std::min;
+
+namespace WebCore {
+
+typedef HashMap<NPStream*, NPP> StreamMap;
+static StreamMap& streams()
+{
+ static StreamMap staticStreams;
+ return staticStreams;
+}
+
+PluginStream::PluginStream(PluginStreamClient* client, Frame* frame, const ResourceRequest& resourceRequest, bool sendNotification, void* notifyData, const NPPluginFuncs* pluginFuncs, NPP instance, const PluginQuirkSet& quirks)
+ : m_resourceRequest(resourceRequest)
+ , m_client(client)
+ , m_frame(frame)
+ , m_notifyData(notifyData)
+ , m_sendNotification(sendNotification)
+ , m_streamState(StreamBeforeStarted)
+ , m_loadManually(false)
+ , m_delayDeliveryTimer(*this, &PluginStream::delayDeliveryTimerFired)
+ , m_tempFileHandle(invalidPlatformFileHandle)
+ , m_pluginFuncs(pluginFuncs)
+ , m_instance(instance)
+ , m_quirks(quirks)
+{
+ ASSERT(m_instance);
+
+ m_stream.url = 0;
+ m_stream.ndata = 0;
+ m_stream.pdata = 0;
+ m_stream.end = 0;
+ m_stream.notifyData = 0;
+ m_stream.lastmodified = 0;
+ m_stream.headers = 0;
+
+ streams().add(&m_stream, m_instance);
+}
+
+PluginStream::~PluginStream()
+{
+ ASSERT(m_streamState != StreamStarted);
+ ASSERT(!m_loader);
+
+ fastFree((char*)m_stream.url);
+
+ streams().remove(&m_stream);
+}
+
+void PluginStream::start()
+{
+ ASSERT(!m_loadManually);
+ m_loader = resourceLoadScheduler()->schedulePluginStreamLoad(m_frame, this, m_resourceRequest);
+}
+
+void PluginStream::stop()
+{
+ m_streamState = StreamStopped;
+
+ if (m_loadManually) {
+ ASSERT(!m_loader);
+
+ DocumentLoader* documentLoader = m_frame->loader().activeDocumentLoader();
+ ASSERT(documentLoader);
+
+ if (documentLoader->isLoadingMainResource())
+ documentLoader->cancelMainResourceLoad(m_frame->loader().cancelledError(m_resourceRequest));
+
+ return;
+ }
+
+ if (m_loader) {
+ m_loader->cancel();
+ m_loader = 0;
+ }
+
+ m_client = 0;
+}
+
+static uint32_t lastModifiedDate(const ResourceResponse& response)
+{
+ double lastModified = response.lastModified();
+ if (!std::isfinite(lastModified))
+ return 0;
+
+ return lastModified * 1000;
+}
+
+void PluginStream::startStream()
+{
+ ASSERT(m_streamState == StreamBeforeStarted);
+
+ const URL& responseURL = m_resourceResponse.url();
+
+ // Some plugins (Flash) expect that javascript URLs are passed back decoded as this is the
+ // format used when requesting the URL.
+ if (protocolIsJavaScript(responseURL))
+ m_stream.url = fastStrDup(decodeURLEscapeSequences(responseURL.string()).utf8().data());
+ else
+ m_stream.url = fastStrDup(responseURL.string().utf8().data());
+
+ CString mimeTypeStr = m_resourceResponse.mimeType().utf8();
+
+ long long expectedContentLength = m_resourceResponse.expectedContentLength();
+
+ if (m_resourceResponse.isHTTP()) {
+ StringBuilder stringBuilder;
+ String separator = ASCIILiteral(": ");
+
+ String statusLine = "HTTP " + String::number(m_resourceResponse.httpStatusCode()) + " OK\n";
+ stringBuilder.append(statusLine);
+
+ HTTPHeaderMap::const_iterator end = m_resourceResponse.httpHeaderFields().end();
+ for (HTTPHeaderMap::const_iterator it = m_resourceResponse.httpHeaderFields().begin(); it != end; ++it) {
+ stringBuilder.append(it->key);
+ stringBuilder.append(separator);
+ stringBuilder.append(it->value);
+ stringBuilder.append('\n');
+ }
+
+ m_headers = stringBuilder.toString().utf8();
+
+ // If the content is encoded (most likely compressed), then don't send its length to the plugin,
+ // which is only interested in the decoded length, not yet known at the moment.
+ // <rdar://problem/4470599> tracks a request for -[NSURLResponse expectedContentLength] to incorporate this logic.
+ String contentEncoding = m_resourceResponse.httpHeaderField(HTTPHeaderName::ContentEncoding);
+ if (!contentEncoding.isNull() && contentEncoding != "identity")
+ expectedContentLength = -1;
+ }
+
+ m_stream.headers = m_headers.data();
+ m_stream.pdata = 0;
+ m_stream.ndata = this;
+ m_stream.end = max(expectedContentLength, 0LL);
+ m_stream.lastmodified = lastModifiedDate(m_resourceResponse);
+ m_stream.notifyData = m_notifyData;
+
+ m_transferMode = NP_NORMAL;
+ m_offset = 0;
+ m_reason = WebReasonNone;
+
+ // Protect the stream if destroystream is called from within the newstream handler
+ RefPtr<PluginStream> protect(this);
+
+ // calling into a plug-in could result in re-entrance if the plug-in yields
+ // control to the system (rdar://5744899). prevent this by deferring further
+ // loading while calling into the plug-in.
+ if (m_loader)
+ m_loader->setDefersLoading(true);
+ NPError npErr = m_pluginFuncs->newstream(m_instance, (NPMIMEType)mimeTypeStr.data(), &m_stream, false, &m_transferMode);
+ if (m_loader)
+ m_loader->setDefersLoading(false);
+
+ // If the stream was destroyed in the call to newstream we return
+ if (m_reason != WebReasonNone)
+ return;
+
+ if (npErr != NPERR_NO_ERROR) {
+ cancelAndDestroyStream(npErr);
+ return;
+ }
+
+ m_streamState = StreamStarted;
+
+ if (m_transferMode == NP_NORMAL)
+ return;
+
+ m_path = openTemporaryFile("WKP", m_tempFileHandle);
+
+ // Something went wrong, cancel loading the stream
+ if (!isHandleValid(m_tempFileHandle))
+ cancelAndDestroyStream(NPRES_NETWORK_ERR);
+}
+
+NPP PluginStream::ownerForStream(NPStream* stream)
+{
+ return streams().get(stream);
+}
+
+void PluginStream::cancelAndDestroyStream(NPReason reason)
+{
+ RefPtr<PluginStream> protect(this);
+
+ destroyStream(reason);
+ stop();
+}
+
+void PluginStream::destroyStream(NPReason reason)
+{
+ m_reason = reason;
+ if (m_reason != NPRES_DONE) {
+ // Stop any pending data from being streamed
+ if (m_deliveryData)
+ m_deliveryData->resize(0);
+ } else if (m_deliveryData && m_deliveryData->size() > 0) {
+ // There is more data to be streamed, don't destroy the stream now.
+ return;
+ }
+ destroyStream();
+}
+
+void PluginStream::destroyStream()
+{
+ if (m_streamState == StreamStopped)
+ return;
+
+ ASSERT(m_reason != WebReasonNone);
+ ASSERT(!m_deliveryData || m_deliveryData->size() == 0);
+
+ closeFile(m_tempFileHandle);
+
+ bool newStreamCalled = m_stream.ndata;
+
+ // Protect from destruction if:
+ // NPN_DestroyStream is called from NPP_NewStream or
+ // PluginStreamClient::streamDidFinishLoading() removes the last reference
+ RefPtr<PluginStream> protect(this);
+
+ if (newStreamCalled) {
+ if (m_reason == NPRES_DONE && (m_transferMode == NP_ASFILE || m_transferMode == NP_ASFILEONLY)) {
+ ASSERT(!m_path.isNull());
+
+ if (m_loader)
+ m_loader->setDefersLoading(true);
+ m_pluginFuncs->asfile(m_instance, &m_stream, m_path.utf8().data());
+ if (m_loader)
+ m_loader->setDefersLoading(false);
+ }
+
+ if (m_streamState != StreamBeforeStarted) {
+ if (m_loader)
+ m_loader->setDefersLoading(true);
+
+ NPError npErr = m_pluginFuncs->destroystream(m_instance, &m_stream, m_reason);
+
+ if (m_loader)
+ m_loader->setDefersLoading(false);
+
+ LOG_NPERROR(npErr);
+ }
+
+ m_stream.ndata = 0;
+ }
+
+ if (m_sendNotification) {
+ // Flash 9 can dereference null if we call NPP_URLNotify without first calling NPP_NewStream
+ // for requests made with NPN_PostURLNotify; see <rdar://5588807>
+ if (m_loader)
+ m_loader->setDefersLoading(true);
+ if (!newStreamCalled && m_quirks.contains(PluginQuirkFlashURLNotifyBug) &&
+ equalIgnoringCase(m_resourceRequest.httpMethod(), "POST")) {
+ m_transferMode = NP_NORMAL;
+ m_stream.url = "";
+ m_stream.notifyData = m_notifyData;
+
+ static char emptyMimeType[] = "";
+ m_pluginFuncs->newstream(m_instance, emptyMimeType, &m_stream, false, &m_transferMode);
+ m_pluginFuncs->destroystream(m_instance, &m_stream, m_reason);
+
+ // in successful requests, the URL is dynamically allocated and freed in our
+ // destructor, so reset it to 0
+ m_stream.url = 0;
+ }
+ m_pluginFuncs->urlnotify(m_instance, m_resourceRequest.url().string().utf8().data(), m_reason, m_notifyData);
+ if (m_loader)
+ m_loader->setDefersLoading(false);
+ }
+
+ m_streamState = StreamStopped;
+
+ if (!m_loadManually && m_client)
+ m_client->streamDidFinishLoading(this);
+
+ if (!m_path.isNull())
+ deleteFile(m_path);
+}
+
+void PluginStream::delayDeliveryTimerFired()
+{
+ deliverData();
+}
+
+void PluginStream::deliverData()
+{
+ ASSERT(m_deliveryData);
+
+ if (m_streamState == StreamStopped)
+ // FIXME: We should cancel our job in the SubresourceLoader on error so we don't reach this case
+ return;
+
+ ASSERT(m_streamState != StreamBeforeStarted);
+
+ if (!m_stream.ndata || m_deliveryData->size() == 0)
+ return;
+
+ int32_t totalBytes = m_deliveryData->size();
+ int32_t totalBytesDelivered = 0;
+
+ if (m_loader)
+ m_loader->setDefersLoading(true);
+ while (totalBytesDelivered < totalBytes) {
+ int32_t deliveryBytes = m_pluginFuncs->writeready(m_instance, &m_stream);
+
+ if (deliveryBytes <= 0) {
+ m_delayDeliveryTimer.startOneShot(0);
+ break;
+ } else {
+ deliveryBytes = min(deliveryBytes, totalBytes - totalBytesDelivered);
+ int32_t dataLength = deliveryBytes;
+ char* data = m_deliveryData->data() + totalBytesDelivered;
+
+ // Write the data
+ deliveryBytes = m_pluginFuncs->write(m_instance, &m_stream, m_offset, dataLength, (void*)data);
+ if (deliveryBytes < 0) {
+ LOG_PLUGIN_NET_ERROR();
+ if (m_loader)
+ m_loader->setDefersLoading(false);
+ cancelAndDestroyStream(NPRES_NETWORK_ERR);
+ return;
+ }
+ deliveryBytes = min(deliveryBytes, dataLength);
+ m_offset += deliveryBytes;
+ totalBytesDelivered += deliveryBytes;
+ }
+ }
+ if (m_loader)
+ m_loader->setDefersLoading(false);
+
+ if (totalBytesDelivered > 0) {
+ if (totalBytesDelivered < totalBytes) {
+ int remainingBytes = totalBytes - totalBytesDelivered;
+ memmove(m_deliveryData->data(), m_deliveryData->data() + totalBytesDelivered, remainingBytes);
+ m_deliveryData->resize(remainingBytes);
+ } else {
+ m_deliveryData->resize(0);
+ if (m_reason != WebReasonNone)
+ destroyStream();
+ }
+ }
+}
+
+void PluginStream::sendJavaScriptStream(const URL& requestURL, const CString& resultString)
+{
+ didReceiveResponse(0, ResourceResponse(requestURL, "text/plain", resultString.length(), ""));
+
+ if (m_streamState == StreamStopped)
+ return;
+
+ if (!resultString.isNull()) {
+ didReceiveData(0, resultString.data(), resultString.length());
+ if (m_streamState == StreamStopped)
+ return;
+ }
+
+ m_loader = 0;
+
+ destroyStream(resultString.isNull() ? NPRES_NETWORK_ERR : NPRES_DONE);
+}
+
+void PluginStream::didReceiveResponse(NetscapePlugInStreamLoader* loader, const ResourceResponse& response)
+{
+ ASSERT_UNUSED(loader, loader == m_loader);
+ ASSERT(m_streamState == StreamBeforeStarted);
+
+ m_resourceResponse = response;
+
+ startStream();
+}
+
+void PluginStream::didReceiveData(NetscapePlugInStreamLoader* loader, const char* data, int length)
+{
+ ASSERT_UNUSED(loader, loader == m_loader);
+ ASSERT(m_streamState == StreamStarted);
+
+ // If the plug-in cancels the stream in deliverData it could be deleted,
+ // so protect it here.
+ RefPtr<PluginStream> protect(this);
+
+ if (m_transferMode != NP_ASFILEONLY) {
+ if (!m_deliveryData)
+ m_deliveryData = std::make_unique<Vector<char>>();
+
+ int oldSize = m_deliveryData->size();
+ m_deliveryData->resize(oldSize + length);
+ memcpy(m_deliveryData->data() + oldSize, data, length);
+
+ deliverData();
+ }
+
+ if (m_streamState != StreamStopped && isHandleValid(m_tempFileHandle)) {
+ int bytesWritten = writeToFile(m_tempFileHandle, data, length);
+ if (bytesWritten != length)
+ cancelAndDestroyStream(NPRES_NETWORK_ERR);
+ }
+}
+
+void PluginStream::didFail(NetscapePlugInStreamLoader* loader, const ResourceError&)
+{
+ ASSERT_UNUSED(loader, loader == m_loader);
+
+ LOG_PLUGIN_NET_ERROR();
+
+ // destroyStream can result in our being deleted
+ RefPtr<PluginStream> protect(this);
+
+ destroyStream(NPRES_NETWORK_ERR);
+
+ m_loader = 0;
+}
+
+void PluginStream::didFinishLoading(NetscapePlugInStreamLoader* loader)
+{
+ ASSERT_UNUSED(loader, loader == m_loader);
+ ASSERT(m_streamState == StreamStarted);
+
+ // destroyStream can result in our being deleted
+ RefPtr<PluginStream> protect(this);
+
+ destroyStream(NPRES_DONE);
+
+ m_loader = 0;
+}
+
+bool PluginStream::wantsAllStreams() const
+{
+ if (!m_pluginFuncs->getvalue)
+ return false;
+
+ void* result = 0;
+ if (m_pluginFuncs->getvalue(m_instance, NPPVpluginWantsAllNetworkStreams, &result) != NPERR_NO_ERROR)
+ return false;
+
+ return result != 0;
+}
+
+}
</ins></span></pre></div>
<a id="trunkSourceWebKitwinPluginsPluginStreamhfromrev178217trunkSourceWebCorepluginsPluginStreamh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebKit/win/Plugins/PluginStream.h (from rev 178217, trunk/Source/WebCore/plugins/PluginStream.h) (0 => 178219)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/win/Plugins/PluginStream.h         (rev 0)
+++ trunk/Source/WebKit/win/Plugins/PluginStream.h        2015-01-10 00:16:52 UTC (rev 178219)
</span><span class="lines">@@ -0,0 +1,122 @@
</span><ins>+/*
+ * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2008 Collabora, Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef PluginStream_h
+#define PluginStream_h
+
+#include "FileSystem.h"
+#include "URL.h"
+#include "NetscapePlugInStreamLoader.h"
+#include "PluginQuirkSet.h"
+#include "ResourceRequest.h"
+#include "ResourceResponse.h"
+#include "Timer.h"
+#include "npruntime_internal.h"
+#include <wtf/HashMap.h>
+#include <wtf/RefCounted.h>
+#include <wtf/Vector.h>
+#include <wtf/text/CString.h>
+#include <wtf/text/StringHash.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+ class Frame;
+ class PluginStream;
+
+ enum PluginStreamState { StreamBeforeStarted, StreamStarted, StreamStopped };
+
+ class PluginStreamClient {
+ public:
+ virtual ~PluginStreamClient() {}
+ virtual void streamDidFinishLoading(PluginStream*) {}
+ };
+
+ class PluginStream : public RefCounted<PluginStream>, private NetscapePlugInStreamLoaderClient {
+ public:
+ static PassRefPtr<PluginStream> create(PluginStreamClient* client, Frame* frame, const ResourceRequest& request, bool sendNotification, void* notifyData, const NPPluginFuncs* functions, NPP instance, const PluginQuirkSet& quirks)
+ {
+ return adoptRef(new PluginStream(client, frame, request, sendNotification, notifyData, functions, instance, quirks));
+ }
+ virtual ~PluginStream();
+
+ void start();
+ void stop();
+
+ void startStream();
+
+ void setLoadManually(bool loadManually) { m_loadManually = loadManually; }
+
+ void sendJavaScriptStream(const URL& requestURL, const WTF::CString& resultString);
+ void cancelAndDestroyStream(NPReason);
+
+ static NPP ownerForStream(NPStream*);
+
+ // NetscapePlugInStreamLoaderClient
+ virtual void didReceiveResponse(NetscapePlugInStreamLoader*, const ResourceResponse&);
+ virtual void didReceiveData(NetscapePlugInStreamLoader*, const char*, int);
+ virtual void didFail(NetscapePlugInStreamLoader*, const ResourceError&);
+ virtual void didFinishLoading(NetscapePlugInStreamLoader*);
+ virtual bool wantsAllStreams() const;
+
+ private:
+ PluginStream(PluginStreamClient*, Frame*, const ResourceRequest&, bool sendNotification, void* notifyData, const NPPluginFuncs*, NPP instance, const PluginQuirkSet&);
+
+ void deliverData();
+ void destroyStream(NPReason);
+ void destroyStream();
+
+ ResourceRequest m_resourceRequest;
+ ResourceResponse m_resourceResponse;
+
+ PluginStreamClient* m_client;
+ Frame* m_frame;
+ RefPtr<NetscapePlugInStreamLoader> m_loader;
+ void* m_notifyData;
+ bool m_sendNotification;
+ PluginStreamState m_streamState;
+ bool m_loadManually;
+
+ Timer m_delayDeliveryTimer;
+ void delayDeliveryTimerFired();
+
+ std::unique_ptr<Vector<char>> m_deliveryData;
+
+ PlatformFileHandle m_tempFileHandle;
+
+ const NPPluginFuncs* m_pluginFuncs;
+ NPP m_instance;
+ uint16_t m_transferMode;
+ int32_t m_offset;
+ CString m_headers;
+ String m_path;
+ NPReason m_reason;
+ NPStream m_stream;
+ PluginQuirkSet m_quirks;
+ };
+
+} // namespace WebCore
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebKitwinPluginsPluginViewcppfromrev178217trunkSourceWebCorepluginsPluginViewcpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebKit/win/Plugins/PluginView.cpp (from rev 178217, trunk/Source/WebCore/plugins/PluginView.cpp) (0 => 178219)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/win/Plugins/PluginView.cpp         (rev 0)
+++ trunk/Source/WebKit/win/Plugins/PluginView.cpp        2015-01-10 00:16:52 UTC (rev 178219)
</span><span class="lines">@@ -0,0 +1,1489 @@
</span><ins>+/*
+ * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2008 Collabora Ltd. All rights reserved.
+ * Copyright (C) 2010 Girish Ramakrishnan <girish@forwardbias.in>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "PluginView.h"
+
+#include "PluginDatabase.h"
+#include "PluginDebug.h"
+#include "PluginPackage.h"
+#include <WebCore/BridgeJSC.h>
+#include <WebCore/Chrome.h>
+#include <WebCore/CookieJar.h>
+#include <WebCore/Document.h>
+#include <WebCore/DocumentLoader.h>
+#include <WebCore/Element.h>
+#include <WebCore/FocusController.h>
+#include <WebCore/Frame.h>
+#include <WebCore/FrameLoadRequest.h>
+#include <WebCore/FrameLoader.h>
+#include <WebCore/FrameLoaderClient.h>
+#include <WebCore/FrameTree.h>
+#include <WebCore/FrameView.h>
+#include <WebCore/GraphicsContext.h>
+#include <WebCore/HTMLNames.h>
+#include <WebCore/HTMLPlugInElement.h>
+#include <WebCore/HTTPHeaderNames.h>
+#include <WebCore/Image.h>
+#include <WebCore/JSDOMBinding.h>
+#include <WebCore/JSDOMWindow.h>
+#include <WebCore/KeyboardEvent.h>
+#include <WebCore/MIMETypeRegistry.h>
+#include <WebCore/MouseEvent.h>
+#include <WebCore/NotImplemented.h>
+#include <WebCore/Page.h>
+#include <WebCore/PlatformMouseEvent.h>
+#include <WebCore/PluginMainThreadScheduler.h>
+#include <WebCore/ProxyServer.h>
+#include <WebCore/RenderBox.h>
+#include <WebCore/RenderObject.h>
+#include <WebCore/ScriptController.h>
+#include <WebCore/SecurityOrigin.h>
+#include <WebCore/Settings.h>
+#include <WebCore/UserGestureIndicator.h>
+#include <WebCore/WheelEvent.h>
+#include <WebCore/c_instance.h>
+#include <WebCore/npruntime_impl.h>
+#include <WebCore/runtime_root.h>
+#include <bindings/ScriptValue.h>
+#include <runtime/JSCJSValue.h>
+#include <runtime/JSLock.h>
+#include <wtf/ASCIICType.h>
+#include <wtf/text/WTFString.h>
+
+#if OS(WINDOWS) && ENABLE(NETSCAPE_PLUGIN_API)
+#include "PluginMessageThrottlerWin.h"
+#endif
+
+using JSC::ExecState;
+using JSC::JSLock;
+using JSC::JSObject;
+using JSC::JSValue;
+
+#if ENABLE(NETSCAPE_PLUGIN_API)
+
+using std::min;
+
+using namespace WTF;
+
+namespace WebCore {
+
+using namespace HTMLNames;
+
+static int s_callingPlugin;
+
+typedef HashMap<NPP, PluginView*> InstanceMap;
+
+static InstanceMap& instanceMap()
+{
+ static InstanceMap& map = *new InstanceMap;
+ return map;
+}
+
+static String scriptStringIfJavaScriptURL(const URL& url)
+{
+ if (!protocolIsJavaScript(url))
+ return String();
+
+ // This returns an unescaped string
+ return decodeURLEscapeSequences(url.string().substring(11));
+}
+
+PluginView* PluginView::s_currentPluginView = 0;
+
+void PluginView::popPopupsStateTimerFired()
+{
+ popPopupsEnabledState();
+}
+
+IntRect PluginView::windowClipRect() const
+{
+ // Start by clipping to our bounds.
+ IntRect clipRect(m_windowRect);
+
+ // Take our element and get the clip rect from the enclosing layer and frame view.
+ FrameView* parentView = m_element->document().view();
+ clipRect.intersect(parentView->windowClipRectForFrameOwner(m_element, true));
+
+ return clipRect;
+}
+
+void PluginView::setFrameRect(const IntRect& rect)
+{
+ if (m_element->document().printing())
+ return;
+
+ if (rect != frameRect())
+ Widget::setFrameRect(rect);
+
+ updatePluginWidget();
+
+#if OS(WINDOWS)
+ // On Windows always call plugin to change geometry.
+ setNPWindowRect(rect);
+#elif defined(XP_UNIX)
+ // On Unix, multiple calls to setNPWindow() in windowed mode causes Flash to crash
+ if (m_mode == NP_FULL || !m_isWindowed)
+ setNPWindowRect(rect);
+#endif
+}
+
+void PluginView::frameRectsChanged()
+{
+ updatePluginWidget();
+}
+
+void PluginView::clipRectChanged()
+{
+ updatePluginWidget();
+}
+
+void PluginView::handleEvent(Event* event)
+{
+ if (!m_plugin || m_isWindowed)
+ return;
+
+ // Protect the plug-in from deletion while dispatching the event.
+ RefPtr<PluginView> protect(this);
+
+ if (event->isMouseEvent())
+ handleMouseEvent(static_cast<MouseEvent*>(event));
+ else if (event->isKeyboardEvent())
+ handleKeyboardEvent(static_cast<KeyboardEvent*>(event));
+#if defined(XP_MACOSX)
+ else if (event->type() == eventNames().wheelEvent || event->type() == eventNames().mousewheelEvent)
+ handleWheelEvent(static_cast<WheelEvent*>(event));
+#endif
+ else if (event->type() == eventNames().contextmenuEvent)
+ event->setDefaultHandled(); // We don't know if the plug-in has handled mousedown event by displaying a context menu, so we never want WebKit to show a default one.
+#if defined(XP_UNIX) && ENABLE(NETSCAPE_PLUGIN_API)
+ else if (event->type() == eventNames().focusoutEvent)
+ handleFocusOutEvent();
+ else if (event->type() == eventNames().focusinEvent)
+ handleFocusInEvent();
+#endif
+}
+
+void PluginView::init()
+{
+ if (m_haveInitialized)
+ return;
+
+ m_haveInitialized = true;
+
+ if (!m_plugin) {
+ ASSERT(m_status == PluginStatusCanNotFindPlugin);
+ return;
+ }
+
+ LOG(Plugins, "PluginView::init(): Initializing plug-in '%s'", m_plugin->name().utf8().data());
+
+ if (!m_plugin->load()) {
+ m_plugin = 0;
+ m_status = PluginStatusCanNotLoadPlugin;
+ return;
+ }
+
+ if (!startOrAddToUnstartedList()) {
+ m_status = PluginStatusCanNotLoadPlugin;
+ return;
+ }
+
+ m_status = PluginStatusLoadedSuccessfully;
+}
+
+bool PluginView::startOrAddToUnstartedList()
+{
+ if (!m_parentFrame->page())
+ return false;
+
+ // We only delay starting the plug-in if we're going to kick off the load
+ // ourselves. Otherwise, the loader will try to deliver data before we've
+ // started the plug-in.
+ if (!m_loadManually && !m_parentFrame->page()->canStartMedia()) {
+ m_parentFrame->document()->addMediaCanStartListener(this);
+ m_isWaitingToStart = true;
+ return true;
+ }
+
+ return start();
+}
+
+bool PluginView::start()
+{
+ if (m_isStarted)
+ return false;
+
+ m_isWaitingToStart = false;
+
+ PluginMainThreadScheduler::scheduler().registerPlugin(m_instance);
+
+ ASSERT(m_plugin);
+ ASSERT(m_plugin->pluginFuncs()->newp);
+
+ NPError npErr;
+ {
+ PluginView::setCurrentPluginView(this);
+ JSC::JSLock::DropAllLocks dropAllLocks(JSDOMWindowBase::commonVM());
+ setCallingPlugin(true);
+ npErr = m_plugin->pluginFuncs()->newp((NPMIMEType)m_mimeType.utf8().data(), m_instance, m_mode, m_paramCount, m_paramNames, m_paramValues, NULL);
+ setCallingPlugin(false);
+ LOG_NPERROR(npErr);
+ PluginView::setCurrentPluginView(0);
+ }
+
+ if (npErr != NPERR_NO_ERROR) {
+ m_status = PluginStatusCanNotLoadPlugin;
+ PluginMainThreadScheduler::scheduler().unregisterPlugin(m_instance);
+ return false;
+ }
+
+ m_isStarted = true;
+
+ if (!m_url.isEmpty() && !m_loadManually) {
+ FrameLoadRequest frameLoadRequest(m_parentFrame->document()->securityOrigin());
+ frameLoadRequest.resourceRequest().setHTTPMethod("GET");
+ frameLoadRequest.resourceRequest().setURL(m_url);
+ load(frameLoadRequest, false, 0);
+ }
+
+ m_status = PluginStatusLoadedSuccessfully;
+
+ if (!platformStart())
+ m_status = PluginStatusCanNotLoadPlugin;
+
+ if (m_status != PluginStatusLoadedSuccessfully)
+ return false;
+
+ return true;
+}
+
+void PluginView::mediaCanStart()
+{
+ ASSERT(!m_isStarted);
+ if (!start())
+ parentFrame()->loader().client().dispatchDidFailToStartPlugin(this);
+}
+
+PluginView::~PluginView()
+{
+ LOG(Plugins, "PluginView::~PluginView()");
+
+ ASSERT(!m_lifeSupportTimer.isActive());
+
+ // If we failed to find the plug-in, we'll return early in our constructor, and
+ // m_instance will be 0.
+ if (m_instance)
+ instanceMap().remove(m_instance);
+
+ if (m_isWaitingToStart)
+ m_parentFrame->document()->removeMediaCanStartListener(this);
+
+ stop();
+
+ freeStringArray(m_paramNames, m_paramCount);
+ freeStringArray(m_paramValues, m_paramCount);
+
+ platformDestroy();
+
+ m_parentFrame->script().cleanupScriptObjectsForPlugin(this);
+
+ if (m_plugin && !(m_plugin->quirks().contains(PluginQuirkDontUnloadPlugin)))
+ m_plugin->unload();
+}
+
+void PluginView::stop()
+{
+ if (!m_isStarted)
+ return;
+
+ LOG(Plugins, "PluginView::stop(): Stopping plug-in '%s'", m_plugin->name().utf8().data());
+
+ HashSet<RefPtr<PluginStream> > streams = m_streams;
+ HashSet<RefPtr<PluginStream> >::iterator end = streams.end();
+ for (HashSet<RefPtr<PluginStream> >::iterator it = streams.begin(); it != end; ++it) {
+ (*it)->stop();
+ disconnectStream((*it).get());
+ }
+
+ ASSERT(m_streams.isEmpty());
+
+ m_isStarted = false;
+
+ JSC::JSLock::DropAllLocks dropAllLocks(JSDOMWindowBase::commonVM());
+
+#if ENABLE(NETSCAPE_PLUGIN_API)
+#if defined(XP_WIN) && !PLATFORM(GTK)
+ // Unsubclass the window
+ if (m_isWindowed) {
+ WNDPROC currentWndProc = (WNDPROC)GetWindowLongPtr(platformPluginWidget(), GWLP_WNDPROC);
+
+ if (currentWndProc == PluginViewWndProc)
+ SetWindowLongPtr(platformPluginWidget(), GWLP_WNDPROC, (LONG_PTR)m_pluginWndProc);
+ }
+#endif // !defined(XP_WIN) || PLATFORM(GTK)
+#endif // ENABLE(NETSCAPE_PLUGIN_API)
+
+#if !defined(XP_MACOSX)
+ // Clear the window
+ m_npWindow.window = 0;
+
+ if (m_plugin->pluginFuncs()->setwindow && !m_plugin->quirks().contains(PluginQuirkDontSetNullWindowHandleOnDestroy)) {
+ PluginView::setCurrentPluginView(this);
+ setCallingPlugin(true);
+ m_plugin->pluginFuncs()->setwindow(m_instance, &m_npWindow);
+ setCallingPlugin(false);
+ PluginView::setCurrentPluginView(0);
+ }
+
+#ifdef XP_UNIX
+ delete static_cast<NPSetWindowCallbackStruct*>(m_npWindow.ws_info);
+ m_npWindow.ws_info = 0;
+#endif
+
+#endif // !defined(XP_MACOSX)
+
+ PluginMainThreadScheduler::scheduler().unregisterPlugin(m_instance);
+
+ NPSavedData* savedData = 0;
+ PluginView::setCurrentPluginView(this);
+ setCallingPlugin(true);
+ NPError npErr = m_plugin->pluginFuncs()->destroy(m_instance, &savedData);
+ setCallingPlugin(false);
+ LOG_NPERROR(npErr);
+ PluginView::setCurrentPluginView(0);
+
+#if ENABLE(NETSCAPE_PLUGIN_API)
+ if (savedData) {
+ // TODO: Actually save this data instead of just discarding it
+ if (savedData->buf)
+ NPN_MemFree(savedData->buf);
+ NPN_MemFree(savedData);
+ }
+#endif
+
+ m_instance->pdata = 0;
+}
+
+void PluginView::setCurrentPluginView(PluginView* pluginView)
+{
+ s_currentPluginView = pluginView;
+}
+
+PluginView* PluginView::currentPluginView()
+{
+ return s_currentPluginView;
+}
+
+static char* createUTF8String(const String& str)
+{
+ CString cstr = str.utf8();
+ const size_t cstrLength = cstr.length();
+ char* result = reinterpret_cast<char*>(fastMalloc(cstrLength + 1));
+
+ memcpy(result, cstr.data(), cstrLength);
+ result[cstrLength] = '\0';
+
+ return result;
+}
+
+void PluginView::performRequest(PluginRequest* request)
+{
+ if (!m_isStarted)
+ return;
+
+ // don't let a plugin start any loads if it is no longer part of a document that is being
+ // displayed unless the loads are in the same frame as the plugin.
+ const String& targetFrameName = request->frameLoadRequest().frameName();
+ if (m_parentFrame->loader().documentLoader() != m_parentFrame->loader().activeDocumentLoader() && (targetFrameName.isNull() || m_parentFrame->tree().find(targetFrameName) != m_parentFrame))
+ return;
+
+ URL requestURL = request->frameLoadRequest().resourceRequest().url();
+ String jsString = scriptStringIfJavaScriptURL(requestURL);
+
+ UserGestureIndicator gestureIndicator(request->shouldAllowPopups() ? DefinitelyProcessingUserGesture : PossiblyProcessingUserGesture);
+
+ if (jsString.isNull()) {
+ // if this is not a targeted request, create a stream for it. otherwise,
+ // just pass it off to the loader
+ if (targetFrameName.isEmpty()) {
+ RefPtr<PluginStream> stream = PluginStream::create(this, m_parentFrame.get(), request->frameLoadRequest().resourceRequest(), request->sendNotification(), request->notifyData(), plugin()->pluginFuncs(), instance(), m_plugin->quirks());
+ m_streams.add(stream);
+ stream->start();
+ } else {
+ // If the target frame is our frame, we could destroy the
+ // PluginView, so we protect it. <rdar://problem/6991251>
+ RefPtr<PluginView> protect(this);
+
+ FrameLoadRequest frameRequest(m_parentFrame.get(), request->frameLoadRequest().resourceRequest());
+ frameRequest.setFrameName(targetFrameName);
+ frameRequest.setShouldCheckNewWindowPolicy(true);
+ m_parentFrame->loader().load(frameRequest);
+
+ // FIXME: <rdar://problem/4807469> This should be sent when the document has finished loading
+ if (request->sendNotification()) {
+ PluginView::setCurrentPluginView(this);
+ JSC::JSLock::DropAllLocks dropAllLocks(JSDOMWindowBase::commonVM());
+ setCallingPlugin(true);
+ m_plugin->pluginFuncs()->urlnotify(m_instance, requestURL.string().utf8().data(), NPRES_DONE, request->notifyData());
+ setCallingPlugin(false);
+ PluginView::setCurrentPluginView(0);
+ }
+ }
+ return;
+ }
+
+ // Targeted JavaScript requests are only allowed on the frame that contains the JavaScript plugin
+ // and this has been made sure in ::load.
+ ASSERT(targetFrameName.isEmpty() || m_parentFrame->tree().find(targetFrameName) == m_parentFrame);
+
+ // Executing a script can cause the plugin view to be destroyed, so we keep a reference to it.
+ RefPtr<PluginView> protector(this);
+ Deprecated::ScriptValue result = m_parentFrame->script().executeScript(jsString, request->shouldAllowPopups());
+
+ if (targetFrameName.isNull()) {
+ String resultString;
+
+ JSC::ExecState* scriptState = m_parentFrame->script().globalObject(pluginWorld())->globalExec();
+ CString cstr;
+ if (result.getString(scriptState, resultString))
+ cstr = resultString.utf8();
+
+ RefPtr<PluginStream> stream = PluginStream::create(this, m_parentFrame.get(), request->frameLoadRequest().resourceRequest(), request->sendNotification(), request->notifyData(), plugin()->pluginFuncs(), instance(), m_plugin->quirks());
+ m_streams.add(stream);
+ stream->sendJavaScriptStream(requestURL, cstr);
+ }
+}
+
+void PluginView::requestTimerFired()
+{
+ ASSERT(!m_requests.isEmpty());
+ ASSERT(!m_isJavaScriptPaused);
+
+ std::unique_ptr<PluginRequest> request = WTF::move(m_requests[0]);
+ m_requests.remove(0);
+
+ // Schedule a new request before calling performRequest since the call to
+ // performRequest can cause the plugin view to be deleted.
+ if (!m_requests.isEmpty())
+ m_requestTimer.startOneShot(0);
+
+ performRequest(request.get());
+}
+
+void PluginView::scheduleRequest(std::unique_ptr<PluginRequest> request)
+{
+ m_requests.append(WTF::move(request));
+
+ if (!m_isJavaScriptPaused)
+ m_requestTimer.startOneShot(0);
+}
+
+NPError PluginView::load(const FrameLoadRequest& frameLoadRequest, bool sendNotification, void* notifyData)
+{
+ ASSERT(frameLoadRequest.resourceRequest().httpMethod() == "GET" || frameLoadRequest.resourceRequest().httpMethod() == "POST");
+
+ URL url = frameLoadRequest.resourceRequest().url();
+
+ if (url.isEmpty())
+ return NPERR_INVALID_URL;
+
+ // Don't allow requests to be made when the document loader is stopping all loaders.
+ DocumentLoader* loader = m_parentFrame->loader().documentLoader();
+ if (!loader || loader->isStopping())
+ return NPERR_GENERIC_ERROR;
+
+ const String& targetFrameName = frameLoadRequest.frameName();
+ String jsString = scriptStringIfJavaScriptURL(url);
+
+ if (!jsString.isNull()) {
+ // Return NPERR_GENERIC_ERROR if JS is disabled. This is what Mozilla does.
+ if (!m_parentFrame->script().canExecuteScripts(NotAboutToExecuteScript))
+ return NPERR_GENERIC_ERROR;
+
+ // For security reasons, only allow JS requests to be made on the frame that contains the plug-in.
+ if (!targetFrameName.isNull() && m_parentFrame->tree().find(targetFrameName) != m_parentFrame)
+ return NPERR_INVALID_PARAM;
+ } else if (!m_parentFrame->document()->securityOrigin()->canDisplay(url))
+ return NPERR_GENERIC_ERROR;
+
+ scheduleRequest(std::make_unique<PluginRequest>(frameLoadRequest, sendNotification, notifyData, arePopupsAllowed()));
+
+ return NPERR_NO_ERROR;
+}
+
+static URL makeURL(const URL& baseURL, const char* relativeURLString)
+{
+ String urlString = relativeURLString;
+
+ // Strip return characters.
+ urlString.replaceWithLiteral('\n', "");
+ urlString.replaceWithLiteral('\r', "");
+
+ return URL(baseURL, urlString);
+}
+
+NPError PluginView::getURLNotify(const char* url, const char* target, void* notifyData)
+{
+ FrameLoadRequest frameLoadRequest(m_parentFrame->document()->securityOrigin());
+
+ frameLoadRequest.setFrameName(target);
+ frameLoadRequest.resourceRequest().setHTTPMethod("GET");
+ frameLoadRequest.resourceRequest().setURL(makeURL(m_parentFrame->document()->baseURL(), url));
+
+ return load(frameLoadRequest, true, notifyData);
+}
+
+NPError PluginView::getURL(const char* url, const char* target)
+{
+ FrameLoadRequest frameLoadRequest(m_parentFrame->document()->securityOrigin());
+
+ frameLoadRequest.setFrameName(target);
+ frameLoadRequest.resourceRequest().setHTTPMethod("GET");
+ frameLoadRequest.resourceRequest().setURL(makeURL(m_parentFrame->document()->baseURL(), url));
+
+ return load(frameLoadRequest, false, 0);
+}
+
+NPError PluginView::postURLNotify(const char* url, const char* target, uint32_t len, const char* buf, NPBool file, void* notifyData)
+{
+ return handlePost(url, target, len, buf, file, notifyData, true, true);
+}
+
+NPError PluginView::postURL(const char* url, const char* target, uint32_t len, const char* buf, NPBool file)
+{
+ // As documented, only allow headers to be specified via NPP_PostURL when using a file.
+ return handlePost(url, target, len, buf, file, 0, false, file);
+}
+
+NPError PluginView::newStream(NPMIMEType, const char* /* target */, NPStream**)
+{
+ notImplemented();
+ // Unsupported
+ return NPERR_GENERIC_ERROR;
+}
+
+int32_t PluginView::write(NPStream*, int32_t /* len */, void* /* buffer */)
+{
+ notImplemented();
+ // Unsupported
+ return -1;
+}
+
+NPError PluginView::destroyStream(NPStream* stream, NPReason reason)
+{
+ if (!stream || PluginStream::ownerForStream(stream) != m_instance)
+ return NPERR_INVALID_INSTANCE_ERROR;
+
+ PluginStream* browserStream = static_cast<PluginStream*>(stream->ndata);
+ browserStream->cancelAndDestroyStream(reason);
+
+ return NPERR_NO_ERROR;
+}
+
+void PluginView::status(const char* message)
+{
+ if (Page* page = m_parentFrame->page())
+ page->chrome().setStatusbarText(m_parentFrame.get(), String::fromUTF8(message));
+}
+
+NPError PluginView::setValue(NPPVariable variable, void* value)
+{
+ LOG(Plugins, "PluginView::setValue(%s): ", prettyNameForNPPVariable(variable, value).data());
+
+ switch (variable) {
+ case NPPVpluginWindowBool:
+ m_isWindowed = value;
+ return NPERR_NO_ERROR;
+ case NPPVpluginTransparentBool:
+ m_isTransparent = value;
+ return NPERR_NO_ERROR;
+#if defined(XP_MACOSX)
+ case NPPVpluginDrawingModel: {
+ // Can only set drawing model inside NPP_New()
+ if (this != currentPluginView())
+ return NPERR_GENERIC_ERROR;
+
+ NPDrawingModel newDrawingModel = NPDrawingModel(uintptr_t(value));
+ switch (newDrawingModel) {
+ case NPDrawingModelCoreGraphics:
+ return NPERR_NO_ERROR;
+ case NPDrawingModelCoreAnimation:
+ default:
+ LOG(Plugins, "Plugin asked for unsupported drawing model: %s",
+ prettyNameForDrawingModel(newDrawingModel));
+ return NPERR_GENERIC_ERROR;
+ }
+ }
+
+ case NPPVpluginEventModel: {
+ // Can only set event model inside NPP_New()
+ if (this != currentPluginView())
+ return NPERR_GENERIC_ERROR;
+
+ NPEventModel newEventModel = NPEventModel(uintptr_t(value));
+ switch (newEventModel) {
+ case NPEventModelCocoa:
+ return NPERR_NO_ERROR;
+ default:
+ LOG(Plugins, "Plugin asked for unsupported event model: %s",
+ prettyNameForEventModel(newEventModel));
+ return NPERR_GENERIC_ERROR;
+ }
+ }
+#endif // defined(XP_MACOSX)
+
+ default:
+ notImplemented();
+ return NPERR_GENERIC_ERROR;
+ }
+}
+
+void PluginView::invalidateTimerFired()
+{
+ for (unsigned i = 0; i < m_invalidRects.size(); i++)
+ invalidateRect(m_invalidRects[i]);
+ m_invalidRects.clear();
+}
+
+
+void PluginView::pushPopupsEnabledState(bool state)
+{
+ m_popupStateStack.append(state);
+}
+
+void PluginView::popPopupsEnabledState()
+{
+ m_popupStateStack.removeLast();
+}
+
+bool PluginView::arePopupsAllowed() const
+{
+ if (!m_popupStateStack.isEmpty())
+ return m_popupStateStack.last();
+
+ return false;
+}
+
+void PluginView::setJavaScriptPaused(bool paused)
+{
+ if (m_isJavaScriptPaused == paused)
+ return;
+ m_isJavaScriptPaused = paused;
+
+ if (m_isJavaScriptPaused)
+ m_requestTimer.stop();
+ else if (!m_requests.isEmpty())
+ m_requestTimer.startOneShot(0);
+}
+
+#if ENABLE(NETSCAPE_PLUGIN_API)
+NPObject* PluginView::npObject()
+{
+ NPObject* object = 0;
+
+ if (!m_isStarted || !m_plugin || !m_plugin->pluginFuncs()->getvalue)
+ return 0;
+
+ // On Windows, calling Java's NPN_GetValue can allow the message loop to
+ // run, allowing loading to take place or JavaScript to run. Protect the
+ // PluginView from destruction. <rdar://problem/6978804>
+ RefPtr<PluginView> protect(this);
+
+ NPError npErr;
+ {
+ PluginView::setCurrentPluginView(this);
+ JSC::JSLock::DropAllLocks dropAllLocks(JSDOMWindowBase::commonVM());
+ setCallingPlugin(true);
+ npErr = m_plugin->pluginFuncs()->getvalue(m_instance, NPPVpluginScriptableNPObject, &object);
+ setCallingPlugin(false);
+ PluginView::setCurrentPluginView(0);
+ }
+
+ if (npErr != NPERR_NO_ERROR)
+ return 0;
+
+ return object;
+}
+#endif
+
+PassRefPtr<JSC::Bindings::Instance> PluginView::bindingInstance()
+{
+#if ENABLE(NETSCAPE_PLUGIN_API)
+ NPObject* object = npObject();
+ if (!object)
+ return 0;
+
+ if (hasOneRef()) {
+ // The renderer for the PluginView was destroyed during the above call, and
+ // the PluginView will be destroyed when this function returns, so we
+ // return null.
+ return 0;
+ }
+
+ RefPtr<JSC::Bindings::RootObject> root = m_parentFrame->script().createRootObject(this);
+ RefPtr<JSC::Bindings::Instance> instance = JSC::Bindings::CInstance::create(object, root.release());
+
+ _NPN_ReleaseObject(object);
+
+ return instance.release();
+#else
+ return 0;
+#endif
+}
+
+void PluginView::disconnectStream(PluginStream* stream)
+{
+ ASSERT(m_streams.contains(stream));
+
+ m_streams.remove(stream);
+}
+
+void PluginView::setParameters(const Vector<String>& paramNames, const Vector<String>& paramValues)
+{
+ ASSERT(paramNames.size() == paramValues.size());
+
+ unsigned size = paramNames.size();
+ unsigned paramCount = 0;
+
+ m_paramNames = reinterpret_cast<char**>(fastMalloc(sizeof(char*) * size));
+ m_paramValues = reinterpret_cast<char**>(fastMalloc(sizeof(char*) * size));
+
+ for (unsigned i = 0; i < size; i++) {
+ if (m_plugin->quirks().contains(PluginQuirkRemoveWindowlessVideoParam) && equalIgnoringCase(paramNames[i], "windowlessvideo"))
+ continue;
+
+ if (paramNames[i] == "pluginspage")
+ m_pluginsPage = paramValues[i];
+
+ m_paramNames[paramCount] = createUTF8String(paramNames[i]);
+ m_paramValues[paramCount] = createUTF8String(paramValues[i]);
+
+ paramCount++;
+ }
+
+ m_paramCount = paramCount;
+}
+
+PluginView::PluginView(Frame* parentFrame, const IntSize& size, PluginPackage* plugin, HTMLPlugInElement* element, const URL& url, const Vector<String>& paramNames, const Vector<String>& paramValues, const String& mimeType, bool loadManually)
+ : m_parentFrame(parentFrame)
+ , m_plugin(plugin)
+ , m_element(element)
+ , m_isStarted(false)
+ , m_url(url)
+ , m_status(PluginStatusLoadedSuccessfully)
+ , m_requestTimer(*this, &PluginView::requestTimerFired)
+ , m_invalidateTimer(*this, &PluginView::invalidateTimerFired)
+ , m_popPopupsStateTimer(*this, &PluginView::popPopupsStateTimerFired)
+ , m_lifeSupportTimer(*this, &PluginView::lifeSupportTimerFired)
+ , m_mode(loadManually ? NP_FULL : NP_EMBED)
+ , m_paramNames(0)
+ , m_paramValues(0)
+ , m_mimeType(mimeType)
+ , m_instance(0)
+#if defined(XP_MACOSX)
+ , m_isWindowed(false)
+ , m_updatedCocoaTextInputRequested(false)
+ , m_keyDownSent(false)
+ , m_disregardKeyUpCounter(0)
+#else
+ , m_isWindowed(true)
+#endif
+ , m_isTransparent(false)
+ , m_haveInitialized(false)
+ , m_isWaitingToStart(false)
+#if defined(XP_UNIX)
+ , m_needsXEmbed(false)
+#endif
+#if OS(WINDOWS) && ENABLE(NETSCAPE_PLUGIN_API)
+ , m_pluginWndProc(0)
+ , m_lastMessage(0)
+ , m_isCallingPluginWndProc(false)
+ , m_wmPrintHDC(0)
+ , m_haveUpdatedPluginWidget(false)
+#endif
+#if PLATFORM(EFL)
+ , m_window(0)
+#endif
+#if defined(XP_MACOSX)
+ , m_contextRef(0)
+#endif
+#if defined(XP_UNIX) && ENABLE(NETSCAPE_PLUGIN_API)
+ , m_hasPendingGeometryChange(true)
+ , m_drawable(0)
+ , m_visual(0)
+ , m_colormap(0)
+ , m_pluginDisplay(0)
+#endif
+ , m_loadManually(loadManually)
+ , m_manualStream(0)
+ , m_isJavaScriptPaused(false)
+ , m_haveCalledSetWindow(false)
+{
+ if (!m_plugin) {
+ m_status = PluginStatusCanNotFindPlugin;
+ return;
+ }
+
+ m_instance = &m_instanceStruct;
+ m_instance->ndata = this;
+ m_instance->pdata = 0;
+
+ instanceMap().add(m_instance, this);
+
+ setParameters(paramNames, paramValues);
+
+ memset(&m_npWindow, 0, sizeof(m_npWindow));
+#if defined(XP_MACOSX)
+ memset(&m_npCgContext, 0, sizeof(m_npCgContext));
+#endif
+
+ resize(size);
+}
+
+void PluginView::focusPluginElement()
+{
+ if (Page* page = m_parentFrame->page())
+ page->focusController().setFocusedElement(m_element, m_parentFrame);
+ else
+ m_parentFrame->document()->setFocusedElement(m_element);
+}
+
+void PluginView::didReceiveResponse(const ResourceResponse& response)
+{
+ if (m_status != PluginStatusLoadedSuccessfully)
+ return;
+
+ ASSERT(m_loadManually);
+ ASSERT(!m_manualStream);
+
+ m_manualStream = PluginStream::create(this, m_parentFrame.get(), m_parentFrame->loader().activeDocumentLoader()->request(), false, 0, plugin()->pluginFuncs(), instance(), m_plugin->quirks());
+ m_manualStream->setLoadManually(true);
+
+ m_manualStream->didReceiveResponse(0, response);
+}
+
+void PluginView::didReceiveData(const char* data, int length)
+{
+ if (m_status != PluginStatusLoadedSuccessfully)
+ return;
+
+ ASSERT(m_loadManually);
+ ASSERT(m_manualStream);
+
+ m_manualStream->didReceiveData(0, data, length);
+}
+
+void PluginView::didFinishLoading()
+{
+ if (m_status != PluginStatusLoadedSuccessfully)
+ return;
+
+ ASSERT(m_loadManually);
+ ASSERT(m_manualStream);
+
+ m_manualStream->didFinishLoading(0);
+}
+
+void PluginView::didFail(const ResourceError& error)
+{
+ if (m_status != PluginStatusLoadedSuccessfully)
+ return;
+
+ ASSERT(m_loadManually);
+
+ if (m_manualStream)
+ m_manualStream->didFail(0, error);
+}
+
+void PluginView::setCallingPlugin(bool b) const
+{
+ if (!m_plugin->quirks().contains(PluginQuirkHasModalMessageLoop))
+ return;
+
+ if (b)
+ ++s_callingPlugin;
+ else
+ --s_callingPlugin;
+
+ ASSERT(s_callingPlugin >= 0);
+}
+
+bool PluginView::isCallingPlugin()
+{
+ return s_callingPlugin > 0;
+}
+
+PassRefPtr<PluginView> PluginView::create(Frame* parentFrame, const IntSize& size, HTMLPlugInElement* element, const URL& url, const Vector<String>& paramNames, const Vector<String>& paramValues, const String& mimeType, bool loadManually)
+{
+ // if we fail to find a plugin for this MIME type, findPlugin will search for
+ // a plugin by the file extension and update the MIME type, so pass a mutable String
+ String mimeTypeCopy = mimeType;
+ PluginPackage* plugin = PluginDatabase::installedPlugins()->findPlugin(url, mimeTypeCopy);
+
+ // No plugin was found, try refreshing the database and searching again
+ if (!plugin && PluginDatabase::installedPlugins()->refresh()) {
+ mimeTypeCopy = mimeType;
+ plugin = PluginDatabase::installedPlugins()->findPlugin(url, mimeTypeCopy);
+ }
+
+ return adoptRef(new PluginView(parentFrame, size, plugin, element, url, paramNames, paramValues, mimeTypeCopy, loadManually));
+}
+
+void PluginView::freeStringArray(char** stringArray, int length)
+{
+ if (!stringArray)
+ return;
+
+ for (int i = 0; i < length; i++)
+ fastFree(stringArray[i]);
+
+ fastFree(stringArray);
+}
+
+static inline bool startsWithBlankLine(const Vector<char>& buffer)
+{
+ return buffer.size() > 0 && buffer[0] == '\n';
+}
+
+static inline int locationAfterFirstBlankLine(const Vector<char>& buffer)
+{
+ const char* bytes = buffer.data();
+ unsigned length = buffer.size();
+
+ for (unsigned i = 0; i < length - 4; i++) {
+ // Support for Acrobat. It sends "\n\n".
+ if (bytes[i] == '\n' && bytes[i + 1] == '\n')
+ return i + 2;
+
+ // Returns the position after 2 CRLF's or 1 CRLF if it is the first line.
+ if (bytes[i] == '\r' && bytes[i + 1] == '\n') {
+ i += 2;
+ if (i == 2)
+ return i;
+ else if (bytes[i] == '\n')
+ // Support for Director. It sends "\r\n\n" (3880387).
+ return i + 1;
+ else if (bytes[i] == '\r' && bytes[i + 1] == '\n')
+ // Support for Flash. It sends "\r\n\r\n" (3758113).
+ return i + 2;
+ }
+ }
+
+ return -1;
+}
+
+static inline const char* findEOL(const char* bytes, unsigned length)
+{
+ // According to the HTTP specification EOL is defined as
+ // a CRLF pair. Unfortunately, some servers will use LF
+ // instead. Worse yet, some servers will use a combination
+ // of both (e.g. <header>CRLFLF<body>), so findEOL needs
+ // to be more forgiving. It will now accept CRLF, LF or
+ // CR.
+ //
+ // It returns NULL if EOLF is not found or it will return
+ // a pointer to the first terminating character.
+ for (unsigned i = 0; i < length; i++) {
+ if (bytes[i] == '\n')
+ return bytes + i;
+ if (bytes[i] == '\r') {
+ // Check to see if spanning buffer bounds
+ // (CRLF is across reads). If so, wait for
+ // next read.
+ if (i + 1 == length)
+ break;
+
+ return bytes + i;
+ }
+ }
+
+ return 0;
+}
+
+static inline String capitalizeRFC822HeaderFieldName(const String& name)
+{
+ bool capitalizeCharacter = true;
+ String result;
+
+ for (unsigned i = 0; i < name.length(); i++) {
+ UChar c;
+
+ if (capitalizeCharacter && name[i] >= 'a' && name[i] <= 'z')
+ c = toASCIIUpper(name[i]);
+ else if (!capitalizeCharacter && name[i] >= 'A' && name[i] <= 'Z')
+ c = toASCIILower(name[i]);
+ else
+ c = name[i];
+
+ if (name[i] == '-')
+ capitalizeCharacter = true;
+ else
+ capitalizeCharacter = false;
+
+ result.append(c);
+ }
+
+ return result;
+}
+
+static inline HTTPHeaderMap parseRFC822HeaderFields(const Vector<char>& buffer, unsigned length)
+{
+ const char* bytes = buffer.data();
+ const char* eol;
+ String lastKey;
+ HTTPHeaderMap headerFields;
+
+ // Loop ove rlines until we're past the header, or we can't find any more end-of-lines
+ while ((eol = findEOL(bytes, length))) {
+ const char* line = bytes;
+ int lineLength = eol - bytes;
+
+ // Move bytes to the character after the terminator as returned by findEOL.
+ bytes = eol + 1;
+ if ((*eol == '\r') && (*bytes == '\n'))
+ bytes++; // Safe since findEOL won't return a spanning CRLF.
+
+ length -= (bytes - line);
+ if (lineLength == 0)
+ // Blank line; we're at the end of the header
+ break;
+ else if (*line == ' ' || *line == '\t') {
+ // Continuation of the previous header
+ if (lastKey.isNull()) {
+ // malformed header; ignore it and continue
+ continue;
+ } else {
+ // Merge the continuation of the previous header
+ String currentValue = headerFields.get(lastKey);
+ String newValue(line, lineLength);
+
+ headerFields.set(lastKey, currentValue + newValue);
+ }
+ } else {
+ // Brand new header
+ const char* colon;
+ for (colon = line; *colon != ':' && colon != eol; colon++) {
+ // empty loop
+ }
+ if (colon == eol)
+ // malformed header; ignore it and continue
+ continue;
+ else {
+ lastKey = capitalizeRFC822HeaderFieldName(String(line, colon - line));
+ String value;
+
+ for (colon++; colon != eol; colon++) {
+ if (*colon != ' ' && *colon != '\t')
+ break;
+ }
+ if (colon == eol)
+ value = "";
+ else
+ value = String(colon, eol - colon);
+
+ String oldValue = headerFields.get(lastKey);
+ if (!oldValue.isNull())
+ value = oldValue + ", " + value;
+
+ headerFields.set(lastKey, value);
+ }
+ }
+ }
+
+ return headerFields;
+}
+
+NPError PluginView::handlePost(const char* url, const char* target, uint32_t len, const char* buf, bool file, void* notifyData, bool sendNotification, bool allowHeaders)
+{
+ if (!url || !len || !buf)
+ return NPERR_INVALID_PARAM;
+
+ FrameLoadRequest frameLoadRequest(m_parentFrame->document()->securityOrigin());
+
+ HTTPHeaderMap headerFields;
+ Vector<char> buffer;
+
+ if (file) {
+ NPError readResult = handlePostReadFile(buffer, len, buf);
+ if(readResult != NPERR_NO_ERROR)
+ return readResult;
+ } else {
+ buffer.resize(len);
+ memcpy(buffer.data(), buf, len);
+ }
+
+ const char* postData = buffer.data();
+ int postDataLength = buffer.size();
+
+ if (allowHeaders) {
+ if (startsWithBlankLine(buffer)) {
+ postData++;
+ postDataLength--;
+ } else {
+ int location = locationAfterFirstBlankLine(buffer);
+ if (location != -1) {
+ // If the blank line is somewhere in the middle of the buffer, everything before is the header
+ headerFields = parseRFC822HeaderFields(buffer, location);
+ unsigned dataLength = buffer.size() - location;
+
+ // Sometimes plugins like to set Content-Length themselves when they post,
+ // but WebFoundation does not like that. So we will remove the header
+ // and instead truncate the data to the requested length.
+ String contentLength = headerFields.get(HTTPHeaderName::ContentLength);
+
+ if (!contentLength.isNull())
+ dataLength = min(contentLength.toInt(), (int)dataLength);
+ headerFields.remove(HTTPHeaderName::ContentLength);
+
+ postData += location;
+ postDataLength = dataLength;
+ }
+ }
+ }
+
+ frameLoadRequest.resourceRequest().setHTTPMethod("POST");
+ frameLoadRequest.resourceRequest().setURL(makeURL(m_parentFrame->document()->baseURL(), url));
+ frameLoadRequest.resourceRequest().setHTTPHeaderFields(WTF::move(headerFields));
+ frameLoadRequest.resourceRequest().setHTTPBody(FormData::create(postData, postDataLength));
+ frameLoadRequest.setFrameName(target);
+
+ return load(frameLoadRequest, sendNotification, notifyData);
+}
+
+void PluginView::invalidateWindowlessPluginRect(const IntRect& rect)
+{
+ if (!isVisible())
+ return;
+
+ if (!m_element->renderer())
+ return;
+ auto& renderer = downcast<RenderBox>(*m_element->renderer());
+
+ IntRect dirtyRect = rect;
+ dirtyRect.move(renderer.borderLeft() + renderer.paddingLeft(), renderer.borderTop() + renderer.paddingTop());
+ renderer.repaintRectangle(dirtyRect);
+}
+
+void PluginView::paintMissingPluginIcon(GraphicsContext* context, const IntRect& rect)
+{
+ static RefPtr<Image> nullPluginImage;
+ if (!nullPluginImage)
+ nullPluginImage = Image::loadPlatformResource("nullPlugin");
+
+ IntRect imageRect(frameRect().x(), frameRect().y(), nullPluginImage->width(), nullPluginImage->height());
+
+ int xOffset = (frameRect().width() - imageRect.width()) / 2;
+ int yOffset = (frameRect().height() - imageRect.height()) / 2;
+
+ imageRect.move(xOffset, yOffset);
+
+ if (!rect.intersects(imageRect))
+ return;
+
+ context->save();
+ context->clip(windowClipRect());
+ context->drawImage(nullPluginImage.get(), ColorSpaceDeviceRGB, imageRect.location());
+ context->restore();
+}
+
+static const char* MozillaUserAgent = "Mozilla/5.0 ("
+#if defined(XP_MACOSX)
+ "Macintosh; U; Intel Mac OS X;"
+#elif defined(XP_WIN)
+ "Windows; U; Windows NT 5.1;"
+#elif defined(XP_UNIX)
+// The Gtk port uses X11 plugins in Mac.
+#if OS(DARWIN) && PLATFORM(GTK)
+ "X11; U; Intel Mac OS X;"
+#else
+ "X11; U; Linux i686;"
+#endif
+#endif
+ " en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0";
+
+static const char* const ChromeUserAgent = "Mozilla/5.0 ("
+#if defined(XP_MACOSX)
+ "Macintosh; U; Intel Mac OS X;"
+#elif defined(XP_WIN)
+ "Windows; U; Windows NT 5.1;"
+#elif defined(XP_UNIX)
+ // The Gtk port uses X11 plugins in Mac.
+#if OS(DARWIN) && PLATFORM(GTK)
+ "X11; U; Intel Mac OS X;"
+#else
+ "X11; U; Linux i686;"
+#endif
+#endif
+ " AppleWebKit/534.34 (KHTML, like Gecko) Chrome/19.0.1055.1 Safari/534.34";
+
+const char* PluginView::userAgent()
+{
+ if (m_plugin->quirks().contains(PluginQuirkWantsMozillaUserAgent))
+ return MozillaUserAgent;
+ else if (m_plugin->quirks().contains(PluginQuirkWantsChromeUserAgent))
+ return ChromeUserAgent;
+ if (m_userAgent.isNull())
+ m_userAgent = m_parentFrame->loader().userAgent(m_url).utf8();
+
+ return m_userAgent.data();
+}
+
+#if ENABLE(NETSCAPE_PLUGIN_API)
+const char* PluginView::userAgentStatic()
+{
+ return MozillaUserAgent;
+}
+#endif
+
+
+void PluginView::lifeSupportTimerFired()
+{
+ deref();
+}
+
+void PluginView::keepAlive()
+{
+ if (m_lifeSupportTimer.isActive())
+ return;
+
+ ref();
+ m_lifeSupportTimer.startOneShot(0);
+}
+
+#if ENABLE(NETSCAPE_PLUGIN_API)
+void PluginView::keepAlive(NPP instance)
+{
+ PluginView* view = instanceMap().get(instance);
+ if (!view)
+ return;
+
+ view->keepAlive();
+}
+
+NPError PluginView::getValueStatic(NPNVariable variable, void* value)
+{
+ LOG(Plugins, "PluginView::getValueStatic(%s)", prettyNameForNPNVariable(variable).data());
+
+ NPError result;
+ if (platformGetValueStatic(variable, value, &result))
+ return result;
+
+ return NPERR_GENERIC_ERROR;
+}
+
+NPError PluginView::getValue(NPNVariable variable, void* value)
+{
+ LOG(Plugins, "PluginView::getValue(%s)", prettyNameForNPNVariable(variable).data());
+
+ NPError result;
+ if (platformGetValue(variable, value, &result))
+ return result;
+
+ if (platformGetValueStatic(variable, value, &result))
+ return result;
+
+ switch (variable) {
+ case NPNVWindowNPObject: {
+ if (m_isJavaScriptPaused)
+ return NPERR_GENERIC_ERROR;
+
+ NPObject* windowScriptObject = m_parentFrame->script().windowScriptNPObject();
+
+ // Return value is expected to be retained, as described here: <http://www.mozilla.org/projects/plugin/npruntime.html>
+ if (windowScriptObject)
+ _NPN_RetainObject(windowScriptObject);
+
+ void** v = (void**)value;
+ *v = windowScriptObject;
+
+ return NPERR_NO_ERROR;
+ }
+
+ case NPNVPluginElementNPObject: {
+ if (m_isJavaScriptPaused)
+ return NPERR_GENERIC_ERROR;
+
+ NPObject* pluginScriptObject = 0;
+
+ if (m_element->hasTagName(appletTag) || m_element->hasTagName(embedTag) || m_element->hasTagName(objectTag))
+ pluginScriptObject = m_element->getNPObject();
+
+ // Return value is expected to be retained, as described here: <http://www.mozilla.org/projects/plugin/npruntime.html>
+ if (pluginScriptObject)
+ _NPN_RetainObject(pluginScriptObject);
+
+ void** v = (void**)value;
+ *v = pluginScriptObject;
+
+ return NPERR_NO_ERROR;
+ }
+
+ case NPNVprivateModeBool: {
+ Page* page = m_parentFrame->page();
+ if (!page)
+ return NPERR_GENERIC_ERROR;
+ *((NPBool*)value) = page->usesEphemeralSession();
+ return NPERR_NO_ERROR;
+ }
+
+ default:
+ return NPERR_GENERIC_ERROR;
+ }
+}
+
+static Frame* getFrame(Frame* parentFrame, Element* element)
+{
+ if (parentFrame)
+ return parentFrame;
+
+ return element->document().frame();
+}
+
+NPError PluginView::getValueForURL(NPNURLVariable variable, const char* url, char** value, uint32_t* len)
+{
+ LOG(Plugins, "PluginView::getValueForURL(%s)", prettyNameForNPNURLVariable(variable).data());
+
+ NPError result = NPERR_NO_ERROR;
+
+ switch (variable) {
+ case NPNURLVCookie: {
+ URL u(m_parentFrame->document()->baseURL(), url);
+ if (u.isValid()) {
+ Frame* frame = getFrame(parentFrame(), m_element);
+ if (frame) {
+ const CString cookieStr = cookies(frame->document(), u).utf8();
+ if (!cookieStr.isNull()) {
+ const int size = cookieStr.length();
+ *value = static_cast<char*>(NPN_MemAlloc(size+1));
+ if (*value) {
+ memset(*value, 0, size+1);
+ memcpy(*value, cookieStr.data(), size+1);
+ if (len)
+ *len = size;
+ } else
+ result = NPERR_OUT_OF_MEMORY_ERROR;
+ }
+ }
+ } else
+ result = NPERR_INVALID_URL;
+ break;
+ }
+ case NPNURLVProxy: {
+ URL u(m_parentFrame->document()->baseURL(), url);
+ if (u.isValid()) {
+ Frame* frame = getFrame(parentFrame(), m_element);
+ const FrameLoader* frameLoader = frame ? &frame->loader() : 0;
+ const NetworkingContext* context = frameLoader ? frameLoader->networkingContext() : 0;
+ const CString proxyStr = toString(proxyServersForURL(u, context)).utf8();
+ if (!proxyStr.isNull()) {
+ const int size = proxyStr.length();
+ *value = static_cast<char*>(NPN_MemAlloc(size+1));
+ if (*value) {
+ memset(*value, 0, size+1);
+ memcpy(*value, proxyStr.data(), size+1);
+ if (len)
+ *len = size;
+ } else
+ result = NPERR_OUT_OF_MEMORY_ERROR;
+ }
+ } else
+ result = NPERR_INVALID_URL;
+ break;
+ }
+ default:
+ result = NPERR_GENERIC_ERROR;
+ LOG(Plugins, "PluginView::getValueForURL: %s", prettyNameForNPNURLVariable(variable).data());
+ break;
+ }
+
+ return result;
+}
+
+
+NPError PluginView::setValueForURL(NPNURLVariable variable, const char* url, const char* value, uint32_t len)
+{
+ LOG(Plugins, "PluginView::setValueForURL(%s)", prettyNameForNPNURLVariable(variable).data());
+
+ NPError result = NPERR_NO_ERROR;
+
+ switch (variable) {
+ case NPNURLVCookie: {
+ URL u(m_parentFrame->document()->baseURL(), url);
+ if (u.isValid()) {
+ const String cookieStr = String::fromUTF8(value, len);
+ Frame* frame = getFrame(parentFrame(), m_element);
+ if (frame && !cookieStr.isEmpty())
+ setCookies(frame->document(), u, cookieStr);
+ } else
+ result = NPERR_INVALID_URL;
+ break;
+ }
+ case NPNURLVProxy:
+ LOG(Plugins, "PluginView::setValueForURL(%s): Plugins are NOT allowed to set proxy information.", prettyNameForNPNURLVariable(variable).data());
+ result = NPERR_GENERIC_ERROR;
+ break;
+ default:
+ LOG(Plugins, "PluginView::setValueForURL: %s", prettyNameForNPNURLVariable(variable).data());
+ result = NPERR_GENERIC_ERROR;
+ break;
+ }
+
+ return result;
+}
+
+NPError PluginView::getAuthenticationInfo(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 */)
+{
+#if LOG_DISABLED
+ UNUSED_PARAM(protocol);
+ UNUSED_PARAM(host);
+ UNUSED_PARAM(port);
+#endif
+ LOG(Plugins, "PluginView::getAuthenticationInfo: protocol=%s, host=%s, port=%d", protocol, host, port);
+ notImplemented();
+ return NPERR_GENERIC_ERROR;
+}
+#endif
+
+void PluginView::privateBrowsingStateChanged(bool privateBrowsingEnabled)
+{
+ NPP_SetValueProcPtr setValue = m_plugin->pluginFuncs()->setvalue;
+ if (!setValue)
+ return;
+
+ PluginView::setCurrentPluginView(this);
+ JSC::JSLock::DropAllLocks dropAllLocks(JSDOMWindowBase::commonVM());
+ setCallingPlugin(true);
+ NPBool value = privateBrowsingEnabled;
+ setValue(m_instance, NPNVprivateModeBool, &value);
+ setCallingPlugin(false);
+ PluginView::setCurrentPluginView(0);
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(NETSCAPE_PLUGIN_API)
</ins></span></pre></div>
<a id="trunkSourceWebKitwinPluginsPluginViewhfromrev178217trunkSourceWebCorepluginsPluginViewh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebKit/win/Plugins/PluginView.h (from rev 178217, trunk/Source/WebCore/plugins/PluginView.h) (0 => 178219)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/win/Plugins/PluginView.h         (rev 0)
+++ trunk/Source/WebKit/win/Plugins/PluginView.h        2015-01-10 00:16:52 UTC (rev 178219)
</span><span class="lines">@@ -0,0 +1,440 @@
</span><ins>+/*
+ * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2008 Collabora Ltd. All rights reserved.
+ * Copyright (C) 2009 Girish Ramakrishnan <girish@forwardbias.in>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef PluginView_h
+#define PluginView_h
+
+#include "FrameLoadRequest.h"
+#include "IntRect.h"
+#include "MediaCanStartListener.h"
+#include "PluginViewBase.h"
+#include "ResourceRequest.h"
+#include "Timer.h"
+#include <wtf/HashMap.h>
+#include <wtf/HashSet.h>
+#include <wtf/OwnPtr.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+#include <wtf/Vector.h>
+#include <wtf/text/CString.h>
+
+#if ENABLE(NETSCAPE_PLUGIN_API)
+#include "PluginStream.h"
+#include "npruntime_internal.h"
+#endif
+
+#if OS(WINDOWS) && PLATFORM(GTK)
+typedef struct HWND__* HWND;
+typedef HWND PlatformPluginWidget;
+#else
+typedef PlatformWidget PlatformPluginWidget;
+#endif
+#if PLATFORM(GTK)
+typedef struct _GtkSocket GtkSocket;
+#endif
+
+#if PLATFORM(X11)
+typedef unsigned long Window;
+typedef struct _XDisplay Display;
+#endif
+
+namespace JSC {
+ namespace Bindings {
+ class Instance;
+ }
+}
+
+namespace WebCore {
+ class Frame;
+ class FrameView;
+ class Image;
+ class HTMLPlugInElement;
+ class KeyboardEvent;
+ class MouseEvent;
+ class URL;
+#if OS(WINDOWS) && ENABLE(NETSCAPE_PLUGIN_API)
+ class PluginMessageThrottlerWin;
+#endif
+ class PluginPackage;
+ class PluginRequest;
+ class PluginStream;
+ class ResourceError;
+ class ResourceResponse;
+ class WheelEvent;
+
+ enum PluginStatus {
+ PluginStatusCanNotFindPlugin,
+ PluginStatusCanNotLoadPlugin,
+ PluginStatusLoadedSuccessfully
+ };
+
+ class PluginRequest {
+ WTF_MAKE_NONCOPYABLE(PluginRequest); WTF_MAKE_FAST_ALLOCATED;
+ public:
+ PluginRequest(const FrameLoadRequest& frameLoadRequest, bool sendNotification, void* notifyData, bool shouldAllowPopups)
+ : m_frameLoadRequest(frameLoadRequest)
+ , m_notifyData(notifyData)
+ , m_sendNotification(sendNotification)
+ , m_shouldAllowPopups(shouldAllowPopups) { }
+ public:
+ const FrameLoadRequest& frameLoadRequest() const { return m_frameLoadRequest; }
+ void* notifyData() const { return m_notifyData; }
+ bool sendNotification() const { return m_sendNotification; }
+ bool shouldAllowPopups() const { return m_shouldAllowPopups; }
+ private:
+ FrameLoadRequest m_frameLoadRequest;
+ void* m_notifyData;
+ bool m_sendNotification;
+ bool m_shouldAllowPopups;
+ };
+
+ class PluginManualLoader {
+ public:
+ virtual ~PluginManualLoader() {}
+ virtual void didReceiveResponse(const ResourceResponse&) = 0;
+ virtual void didReceiveData(const char*, int) = 0;
+ virtual void didFinishLoading() = 0;
+ virtual void didFail(const ResourceError&) = 0;
+ };
+
+ class PluginView : public PluginViewBase
+#if ENABLE(NETSCAPE_PLUGIN_API)
+ , private PluginStreamClient
+#endif
+ , public PluginManualLoader
+ , private MediaCanStartListener {
+ public:
+ static PassRefPtr<PluginView> create(Frame* parentFrame, const IntSize&, HTMLPlugInElement*, const URL&, const Vector<String>& paramNames, const Vector<String>& paramValues, const String& mimeType, bool loadManually);
+ virtual ~PluginView();
+
+ PluginPackage* plugin() const { return m_plugin.get(); }
+#if ENABLE(NETSCAPE_PLUGIN_API)
+ NPP instance() const { return m_instance; }
+#endif
+
+ void setNPWindowRect(const IntRect&);
+ static PluginView* currentPluginView();
+
+#if ENABLE(NETSCAPE_PLUGIN_API)
+ NPObject* npObject();
+#endif
+ PassRefPtr<JSC::Bindings::Instance> bindingInstance();
+
+ PluginStatus status() const { return m_status; }
+
+#if ENABLE(NETSCAPE_PLUGIN_API)
+ // NPN functions
+ NPError getURLNotify(const char* url, const char* target, void* notifyData);
+ NPError getURL(const char* url, const char* target);
+ NPError postURLNotify(const char* url, const char* target, uint32_t len, const char* but, NPBool file, void* notifyData);
+ NPError postURL(const char* url, const char* target, uint32_t len, const char* but, NPBool file);
+ NPError newStream(NPMIMEType type, const char* target, NPStream** stream);
+ int32_t write(NPStream* stream, int32_t len, void* buffer);
+ NPError destroyStream(NPStream* stream, NPReason reason);
+#endif
+ const char* userAgent();
+#if ENABLE(NETSCAPE_PLUGIN_API)
+ static const char* userAgentStatic();
+#endif
+ void status(const char* message);
+
+#if ENABLE(NETSCAPE_PLUGIN_API)
+ NPError getValue(NPNVariable variable, void* value);
+ static NPError getValueStatic(NPNVariable variable, void* value);
+ NPError setValue(NPPVariable variable, void* value);
+ NPError getValueForURL(NPNURLVariable variable, const char* url, char** value, uint32_t* len);
+ NPError setValueForURL(NPNURLVariable variable, const char* url, const char* value, uint32_t len);
+ NPError getAuthenticationInfo(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);
+ void invalidateRect(NPRect*);
+ void invalidateRegion(NPRegion);
+#endif
+ void forceRedraw();
+ void pushPopupsEnabledState(bool state);
+ void popPopupsEnabledState();
+
+ virtual void invalidateRect(const IntRect&);
+
+ bool arePopupsAllowed() const;
+
+ void setJavaScriptPaused(bool);
+
+ void privateBrowsingStateChanged(bool);
+
+ void disconnectStream(PluginStream*);
+ void streamDidFinishLoading(PluginStream* stream) { disconnectStream(stream); }
+
+ // Widget functions
+ virtual void setFrameRect(const IntRect&);
+ virtual void frameRectsChanged();
+ virtual void setFocus(bool);
+ virtual void show();
+ virtual void hide();
+ virtual void paint(GraphicsContext*, const IntRect&);
+ virtual void clipRectChanged() override;
+
+ // This method is used by plugins on all platforms to obtain a clip rect that includes clips set by WebCore,
+ // e.g., in overflow:auto sections. The clip rects coordinates are in the containing window's coordinate space.
+ // This clip includes any clips that the widget itself sets up for its children.
+ IntRect windowClipRect() const;
+
+ virtual void handleEvent(Event*);
+ virtual void setParent(ScrollView*);
+ virtual void setParentVisible(bool);
+
+ virtual bool isPluginView() const override { return true; }
+
+ Frame* parentFrame() const { return m_parentFrame.get(); }
+
+ void focusPluginElement();
+
+ const String& pluginsPage() const { return m_pluginsPage; }
+ const String& mimeType() const { return m_mimeType; }
+ const URL& url() const { return m_url; }
+
+#if defined(XP_MACOSX) && ENABLE(NETSCAPE_PLUGIN_API)
+ bool popUpContextMenu(NPMenu*);
+#endif
+
+#if OS(WINDOWS) && ENABLE(NETSCAPE_PLUGIN_API)
+ static LRESULT CALLBACK PluginViewWndProc(HWND, UINT, WPARAM, LPARAM);
+ LRESULT wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
+ WNDPROC pluginWndProc() const { return m_pluginWndProc; }
+#endif
+
+ // Used for manual loading
+ void didReceiveResponse(const ResourceResponse&);
+ void didReceiveData(const char*, int);
+ void didFinishLoading();
+ void didFail(const ResourceError&);
+
+ static bool isCallingPlugin();
+
+ bool start();
+
+#if ENABLE(NETSCAPE_PLUGIN_API)
+ static void keepAlive(NPP);
+#endif
+ void keepAlive();
+
+#if PLATFORM(X11)
+ static Display* getPluginDisplay(Frame*);
+ static Window getRootWindow(Frame* parentFrame);
+#endif
+
+ private:
+ PluginView(Frame* parentFrame, const IntSize&, PluginPackage*, HTMLPlugInElement*, const URL&, const Vector<String>& paramNames, const Vector<String>& paramValues, const String& mimeType, bool loadManually);
+
+ void setParameters(const Vector<String>& paramNames, const Vector<String>& paramValues);
+ bool startOrAddToUnstartedList();
+ void init();
+ bool platformStart();
+ void stop();
+ void platformDestroy();
+ static void setCurrentPluginView(PluginView*);
+#if ENABLE(NETSCAPE_PLUGIN_API)
+ NPError load(const FrameLoadRequest&, bool sendNotification, void* notifyData);
+ NPError handlePost(const char* url, const char* target, uint32_t len, const char* buf, bool file, void* notifyData, bool sendNotification, bool allowHeaders);
+ NPError handlePostReadFile(Vector<char>& buffer, uint32_t len, const char* buf);
+#endif
+ static void freeStringArray(char** stringArray, int length);
+ void setCallingPlugin(bool) const;
+
+ void invalidateWindowlessPluginRect(const IntRect&);
+
+ virtual void mediaCanStart();
+
+#if OS(WINDOWS) && ENABLE(NETSCAPE_PLUGIN_API)
+ void paintWindowedPluginIntoContext(GraphicsContext*, const IntRect&);
+ static HDC WINAPI hookedBeginPaint(HWND, PAINTSTRUCT*);
+ static BOOL WINAPI hookedEndPaint(HWND, const PAINTSTRUCT*);
+#endif
+
+#if ENABLE(NETSCAPE_PLUGIN_API)
+ static bool platformGetValueStatic(NPNVariable variable, void* value, NPError* result);
+ bool platformGetValue(NPNVariable variable, void* value, NPError* result);
+#endif
+
+ RefPtr<Frame> m_parentFrame;
+ RefPtr<PluginPackage> m_plugin;
+ HTMLPlugInElement* m_element;
+ bool m_isStarted;
+ URL m_url;
+ PluginStatus m_status;
+ Vector<IntRect> m_invalidRects;
+
+ void performRequest(PluginRequest*);
+ void scheduleRequest(std::unique_ptr<PluginRequest>);
+ void requestTimerFired();
+ void invalidateTimerFired();
+ Timer m_requestTimer;
+ Timer m_invalidateTimer;
+
+ void popPopupsStateTimerFired();
+ Timer m_popPopupsStateTimer;
+
+ void lifeSupportTimerFired();
+ Timer m_lifeSupportTimer;
+
+#if ENABLE(NETSCAPE_PLUGIN_API)
+ bool dispatchNPEvent(NPEvent&);
+#endif
+#if defined(XP_MACOSX) && ENABLE(NETSCAPE_PLUGIN_API)
+ int16_t dispatchNPCocoaEvent(NPCocoaEvent&);
+ bool m_updatedCocoaTextInputRequested;
+ bool m_keyDownSent;
+ uint16_t m_disregardKeyUpCounter;
+#endif
+
+#if defined(XP_MACOSX)
+ void handleWheelEvent(WheelEvent*);
+#endif
+ void updatePluginWidget();
+ void paintMissingPluginIcon(GraphicsContext*, const IntRect&);
+
+ void handleKeyboardEvent(KeyboardEvent*);
+ void handleMouseEvent(MouseEvent*);
+#if defined(XP_UNIX) && ENABLE(NETSCAPE_PLUGIN_API)
+ void handleFocusInEvent();
+ void handleFocusOutEvent();
+#endif
+
+#if OS(WINDOWS)
+ void paintIntoTransformedContext(HDC);
+ PassRefPtr<Image> snapshot();
+#endif
+
+ int m_mode;
+ int m_paramCount;
+ char** m_paramNames;
+ char** m_paramValues;
+ String m_pluginsPage;
+
+ String m_mimeType;
+ WTF::CString m_userAgent;
+
+#if ENABLE(NETSCAPE_PLUGIN_API)
+ NPP m_instance;
+ NPP_t m_instanceStruct;
+ NPWindow m_npWindow;
+#endif
+
+ Vector<bool, 4> m_popupStateStack;
+
+ HashSet<RefPtr<PluginStream> > m_streams;
+ Vector<std::unique_ptr<PluginRequest>> m_requests;
+
+ bool m_isWindowed;
+ bool m_isTransparent;
+ bool m_haveInitialized;
+ bool m_isWaitingToStart;
+
+#if defined(XP_UNIX)
+ bool m_needsXEmbed;
+#endif
+
+#if OS(WINDOWS) && ENABLE(NETSCAPE_PLUGIN_API)
+ OwnPtr<PluginMessageThrottlerWin> m_messageThrottler;
+ WNDPROC m_pluginWndProc;
+ unsigned m_lastMessage;
+ bool m_isCallingPluginWndProc;
+ HDC m_wmPrintHDC;
+ bool m_haveUpdatedPluginWidget;
+#endif
+
+#if (PLATFORM(GTK) && OS(WINDOWS)) || PLATFORM(EFL)
+ // On Mac OSX and Qt/Windows the plugin does not have its own native widget,
+ // but is using the containing window as its reference for positioning/painting.
+ PlatformPluginWidget m_window;
+public:
+ PlatformPluginWidget platformPluginWidget() const { return m_window; }
+ void setPlatformPluginWidget(PlatformPluginWidget widget) { m_window = widget; }
+#else
+public:
+ void setPlatformPluginWidget(PlatformPluginWidget widget) { setPlatformWidget(widget); }
+ PlatformPluginWidget platformPluginWidget() const { return platformWidget(); }
+#endif
+
+private:
+
+#if defined(XP_UNIX) || PLATFORM(GTK)
+ void setNPWindowIfNeeded();
+#elif defined(XP_MACOSX)
+ NP_CGContext m_npCgContext;
+ CGContextRef m_contextRef;
+
+ void setNPWindowIfNeeded();
+#endif
+
+#if defined(XP_UNIX) && ENABLE(NETSCAPE_PLUGIN_API)
+ bool m_hasPendingGeometryChange;
+ Pixmap m_drawable;
+ Visual* m_visual;
+ Colormap m_colormap;
+ Display* m_pluginDisplay;
+
+ void initXEvent(XEvent* event);
+#endif
+
+#if PLATFORM(GTK)
+ static gboolean plugRemovedCallback(GtkSocket*, PluginView*);
+ static void plugAddedCallback(GtkSocket*, PluginView*);
+ void updateWidgetAllocationAndClip();
+ bool m_plugAdded;
+ IntRect m_delayedAllocation;
+#endif
+
+ IntRect m_clipRect; // The clip rect to apply to a windowed plug-in
+ IntRect m_windowRect; // Our window rect.
+
+ bool m_loadManually;
+ RefPtr<PluginStream> m_manualStream;
+
+ bool m_isJavaScriptPaused;
+
+ bool m_haveCalledSetWindow;
+
+ static PluginView* s_currentPluginView;
+ };
+
+inline PluginView* toPluginView(Widget* widget)
+{
+ ASSERT(!widget || widget->isPluginView());
+ return static_cast<PluginView*>(widget);
+}
+
+inline const PluginView* toPluginView(const Widget* widget)
+{
+ ASSERT(!widget || widget->isPluginView());
+ return static_cast<const PluginView*>(widget);
+}
+
+// This will catch anyone doing an unnecessary cast.
+void toPluginView(const PluginView*);
+
+} // namespace WebCore
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebKitwinPluginsPluginViewWincppfromrev178217trunkSourceWebCorepluginswinPluginViewWincpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebKit/win/Plugins/PluginViewWin.cpp (from rev 178217, trunk/Source/WebCore/plugins/win/PluginViewWin.cpp) (0 => 178219)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/win/Plugins/PluginViewWin.cpp         (rev 0)
+++ trunk/Source/WebKit/win/Plugins/PluginViewWin.cpp        2015-01-10 00:16:52 UTC (rev 178219)
</span><span class="lines">@@ -0,0 +1,1011 @@
</span><ins>+/*
+ * Copyright (C) 2006, 2007, 2008, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2008 Collabora Ltd. All rights reserved.
+ * Copyright (C) 2008-2009 Torch Mobile, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "PluginView.h"
+
+#include <WebCore/BitmapImage.h>
+#include <WebCore/BitmapInfo.h>
+#include <WebCore/BridgeJSC.h>
+#include <WebCore/Chrome.h>
+#include <WebCore/ChromeClient.h>
+#include <WebCore/Document.h>
+#include <WebCore/DocumentLoader.h>
+#include <WebCore/Element.h>
+#include <WebCore/EventNames.h>
+#include <WebCore/FocusController.h>
+#include <WebCore/Frame.h>
+#include <WebCore/FrameLoadRequest.h>
+#include <WebCore/FrameLoader.h>
+#include <WebCore/FrameTree.h>
+#include <WebCore/FrameView.h>
+#include <WebCore/GraphicsContext.h>
+#include <WebCore/HTMLNames.h>
+#include <WebCore/HTMLPlugInElement.h>
+#include <WebCore/HostWindow.h>
+#include <WebCore/Image.h>
+#include <WebCore/JSDOMBinding.h>
+#include <WebCore/JSDOMWindow.h>
+#include <WebCore/KeyboardEvent.h>
+#include <WebCore/LocalWindowsContext.h>
+#include <WebCore/MIMETypeRegistry.h>
+#include <WebCore/MouseEvent.h>
+#include <WebCore/Page.h>
+#include <WebCore/PlatformMouseEvent.h>
+#include "PluginDatabase.h"
+#include "PluginDebug.h"
+#include "PluginMainThreadScheduler.h"
+#include "PluginMessageThrottlerWin.h"
+#include "PluginPackage.h"
+#include <WebCore/RenderWidget.h>
+#include <WebCore/Settings.h>
+#include <WebCore/WebCoreInstanceHandle.h>
+#include <WebCore/c_instance.h>
+#include <WebCore/npruntime_impl.h>
+#include <WebCore/runtime_root.h>
+#include <runtime/JSCJSValue.h>
+#include <runtime/JSLock.h>
+#include <wtf/ASCIICType.h>
+#include <wtf/text/WTFString.h>
+#include <wtf/win/GDIObject.h>
+
+#if USE(CAIRO)
+#include "PlatformContextCairo.h"
+#include <cairo-win32.h>
+#endif
+
+#if PLATFORM(GTK)
+#include <gdk/gdkwin32.h>
+#include <gtk/gtk.h>
+#endif
+
+static inline HWND windowHandleForPageClient(PlatformPageClient client)
+{
+#if PLATFORM(GTK)
+ if (!client)
+ return 0;
+ if (GdkWindow* window = gtk_widget_get_window(client))
+ return static_cast<HWND>(GDK_WINDOW_HWND(window));
+ return 0;
+#else
+ return client;
+#endif
+}
+
+using JSC::ExecState;
+using JSC::JSLock;
+using JSC::JSObject;
+
+using std::min;
+
+using namespace WTF;
+
+namespace WebCore {
+
+using namespace HTMLNames;
+
+const LPCWSTR kWebPluginViewdowClassName = L"WebPluginView";
+const LPCWSTR kWebPluginViewProperty = L"WebPluginViewProperty";
+
+// The code used to hook BeginPaint/EndPaint originally came from
+// <http://www.fengyuan.com/article/wmprint.html>.
+// Copyright (C) 2000 by Feng Yuan (www.fengyuan.com).
+
+static unsigned beginPaintSysCall;
+static BYTE* beginPaint;
+
+static unsigned endPaintSysCall;
+static BYTE* endPaint;
+
+typedef HDC (WINAPI *PtrBeginPaint)(HWND, PAINTSTRUCT*);
+typedef BOOL (WINAPI *PtrEndPaint)(HWND, const PAINTSTRUCT*);
+
+#if OS(WINDOWS) && CPU(X86_64) && COMPILER(MSVC)
+extern "C" HDC __stdcall _HBeginPaint(HWND hWnd, LPPAINTSTRUCT lpPaint);
+extern "C" BOOL __stdcall _HEndPaint(HWND hWnd, const PAINTSTRUCT* lpPaint);
+#endif
+
+HDC WINAPI PluginView::hookedBeginPaint(HWND hWnd, PAINTSTRUCT* lpPaint)
+{
+ PluginView* pluginView = reinterpret_cast<PluginView*>(GetProp(hWnd, kWebPluginViewProperty));
+ if (pluginView && pluginView->m_wmPrintHDC) {
+ // We're secretly handling WM_PRINTCLIENT, so set up the PAINTSTRUCT so
+ // that the plugin will paint into the HDC we provide.
+ memset(lpPaint, 0, sizeof(PAINTSTRUCT));
+ lpPaint->hdc = pluginView->m_wmPrintHDC;
+ GetClientRect(hWnd, &lpPaint->rcPaint);
+ return pluginView->m_wmPrintHDC;
+ }
+
+#if COMPILER(GCC)
+ HDC result;
+ asm ("push %2\n"
+ "push %3\n"
+ "call *%4\n"
+ : "=a" (result)
+ : "a" (beginPaintSysCall), "g" (lpPaint), "g" (hWnd), "m" (beginPaint)
+ : "memory"
+ );
+ return result;
+#elif defined(_M_IX86)
+ // Call through to the original BeginPaint.
+ __asm mov eax, beginPaintSysCall
+ __asm push lpPaint
+ __asm push hWnd
+ __asm call beginPaint
+#else
+ return _HBeginPaint(hWnd, lpPaint);
+#endif
+}
+
+BOOL WINAPI PluginView::hookedEndPaint(HWND hWnd, const PAINTSTRUCT* lpPaint)
+{
+ PluginView* pluginView = reinterpret_cast<PluginView*>(GetProp(hWnd, kWebPluginViewProperty));
+ if (pluginView && pluginView->m_wmPrintHDC) {
+ // We're secretly handling WM_PRINTCLIENT, so we don't have to do any
+ // cleanup.
+ return TRUE;
+ }
+
+#if COMPILER(GCC)
+ BOOL result;
+ asm ("push %2\n"
+ "push %3\n"
+ "call *%4\n"
+ : "=a" (result)
+ : "a" (endPaintSysCall), "g" (lpPaint), "g" (hWnd), "m" (endPaint)
+ );
+ return result;
+#elif defined (_M_IX86)
+ // Call through to the original EndPaint.
+ __asm mov eax, endPaintSysCall
+ __asm push lpPaint
+ __asm push hWnd
+ __asm call endPaint
+#else
+ return _HEndPaint(hWnd, lpPaint);
+#endif
+}
+
+static void hook(const char* module, const char* proc, unsigned& sysCallID, BYTE*& pProc, const void* pNewProc)
+{
+ // See <http://www.fengyuan.com/article/wmprint.html> for an explanation of
+ // how this function works.
+
+ HINSTANCE hMod = GetModuleHandleA(module);
+
+ pProc = reinterpret_cast<BYTE*>(reinterpret_cast<ptrdiff_t>(GetProcAddress(hMod, proc)));
+
+#if COMPILER(GCC) || defined(_M_IX86)
+ if (pProc[0] != 0xB8)
+ return;
+
+ // FIXME: Should we be reading the bytes one-by-one instead of doing an
+ // unaligned read?
+ sysCallID = *reinterpret_cast<unsigned*>(pProc + 1);
+
+ DWORD flOldProtect;
+ if (!VirtualProtect(pProc, 5, PAGE_EXECUTE_READWRITE, &flOldProtect))
+ return;
+
+ pProc[0] = 0xE9;
+ *reinterpret_cast<unsigned*>(pProc + 1) = reinterpret_cast<intptr_t>(pNewProc) - reinterpret_cast<intptr_t>(pProc + 5);
+
+ pProc += 5;
+#else
+ /* Disassembly of BeginPaint()
+ 00000000779FC5B0 4C 8B D1 mov r10,rcx
+ 00000000779FC5B3 B8 17 10 00 00 mov eax,1017h
+ 00000000779FC5B8 0F 05 syscall
+ 00000000779FC5BA C3 ret
+ 00000000779FC5BB 90 nop
+ 00000000779FC5BC 90 nop
+ 00000000779FC5BD 90 nop
+ 00000000779FC5BE 90 nop
+ 00000000779FC5BF 90 nop
+ 00000000779FC5C0 90 nop
+ 00000000779FC5C1 90 nop
+ 00000000779FC5C2 90 nop
+ 00000000779FC5C3 90 nop
+ */
+ // Check for the signature as in the above disassembly
+ DWORD guard = 0xB8D18B4C;
+ if (*reinterpret_cast<DWORD*>(pProc) != guard)
+ return;
+
+ DWORD flOldProtect;
+ VirtualProtect(pProc, 12, PAGE_EXECUTE_READWRITE, & flOldProtect);
+ pProc[0] = 0x48; // mov rax, this
+ pProc[1] = 0xb8;
+ *(__int64*)(pProc+2) = (__int64)pNewProc;
+ pProc[10] = 0xff; // jmp rax
+ pProc[11] = 0xe0;
+#endif
+}
+
+static void setUpOffscreenPaintingHooks(HDC (WINAPI*hookedBeginPaint)(HWND, PAINTSTRUCT*), BOOL (WINAPI*hookedEndPaint)(HWND, const PAINTSTRUCT*))
+{
+ static bool haveHooked = false;
+ if (haveHooked)
+ return;
+ haveHooked = true;
+
+ // Most (all?) windowed plugins don't seem to respond to WM_PRINTCLIENT, so
+ // we hook into BeginPaint/EndPaint to allow their normal WM_PAINT handling
+ // to draw into a given HDC. Note that this hooking affects the entire
+ // process.
+ hook("user32.dll", "BeginPaint", beginPaintSysCall, beginPaint, reinterpret_cast<const void *>(reinterpret_cast<ptrdiff_t>(hookedBeginPaint)));
+ hook("user32.dll", "EndPaint", endPaintSysCall, endPaint, reinterpret_cast<const void *>(reinterpret_cast<ptrdiff_t>(hookedEndPaint)));
+
+}
+
+static bool registerPluginView()
+{
+ static bool haveRegisteredWindowClass = false;
+ if (haveRegisteredWindowClass)
+ return true;
+
+ haveRegisteredWindowClass = true;
+
+#if PLATFORM(GTK)
+ WebCore::setInstanceHandle((HINSTANCE)(GetModuleHandle(0)));
+#endif
+
+ ASSERT(WebCore::instanceHandle());
+
+ WNDCLASSEX wcex;
+ wcex.cbSize = sizeof(WNDCLASSEX);
+ wcex.hIconSm = 0;
+ wcex.style = CS_DBLCLKS;
+ wcex.lpfnWndProc = DefWindowProc;
+ wcex.cbClsExtra = 0;
+ wcex.cbWndExtra = 0;
+ wcex.hInstance = WebCore::instanceHandle();
+ wcex.hIcon = 0;
+ wcex.hCursor = LoadCursor(0, IDC_ARROW);
+ wcex.hbrBackground = (HBRUSH)COLOR_WINDOW;
+ wcex.lpszMenuName = 0;
+ wcex.lpszClassName = kWebPluginViewdowClassName;
+
+ return !!RegisterClassEx(&wcex);
+}
+
+LRESULT CALLBACK PluginView::PluginViewWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ PluginView* pluginView = reinterpret_cast<PluginView*>(GetProp(hWnd, kWebPluginViewProperty));
+
+ return pluginView->wndProc(hWnd, message, wParam, lParam);
+}
+
+static bool isWindowsMessageUserGesture(UINT message)
+{
+ switch (message) {
+ case WM_LBUTTONUP:
+ case WM_MBUTTONUP:
+ case WM_RBUTTONUP:
+ case WM_KEYUP:
+ return true;
+ default:
+ return false;
+ }
+}
+
+static inline IntPoint contentsToNativeWindow(FrameView* view, const IntPoint& point)
+{
+ return view->contentsToWindow(point);
+}
+
+static inline IntRect contentsToNativeWindow(FrameView* view, const IntRect& rect)
+{
+ return view->contentsToWindow(rect);
+}
+
+LRESULT
+PluginView::wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ // <rdar://5711136> Sometimes Flash will call SetCapture before creating
+ // a full-screen window and will not release it, which causes the
+ // full-screen window to never receive mouse events. We set/release capture
+ // on mouse down/up before sending the event to the plug-in to prevent that.
+ switch (message) {
+ case WM_LBUTTONDOWN:
+ case WM_MBUTTONDOWN:
+ case WM_RBUTTONDOWN:
+ ::SetCapture(hWnd);
+ break;
+ case WM_LBUTTONUP:
+ case WM_MBUTTONUP:
+ case WM_RBUTTONUP:
+ ::ReleaseCapture();
+ break;
+ }
+
+ if (message == m_lastMessage &&
+ m_plugin->quirks().contains(PluginQuirkDontCallWndProcForSameMessageRecursively) &&
+ m_isCallingPluginWndProc)
+ return 1;
+
+ if (message == WM_USER + 1 &&
+ m_plugin->quirks().contains(PluginQuirkThrottleWMUserPlusOneMessages)) {
+ if (!m_messageThrottler)
+ m_messageThrottler = adoptPtr(new PluginMessageThrottlerWin(this));
+
+ m_messageThrottler->appendMessage(hWnd, message, wParam, lParam);
+ return 0;
+ }
+
+ m_lastMessage = message;
+ m_isCallingPluginWndProc = true;
+
+ // If the plug-in doesn't explicitly support changing the pop-up state, we enable
+ // popups for all user gestures.
+ // Note that we need to pop the state in a timer, because the Flash plug-in
+ // pops up windows in response to a posted message.
+ if (m_plugin->pluginFuncs()->version < NPVERS_HAS_POPUPS_ENABLED_STATE &&
+ isWindowsMessageUserGesture(message) && !m_popPopupsStateTimer.isActive()) {
+
+ pushPopupsEnabledState(true);
+
+ m_popPopupsStateTimer.startOneShot(0);
+ }
+
+ if (message == WM_PRINTCLIENT) {
+ // Most (all?) windowed plugins don't respond to WM_PRINTCLIENT, so we
+ // change the message to WM_PAINT and rely on our hooked versions of
+ // BeginPaint/EndPaint to make the plugin draw into the given HDC.
+ message = WM_PAINT;
+ m_wmPrintHDC = reinterpret_cast<HDC>(wParam);
+ }
+
+ // Call the plug-in's window proc.
+ LRESULT result = ::CallWindowProc(m_pluginWndProc, hWnd, message, wParam, lParam);
+
+ m_wmPrintHDC = 0;
+
+ m_isCallingPluginWndProc = false;
+
+ return result;
+}
+
+void PluginView::updatePluginWidget()
+{
+ if (!parent())
+ return;
+
+ FrameView& frameView = downcast<FrameView>(*parent());
+
+ IntRect oldWindowRect = m_windowRect;
+ IntRect oldClipRect = m_clipRect;
+
+ m_windowRect = IntRect(frameView.contentsToWindow(frameRect().location()), frameRect().size());
+ m_clipRect = windowClipRect();
+ m_clipRect.move(-m_windowRect.x(), -m_windowRect.y());
+
+ if (platformPluginWidget() && (!m_haveUpdatedPluginWidget || m_windowRect != oldWindowRect || m_clipRect != oldClipRect)) {
+
+ setCallingPlugin(true);
+
+ // To prevent flashes while scrolling, we disable drawing during the window
+ // update process by clipping the window to the zero rect.
+
+ bool clipToZeroRect = !m_plugin->quirks().contains(PluginQuirkDontClipToZeroRectWhenScrolling);
+
+ if (clipToZeroRect) {
+ auto rgn = adoptGDIObject(::CreateRectRgn(0, 0, 0, 0));
+ ::SetWindowRgn(platformPluginWidget(), rgn.leak(), FALSE);
+ } else {
+ auto rgn = adoptGDIObject(::CreateRectRgn(m_clipRect.x(), m_clipRect.y(), m_clipRect.maxX(), m_clipRect.maxY()));
+ ::SetWindowRgn(platformPluginWidget(), rgn.leak(), TRUE);
+ }
+
+ if (!m_haveUpdatedPluginWidget || m_windowRect != oldWindowRect)
+ ::MoveWindow(platformPluginWidget(), m_windowRect.x(), m_windowRect.y(), m_windowRect.width(), m_windowRect.height(), TRUE);
+
+ if (clipToZeroRect) {
+ auto rgn = adoptGDIObject(::CreateRectRgn(m_clipRect.x(), m_clipRect.y(), m_clipRect.maxX(), m_clipRect.maxY()));
+ ::SetWindowRgn(platformPluginWidget(), rgn.leak(), TRUE);
+ }
+
+ setCallingPlugin(false);
+
+ m_haveUpdatedPluginWidget = true;
+ }
+}
+
+void PluginView::setFocus(bool focused)
+{
+ if (focused && platformPluginWidget())
+ SetFocus(platformPluginWidget());
+
+ Widget::setFocus(focused);
+
+ if (!m_plugin || m_isWindowed)
+ return;
+
+ NPEvent npEvent;
+
+ npEvent.event = focused ? WM_SETFOCUS : WM_KILLFOCUS;
+ npEvent.wParam = 0;
+ npEvent.lParam = 0;
+
+ dispatchNPEvent(npEvent);
+}
+
+void PluginView::show()
+{
+ setSelfVisible(true);
+
+ if (isParentVisible() && platformPluginWidget())
+ ShowWindow(platformPluginWidget(), SW_SHOWNA);
+
+ Widget::show();
+}
+
+void PluginView::hide()
+{
+ setSelfVisible(false);
+
+ if (isParentVisible() && platformPluginWidget())
+ ShowWindow(platformPluginWidget(), SW_HIDE);
+
+ Widget::hide();
+}
+
+bool PluginView::dispatchNPEvent(NPEvent& npEvent)
+{
+ if (!m_plugin->pluginFuncs()->event)
+ return true;
+
+ bool shouldPop = false;
+
+ if (m_plugin->pluginFuncs()->version < NPVERS_HAS_POPUPS_ENABLED_STATE && isWindowsMessageUserGesture(npEvent.event)) {
+ pushPopupsEnabledState(true);
+ shouldPop = true;
+ }
+
+ JSC::JSLock::DropAllLocks dropAllLocks(JSDOMWindowBase::commonVM());
+ setCallingPlugin(true);
+ bool accepted = !m_plugin->pluginFuncs()->event(m_instance, &npEvent);
+ setCallingPlugin(false);
+
+ if (shouldPop)
+ popPopupsEnabledState();
+
+ return accepted;
+}
+
+void PluginView::paintIntoTransformedContext(HDC hdc)
+{
+ if (m_isWindowed) {
+ SendMessage(platformPluginWidget(), WM_PRINTCLIENT, reinterpret_cast<WPARAM>(hdc), PRF_CLIENT | PRF_CHILDREN | PRF_OWNED);
+ return;
+ }
+
+ m_npWindow.type = NPWindowTypeDrawable;
+ m_npWindow.window = hdc;
+
+ WINDOWPOS windowpos = { 0, 0, 0, 0, 0, 0, 0 };
+
+ IntRect r = contentsToNativeWindow(downcast<FrameView>(parent()), frameRect());
+
+ windowpos.x = r.x();
+ windowpos.y = r.y();
+ windowpos.cx = r.width();
+ windowpos.cy = r.height();
+
+ NPEvent npEvent;
+ npEvent.event = WM_WINDOWPOSCHANGED;
+ npEvent.lParam = reinterpret_cast<uintptr_t>(&windowpos);
+ npEvent.wParam = 0;
+
+ dispatchNPEvent(npEvent);
+
+ setNPWindowRect(frameRect());
+
+ npEvent.event = WM_PAINT;
+ npEvent.wParam = reinterpret_cast<uintptr_t>(hdc);
+
+ // This is supposed to be a pointer to the dirty rect, but it seems that the Flash plugin
+ // ignores it so we just pass null.
+ npEvent.lParam = 0;
+
+ dispatchNPEvent(npEvent);
+}
+
+void PluginView::paintWindowedPluginIntoContext(GraphicsContext* context, const IntRect& rect)
+{
+#if !USE(WINGDI)
+ ASSERT(m_isWindowed);
+ ASSERT(context->shouldIncludeChildWindows());
+
+ IntPoint locationInWindow = downcast<FrameView>(*parent()).convertToContainingWindow(frameRect().location());
+
+ LocalWindowsContext windowsContext(context, frameRect(), false);
+
+#if USE(CAIRO)
+ // Must flush drawings up to this point to the backing metafile, otherwise the
+ // plugin region will be overwritten with any clear regions specified in the
+ // cairo-controlled portions of the rendering.
+ cairo_show_page(context->platformContext()->cr());
+#endif
+
+ HDC hdc = windowsContext.hdc();
+ XFORM originalTransform;
+ GetWorldTransform(hdc, &originalTransform);
+
+ // The plugin expects the DC to be in client coordinates, so we translate
+ // the DC to make that so.
+ AffineTransform ctm = context->getCTM();
+ ctm.translate(locationInWindow.x(), locationInWindow.y());
+ XFORM transform = static_cast<XFORM>(ctm.toTransformationMatrix());
+
+ SetWorldTransform(hdc, &transform);
+
+ paintIntoTransformedContext(hdc);
+
+ SetWorldTransform(hdc, &originalTransform);
+#endif
+}
+
+void PluginView::paint(GraphicsContext* context, const IntRect& rect)
+{
+ if (!m_isStarted) {
+ // Draw the "missing plugin" image
+ paintMissingPluginIcon(context, rect);
+ return;
+ }
+
+ if (context->paintingDisabled())
+ return;
+
+ // Ensure that we have called SetWindow before we try to paint.
+ if (!m_haveCalledSetWindow)
+ setNPWindowRect(frameRect());
+
+ if (m_isWindowed) {
+#if !USE(WINGDI)
+ if (context->shouldIncludeChildWindows())
+ paintWindowedPluginIntoContext(context, rect);
+#endif
+ return;
+ }
+
+ // In the GTK and Qt ports we draw in an offscreen buffer and don't want to use the window
+ // coordinates.
+#if PLATFORM(GTK)
+ IntRect rectInWindow(rect);
+ rectInWindow.intersect(frameRect());
+#else
+ IntRect rectInWindow = downcast<FrameView>(*parent()).contentsToWindow(frameRect());
+#endif
+ LocalWindowsContext windowsContext(context, rectInWindow, m_isTransparent);
+
+ // On Safari/Windows without transparency layers the GraphicsContext returns the HDC
+ // of the window and the plugin expects that the passed in DC has window coordinates.
+ // In the GTK and Qt ports we always draw in an offscreen buffer and therefore need
+ // to preserve the translation set in getWindowsContext.
+#if !PLATFORM(GTK)
+ if (!context->isInTransparencyLayer()) {
+ XFORM transform;
+ GetWorldTransform(windowsContext.hdc(), &transform);
+ transform.eDx = 0;
+ transform.eDy = 0;
+ SetWorldTransform(windowsContext.hdc(), &transform);
+ }
+#endif
+
+ paintIntoTransformedContext(windowsContext.hdc());
+}
+
+void PluginView::handleKeyboardEvent(KeyboardEvent* event)
+{
+ ASSERT(m_plugin && !m_isWindowed);
+
+ NPEvent npEvent;
+
+ npEvent.wParam = event->keyCode();
+
+ if (event->type() == eventNames().keydownEvent) {
+ npEvent.event = WM_KEYDOWN;
+ npEvent.lParam = 0;
+ } else if (event->type() == eventNames().keypressEvent) {
+ npEvent.event = WM_CHAR;
+ npEvent.lParam = 0;
+ } else if (event->type() == eventNames().keyupEvent) {
+ npEvent.event = WM_KEYUP;
+ npEvent.lParam = 0x8000;
+ } else
+ return;
+
+ JSC::JSLock::DropAllLocks dropAllLocks(JSDOMWindowBase::commonVM());
+ if (dispatchNPEvent(npEvent))
+ event->setDefaultHandled();
+}
+
+extern bool ignoreNextSetCursor;
+
+void PluginView::handleMouseEvent(MouseEvent* event)
+{
+ ASSERT(m_plugin && !m_isWindowed);
+
+ NPEvent npEvent;
+
+ IntPoint p = contentsToNativeWindow(downcast<FrameView>(parent()), IntPoint(event->pageX(), event->pageY()));
+
+ npEvent.lParam = MAKELPARAM(p.x(), p.y());
+ npEvent.wParam = 0;
+
+ if (event->ctrlKey())
+ npEvent.wParam |= MK_CONTROL;
+ if (event->shiftKey())
+ npEvent.wParam |= MK_SHIFT;
+
+ if (event->type() == eventNames().mousemoveEvent ||
+ event->type() == eventNames().mouseoutEvent ||
+ event->type() == eventNames().mouseoverEvent) {
+ npEvent.event = WM_MOUSEMOVE;
+ if (event->buttonDown())
+ switch (event->button()) {
+ case LeftButton:
+ npEvent.wParam |= MK_LBUTTON;
+ break;
+ case MiddleButton:
+ npEvent.wParam |= MK_MBUTTON;
+ break;
+ case RightButton:
+ npEvent.wParam |= MK_RBUTTON;
+ break;
+ }
+ }
+ else if (event->type() == eventNames().mousedownEvent) {
+ focusPluginElement();
+ switch (event->button()) {
+ case 0:
+ npEvent.event = WM_LBUTTONDOWN;
+ break;
+ case 1:
+ npEvent.event = WM_MBUTTONDOWN;
+ break;
+ case 2:
+ npEvent.event = WM_RBUTTONDOWN;
+ break;
+ }
+ } else if (event->type() == eventNames().mouseupEvent) {
+ switch (event->button()) {
+ case 0:
+ npEvent.event = WM_LBUTTONUP;
+ break;
+ case 1:
+ npEvent.event = WM_MBUTTONUP;
+ break;
+ case 2:
+ npEvent.event = WM_RBUTTONUP;
+ break;
+ }
+ } else
+ return;
+
+ JSC::JSLock::DropAllLocks dropAllLocks(JSDOMWindowBase::commonVM());
+ // FIXME: Consider back porting the http://webkit.org/b/58108 fix here.
+ if (dispatchNPEvent(npEvent))
+ event->setDefaultHandled();
+
+#if !PLATFORM(GTK)
+ // Currently, Widget::setCursor is always called after this function in EventHandler.cpp
+ // and since we don't want that we set ignoreNextSetCursor to true here to prevent that.
+ ignoreNextSetCursor = true;
+ if (Page* page = m_parentFrame->page())
+ page->chrome().client().setLastSetCursorToCurrentCursor();
+#endif
+}
+
+void PluginView::setParent(ScrollView* parent)
+{
+ Widget::setParent(parent);
+
+ if (parent)
+ init();
+ else {
+ if (!platformPluginWidget())
+ return;
+
+ // If the plug-in window or one of its children have the focus, we need to
+ // clear it to prevent the web view window from being focused because that can
+ // trigger a layout while the plugin element is being detached.
+ HWND focusedWindow = ::GetFocus();
+ if (platformPluginWidget() == focusedWindow || ::IsChild(platformPluginWidget(), focusedWindow))
+ ::SetFocus(0);
+ }
+}
+
+void PluginView::setParentVisible(bool visible)
+{
+ if (isParentVisible() == visible)
+ return;
+
+ Widget::setParentVisible(visible);
+
+ if (isSelfVisible() && platformPluginWidget()) {
+ if (visible)
+ ShowWindow(platformPluginWidget(), SW_SHOWNA);
+ else
+ ShowWindow(platformPluginWidget(), SW_HIDE);
+ }
+}
+
+void PluginView::setNPWindowRect(const IntRect& rect)
+{
+ if (!m_isStarted)
+ return;
+
+ // In the GTK port we draw in an offscreen buffer and don't want to use the window
+ // coordinates.
+# if PLATFORM(GTK)
+ IntPoint p = rect.location();
+# else
+ IntPoint p = downcast<FrameView>(*parent()).contentsToWindow(rect.location());
+# endif
+ m_npWindow.x = p.x();
+ m_npWindow.y = p.y();
+
+ m_npWindow.width = rect.width();
+ m_npWindow.height = rect.height();
+
+ m_npWindow.clipRect.right = rect.width();
+ m_npWindow.clipRect.bottom = rect.height();
+ m_npWindow.clipRect.left = 0;
+ m_npWindow.clipRect.top = 0;
+
+ if (m_plugin->pluginFuncs()->setwindow) {
+ JSC::JSLock::DropAllLocks dropAllLocks(JSDOMWindowBase::commonVM());
+ setCallingPlugin(true);
+ m_plugin->pluginFuncs()->setwindow(m_instance, &m_npWindow);
+ setCallingPlugin(false);
+
+ m_haveCalledSetWindow = true;
+
+ if (!m_isWindowed)
+ return;
+
+ ASSERT(platformPluginWidget());
+
+ WNDPROC currentWndProc = (WNDPROC)GetWindowLongPtr(platformPluginWidget(), GWLP_WNDPROC);
+ if (currentWndProc != PluginViewWndProc)
+ m_pluginWndProc = (WNDPROC)SetWindowLongPtr(platformPluginWidget(), GWLP_WNDPROC, (LONG_PTR)PluginViewWndProc);
+ }
+}
+
+NPError PluginView::handlePostReadFile(Vector<char>& buffer, uint32_t len, const char* buf)
+{
+ String filename(buf, len);
+
+ if (filename.startsWith("file:///"))
+ filename = filename.substring(8);
+
+ // Get file info
+ WIN32_FILE_ATTRIBUTE_DATA attrs;
+ if (GetFileAttributesExW(filename.charactersWithNullTermination().data(), GetFileExInfoStandard, &attrs) == 0)
+ return NPERR_FILE_NOT_FOUND;
+
+ if (attrs.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+ return NPERR_FILE_NOT_FOUND;
+
+ HANDLE fileHandle = CreateFileW(filename.charactersWithNullTermination().data(), FILE_READ_DATA, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
+
+ if (fileHandle == INVALID_HANDLE_VALUE)
+ return NPERR_FILE_NOT_FOUND;
+
+ buffer.resize(attrs.nFileSizeLow);
+
+ DWORD bytesRead;
+ int retval = ReadFile(fileHandle, buffer.data(), attrs.nFileSizeLow, &bytesRead, 0);
+
+ CloseHandle(fileHandle);
+
+ if (retval == 0 || bytesRead != attrs.nFileSizeLow)
+ return NPERR_FILE_NOT_FOUND;
+
+ return NPERR_NO_ERROR;
+}
+
+bool PluginView::platformGetValueStatic(NPNVariable, void*, NPError*)
+{
+ return false;
+}
+
+bool PluginView::platformGetValue(NPNVariable variable, void* value, NPError* result)
+{
+ switch (variable) {
+ case NPNVnetscapeWindow: {
+ HWND* w = reinterpret_cast<HWND*>(value);
+ *w = windowHandleForPageClient(parent() ? parent()->hostWindow()->platformPageClient() : 0);
+ *result = NPERR_NO_ERROR;
+ return true;
+ }
+
+ case NPNVSupportsWindowless: {
+ NPBool* flag = reinterpret_cast<NPBool*>(value);
+ *flag = TRUE;
+ *result = NPERR_NO_ERROR;
+ return true;
+ }
+
+ default:
+ return false;
+ }
+}
+
+void PluginView::invalidateRect(const IntRect& rect)
+{
+ if (m_isWindowed) {
+ RECT invalidRect = { rect.x(), rect.y(), rect.maxX(), rect.maxY() };
+ ::InvalidateRect(platformPluginWidget(), &invalidRect, false);
+ return;
+ }
+
+ invalidateWindowlessPluginRect(rect);
+}
+
+void PluginView::invalidateRect(NPRect* rect)
+{
+ if (!rect) {
+ invalidate();
+ return;
+ }
+
+ IntRect r(rect->left, rect->top, rect->right - rect->left, rect->bottom - rect->top);
+
+ if (m_isWindowed) {
+ RECT invalidRect = { r.x(), r.y(), r.maxX(), r.maxY() };
+ InvalidateRect(platformPluginWidget(), &invalidRect, FALSE);
+ } else {
+ if (m_plugin->quirks().contains(PluginQuirkThrottleInvalidate)) {
+ m_invalidRects.append(r);
+ if (!m_invalidateTimer.isActive())
+ m_invalidateTimer.startOneShot(0.001);
+ } else
+ invalidateRect(r);
+ }
+}
+
+void PluginView::invalidateRegion(NPRegion region)
+{
+ if (m_isWindowed)
+ return;
+
+ RECT r;
+
+ if (GetRgnBox(region, &r) == 0) {
+ invalidate();
+ return;
+ }
+
+ IntRect rect(IntPoint(r.left, r.top), IntSize(r.right-r.left, r.bottom-r.top));
+ invalidateRect(rect);
+}
+
+void PluginView::forceRedraw()
+{
+ if (m_isWindowed)
+ ::UpdateWindow(platformPluginWidget());
+ else
+ ::UpdateWindow(windowHandleForPageClient(parent() ? parent()->hostWindow()->platformPageClient() : 0));
+}
+
+bool PluginView::platformStart()
+{
+ ASSERT(m_isStarted);
+ ASSERT(m_status == PluginStatusLoadedSuccessfully);
+
+ if (m_isWindowed) {
+ registerPluginView();
+ setUpOffscreenPaintingHooks(hookedBeginPaint, hookedEndPaint);
+
+ DWORD flags = WS_CHILD;
+ if (isSelfVisible())
+ flags |= WS_VISIBLE;
+
+ HWND parentWindowHandle = windowHandleForPageClient(m_parentFrame->view()->hostWindow()->platformPageClient());
+ HWND window = ::CreateWindowEx(0, kWebPluginViewdowClassName, 0, flags,
+ 0, 0, 0, 0, parentWindowHandle, 0, WebCore::instanceHandle(), 0);
+
+#if OS(WINDOWS) && PLATFORM(GTK)
+ m_window = window;
+#else
+ setPlatformWidget(window);
+#endif
+
+ // Calling SetWindowLongPtrA here makes the window proc ASCII, which is required by at least
+ // the Shockwave Director plug-in.
+#if OS(WINDOWS) && CPU(X86_64)
+ ::SetWindowLongPtrA(platformPluginWidget(), GWLP_WNDPROC, (LONG_PTR)DefWindowProcA);
+#else
+ ::SetWindowLongPtrA(platformPluginWidget(), GWL_WNDPROC, (LONG)DefWindowProcA);
+#endif
+ SetProp(platformPluginWidget(), kWebPluginViewProperty, this);
+
+ m_npWindow.type = NPWindowTypeWindow;
+ m_npWindow.window = platformPluginWidget();
+ } else {
+ m_npWindow.type = NPWindowTypeDrawable;
+ m_npWindow.window = 0;
+ }
+
+ updatePluginWidget();
+
+ if (!m_plugin->quirks().contains(PluginQuirkDeferFirstSetWindowCall))
+ setNPWindowRect(frameRect());
+
+ return true;
+}
+
+void PluginView::platformDestroy()
+{
+ if (!platformPluginWidget())
+ return;
+
+ DestroyWindow(platformPluginWidget());
+ setPlatformPluginWidget(0);
+}
+
+PassRefPtr<Image> PluginView::snapshot()
+{
+#if !PLATFORM(GTK) && !USE(WINGDI)
+ auto hdc = adoptGDIObject(::CreateCompatibleDC(0));
+
+ if (!m_isWindowed) {
+ // Enable world transforms.
+ SetGraphicsMode(hdc.get(), GM_ADVANCED);
+
+ XFORM transform;
+ GetWorldTransform(hdc.get(), &transform);
+
+ // Windowless plug-ins assume that they're drawing onto the view's DC.
+ // Translate the context so that the plug-in draws at (0, 0).
+ IntPoint position = downcast<FrameView>(*parent()).contentsToWindow(frameRect()).location();
+ transform.eDx = -position.x();
+ transform.eDy = -position.y();
+ SetWorldTransform(hdc.get(), &transform);
+ }
+
+ void* bits;
+ BitmapInfo bmp = BitmapInfo::createBottomUp(frameRect().size());
+ auto hbmp = adoptGDIObject(::CreateDIBSection(0, &bmp, DIB_RGB_COLORS, &bits, 0, 0));
+
+ HBITMAP hbmpOld = static_cast<HBITMAP>(SelectObject(hdc.get(), hbmp.get()));
+
+ paintIntoTransformedContext(hdc.get());
+
+ SelectObject(hdc.get(), hbmpOld);
+
+ return BitmapImage::create(hbmp.get());
+#else
+ return 0;
+#endif
+}
+
+} // namespace WebCore
</ins></span></pre></div>
<a id="trunkSourceWebKitwinPluginsnpapicppfromrev178217trunkSourceWebCorepluginsnpapicpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebKit/win/Plugins/npapi.cpp (from rev 178217, trunk/Source/WebCore/plugins/npapi.cpp) (0 => 178219)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/win/Plugins/npapi.cpp         (rev 0)
+++ trunk/Source/WebKit/win/Plugins/npapi.cpp        2015-01-10 00:16:52 UTC (rev 178219)
</span><span class="lines">@@ -0,0 +1,208 @@
</span><ins>+/*
+ * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#include "Page.h"
+#include "PluginMainThreadScheduler.h"
+#include "PluginView.h"
+#include "npruntime_internal.h"
+
+using namespace WebCore;
+
+// The plugin view is always the ndata of the instance,. Sometimes, plug-ins will call an instance-specific function
+// with a NULL instance. To workaround this, call the last plug-in view that made a call to a plug-in.
+// Currently, the current plug-in view is only set before NPP_New in PluginView::start.
+// This specifically works around Flash and Shockwave. When we call NPP_New, they call NPN_Useragent with a NULL instance.
+static PluginView* pluginViewForInstance(NPP instance)
+{
+ if (instance && instance->ndata)
+ return static_cast<PluginView*>(instance->ndata);
+ return PluginView::currentPluginView();
+}
+
+void* NPN_MemAlloc(uint32_t size)
+{
+ return malloc(size);
+}
+
+void NPN_MemFree(void* ptr)
+{
+ free(ptr);
+}
+
+uint32_t NPN_MemFlush(uint32_t)
+{
+ // Do nothing
+ return 0;
+}
+
+void NPN_ReloadPlugins(NPBool reloadPages)
+{
+ Page::refreshPlugins(reloadPages);
+}
+
+NPError NPN_RequestRead(NPStream*, NPByteRange*)
+{
+ return NPERR_STREAM_NOT_SEEKABLE;
+}
+
+NPError NPN_GetURLNotify(NPP instance, const char* url, const char* target, void* notifyData)
+{
+ return pluginViewForInstance(instance)->getURLNotify(url, target, notifyData);
+}
+
+NPError NPN_GetURL(NPP instance, const char* url, const char* target)
+{
+ return pluginViewForInstance(instance)->getURL(url, target);
+}
+
+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);
+}
+
+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);
+}
+
+NPError NPN_NewStream(NPP instance, NPMIMEType type, const char* target, NPStream** stream)
+{
+ return pluginViewForInstance(instance)->newStream(type, target, stream);
+}
+
+int32_t NPN_Write(NPP instance, NPStream* stream, int32_t len, void* buffer)
+{
+ return pluginViewForInstance(instance)->write(stream, len, buffer);
+}
+
+NPError NPN_DestroyStream(NPP instance, NPStream* stream, NPReason reason)
+{
+ return pluginViewForInstance(instance)->destroyStream(stream, reason);
+}
+
+const char* NPN_UserAgent(NPP instance)
+{
+ PluginView* view = pluginViewForInstance(instance);
+
+ if (!view)
+ return PluginView::userAgentStatic();
+
+ return view->userAgent();
+}
+
+void NPN_Status(NPP instance, const char* message)
+{
+ pluginViewForInstance(instance)->status(message);
+}
+
+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);
+}
+
+void NPN_InvalidateRegion(NPP instance, NPRegion invalidRegion)
+{
+ pluginViewForInstance(instance)->invalidateRegion(invalidRegion);
+}
+
+void NPN_ForceRedraw(NPP instance)
+{
+ pluginViewForInstance(instance)->forceRedraw();
+}
+
+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);
+}
+
+NPError NPN_SetValue(NPP instance, NPPVariable variable, void* value)
+{
+ return pluginViewForInstance(instance)->setValue(variable, value);
+}
+
+void* NPN_GetJavaEnv()
+{
+ // Unsupported
+ return 0;
+}
+
+void* NPN_GetJavaPeer(NPP)
+{
+ // Unsupported
+ return 0;
+}
+
+void NPN_PushPopupsEnabledState(NPP instance, NPBool enabled)
+{
+ pluginViewForInstance(instance)->pushPopupsEnabledState(enabled);
+}
+
+void NPN_PopPopupsEnabledState(NPP instance)
+{
+ pluginViewForInstance(instance)->popPopupsEnabledState();
+}
+
+extern "C" typedef void PluginThreadAsyncCallFunction(void*);
+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);
+}
+
+NPError NPN_GetValueForURL(NPP instance, NPNURLVariable variable, const char* url, char** value, uint32_t* len)
+{
+ return pluginViewForInstance(instance)->getValueForURL(variable, url, value, len);
+}
+
+NPError NPN_SetValueForURL(NPP instance, NPNURLVariable variable, const char* url, const char* value, uint32_t len)
+{
+ return pluginViewForInstance(instance)->setValueForURL(variable, url, value, len);
+}
+
+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);
+}
+
+NPError NPN_PopUpContextMenu(NPP instance, NPMenu* menu)
+{
+ UNUSED_PARAM(instance);
+ UNUSED_PARAM(menu);
+ return NPERR_NO_ERROR;
+}
</ins></span></pre></div>
<a id="trunkSourceWebKitwinWebCoreSupportEmbeddedWidgeth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/win/WebCoreSupport/EmbeddedWidget.h (178218 => 178219)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/win/WebCoreSupport/EmbeddedWidget.h        2015-01-10 00:09:59 UTC (rev 178218)
+++ trunk/Source/WebKit/win/WebCoreSupport/EmbeddedWidget.h        2015-01-10 00:16:52 UTC (rev 178219)
</span><span class="lines">@@ -26,10 +26,10 @@
</span><span class="cx"> #ifndef EmbeddedWidget_h
</span><span class="cx"> #define EmbeddedWidget_h
</span><span class="cx">
</span><ins>+#include "PluginView.h"
</ins><span class="cx"> #include "WebKit.h"
</span><span class="cx"> #include <WebCore/COMPtr.h>
</span><span class="cx"> #include <WebCore/IntRect.h>
</span><del>-#include <WebCore/PluginView.h>
</del><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> class HTMLPlugInElement;
</span></span></pre></div>
<a id="trunkSourceWebKitwinWebCoreSupportWebFrameLoaderClientcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/win/WebCoreSupport/WebFrameLoaderClient.cpp (178218 => 178219)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/win/WebCoreSupport/WebFrameLoaderClient.cpp        2015-01-10 00:09:59 UTC (rev 178218)
+++ trunk/Source/WebKit/win/WebCoreSupport/WebFrameLoaderClient.cpp        2015-01-10 00:16:52 UTC (rev 178219)
</span><span class="lines">@@ -35,6 +35,9 @@
</span><span class="cx"> #include "EmbeddedWidget.h"
</span><span class="cx"> #include "MarshallingHelpers.h"
</span><span class="cx"> #include "NotImplemented.h"
</span><ins>+#include "PluginDatabase.h"
+#include "PluginPackage.h"
+#include "PluginView.h"
</ins><span class="cx"> #include "WebActionPropertyBag.h"
</span><span class="cx"> #include "WebCachedFramePlatformData.h"
</span><span class="cx"> #include "WebChromeClient.h"
</span><span class="lines">@@ -73,9 +76,6 @@
</span><span class="cx"> #include <WebCore/LocalizedStrings.h>
</span><span class="cx"> #include <WebCore/MIMETypeRegistry.h>
</span><span class="cx"> #include <WebCore/Page.h>
</span><del>-#include <WebCore/PluginDatabase.h>
-#include <WebCore/PluginPackage.h>
-#include <WebCore/PluginView.h>
</del><span class="cx"> #include <WebCore/PolicyChecker.h>
</span><span class="cx"> #include <WebCore/RenderWidget.h>
</span><span class="cx"> #include <WebCore/ResourceHandle.h>
</span></span></pre></div>
<a id="trunkSourceWebKitwinWebCoreSupportWebPlatformStrategiescpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/win/WebCoreSupport/WebPlatformStrategies.cpp (178218 => 178219)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/win/WebCoreSupport/WebPlatformStrategies.cpp        2015-01-10 00:09:59 UTC (rev 178218)
+++ trunk/Source/WebKit/win/WebCoreSupport/WebPlatformStrategies.cpp        2015-01-10 00:16:52 UTC (rev 178219)
</span><span class="lines">@@ -26,11 +26,11 @@
</span><span class="cx"> #include "WebPlatformStrategies.h"
</span><span class="cx">
</span><span class="cx"> #include "FrameLoader.h"
</span><ins>+#include "PluginDatabase.h"
</ins><span class="cx"> #include "WebFrameNetworkingContext.h"
</span><span class="cx"> #include <WebCore/Page.h>
</span><span class="cx"> #include <WebCore/PageGroup.h>
</span><span class="cx"> #include <WebCore/PlatformCookieJar.h>
</span><del>-#include <WebCore/PluginDatabase.h>
</del><span class="cx"> #if USE(CFNETWORK)
</span><span class="cx"> #include <WebKitSystemInterface/WebKitSystemInterface.h>
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKitwinWebFramecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/win/WebFrame.cpp (178218 => 178219)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/win/WebFrame.cpp        2015-01-10 00:09:59 UTC (rev 178218)
+++ trunk/Source/WebKit/win/WebFrame.cpp        2015-01-10 00:16:52 UTC (rev 178219)
</span><span class="lines">@@ -32,6 +32,8 @@
</span><span class="cx"> #include "DOMCoreClasses.h"
</span><span class="cx"> #include "HTMLFrameOwnerElement.h"
</span><span class="cx"> #include "MarshallingHelpers.h"
</span><ins>+#include "PluginDatabase.h"
+#include "PluginView.h"
</ins><span class="cx"> #include "WebActionPropertyBag.h"
</span><span class="cx"> #include "WebChromeClient.h"
</span><span class="cx"> #include "WebDataSource.h"
</span><span class="lines">@@ -85,8 +87,6 @@
</span><span class="cx"> #include <WebCore/Page.h>
</span><span class="cx"> #include <WebCore/PlatformKeyboardEvent.h>
</span><span class="cx"> #include <WebCore/PluginData.h>
</span><del>-#include <WebCore/PluginDatabase.h>
-#include <WebCore/PluginView.h>
</del><span class="cx"> #include <WebCore/PolicyChecker.h>
</span><span class="cx"> #include <WebCore/PrintContext.h>
</span><span class="cx"> #include <WebCore/ResourceHandle.h>
</span></span></pre></div>
<a id="trunkSourceWebKitwinWebViewcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/win/WebView.cpp (178218 => 178219)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/win/WebView.cpp        2015-01-10 00:09:59 UTC (rev 178218)
+++ trunk/Source/WebKit/win/WebView.cpp        2015-01-10 00:16:52 UTC (rev 178219)
</span><span class="lines">@@ -32,6 +32,8 @@
</span><span class="cx"> #include "DOMCoreClasses.h"
</span><span class="cx"> #include "FullscreenVideoController.h"
</span><span class="cx"> #include "MarshallingHelpers.h"
</span><ins>+#include "PluginDatabase.h"
+#include "PluginView.h"
</ins><span class="cx"> #include "ResourceLoadScheduler.h"
</span><span class="cx"> #include "SoftLinking.h"
</span><span class="cx"> #include "SubframeLoader.h"
</span><span class="lines">@@ -127,8 +129,6 @@
</span><span class="cx"> #include <WebCore/PlatformMouseEvent.h>
</span><span class="cx"> #include <WebCore/PlatformWheelEvent.h>
</span><span class="cx"> #include <WebCore/PluginData.h>
</span><del>-#include <WebCore/PluginDatabase.h>
-#include <WebCore/PluginView.h>
</del><span class="cx"> #include <WebCore/PopupMenu.h>
</span><span class="cx"> #include <WebCore/PopupMenuWin.h>
</span><span class="cx"> #include <WebCore/ProgressTracker.h>
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessPluginsunixPluginInfoStoreUnixcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Plugins/unix/PluginInfoStoreUnix.cpp (178218 => 178219)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Plugins/unix/PluginInfoStoreUnix.cpp        2015-01-10 00:09:59 UTC (rev 178218)
+++ trunk/Source/WebKit2/UIProcess/Plugins/unix/PluginInfoStoreUnix.cpp        2015-01-10 00:16:52 UTC (rev 178219)
</span><span class="lines">@@ -32,7 +32,6 @@
</span><span class="cx"> #include "PluginInfoStore.h"
</span><span class="cx">
</span><span class="cx"> #include "NetscapePluginModule.h"
</span><del>-#include "PluginDatabase.h"
</del><span class="cx"> #include <WebCore/FileSystem.h>
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(GTK)
</span></span></pre>
</div>
</div>
</body>
</html>