pewtermoose@webkit.org | fa3bc3f | 2008-02-28 20:46:37 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. |
alp@webkit.org | a55698b | 2008-05-01 18:15:39 +0000 | [diff] [blame] | 3 | * Copyright (C) 2008 Collabora Ltd. All rights reserved. |
zecke@webkit.org | 05363c9 | 2009-05-25 03:28:41 +0000 | [diff] [blame] | 4 | * Copyright (C) 2009 Holger Hans Peter Freyther |
pewtermoose@webkit.org | fa3bc3f | 2008-02-28 20:46:37 +0000 | [diff] [blame] | 5 | * |
| 6 | * Redistribution and use in source and binary forms, with or without |
| 7 | * modification, are permitted provided that the following conditions |
| 8 | * are met: |
| 9 | * 1. Redistributions of source code must retain the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer. |
| 11 | * 2. Redistributions in binary form must reproduce the above copyright |
| 12 | * notice, this list of conditions and the following disclaimer in the |
| 13 | * documentation and/or other materials provided with the distribution. |
| 14 | * |
| 15 | * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
| 16 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 18 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| 19 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 21 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 22 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 23 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
kenneth@webkit.org | 4939593 | 2009-07-28 20:29:19 +0000 | [diff] [blame] | 25 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
pewtermoose@webkit.org | fa3bc3f | 2008-02-28 20:46:37 +0000 | [diff] [blame] | 26 | */ |
| 27 | |
| 28 | #include "config.h" |
| 29 | #include "PluginPackage.h" |
| 30 | |
| 31 | #include "MIMETypeRegistry.h" |
alp@webkit.org | a55698b | 2008-05-01 18:15:39 +0000 | [diff] [blame] | 32 | #include "PluginDatabase.h" |
pewtermoose@webkit.org | fa3bc3f | 2008-02-28 20:46:37 +0000 | [diff] [blame] | 33 | #include "PluginDebug.h" |
| 34 | #include "Timer.h" |
| 35 | #include "npruntime_impl.h" |
alp@webkit.org | a55698b | 2008-05-01 18:15:39 +0000 | [diff] [blame] | 36 | #include <string.h> |
pewtermoose@webkit.org | fa3bc3f | 2008-02-28 20:46:37 +0000 | [diff] [blame] | 37 | #include <wtf/OwnArrayPtr.h> |
barraclough@apple.com | 00b7992 | 2010-03-31 05:44:34 +0000 | [diff] [blame] | 38 | #include <wtf/text/CString.h> |
pewtermoose@webkit.org | fa3bc3f | 2008-02-28 20:46:37 +0000 | [diff] [blame] | 39 | |
| 40 | namespace WebCore { |
| 41 | |
| 42 | PluginPackage::~PluginPackage() |
| 43 | { |
alp@webkit.org | a55698b | 2008-05-01 18:15:39 +0000 | [diff] [blame] | 44 | // This destructor gets called during refresh() if PluginDatabase's |
| 45 | // PluginSet hash is already populated, as it removes items from |
| 46 | // the hash table. Calling the destructor on a loaded plug-in of |
| 47 | // course would cause a crash, so we check to call unload before we |
| 48 | // ASSERT. |
| 49 | // FIXME: There is probably a better way to fix this. |
kenneth@webkit.org | 4939593 | 2009-07-28 20:29:19 +0000 | [diff] [blame] | 50 | if (!m_loadCount) |
alp@webkit.org | a55698b | 2008-05-01 18:15:39 +0000 | [diff] [blame] | 51 | unloadWithoutShutdown(); |
| 52 | else |
| 53 | unload(); |
| 54 | |
pewtermoose@webkit.org | fa3bc3f | 2008-02-28 20:46:37 +0000 | [diff] [blame] | 55 | ASSERT(!m_isLoaded); |
| 56 | } |
| 57 | |
| 58 | void PluginPackage::freeLibrarySoon() |
| 59 | { |
| 60 | ASSERT(!m_freeLibraryTimer.isActive()); |
| 61 | ASSERT(m_module); |
kenneth@webkit.org | 4939593 | 2009-07-28 20:29:19 +0000 | [diff] [blame] | 62 | ASSERT(!m_loadCount); |
pewtermoose@webkit.org | fa3bc3f | 2008-02-28 20:46:37 +0000 | [diff] [blame] | 63 | |
| 64 | m_freeLibraryTimer.startOneShot(0); |
| 65 | } |
| 66 | |
| 67 | void PluginPackage::freeLibraryTimerFired(Timer<PluginPackage>*) |
| 68 | { |
| 69 | ASSERT(m_module); |
kenneth@webkit.org | 4939593 | 2009-07-28 20:29:19 +0000 | [diff] [blame] | 70 | ASSERT(!m_loadCount); |
pewtermoose@webkit.org | fa3bc3f | 2008-02-28 20:46:37 +0000 | [diff] [blame] | 71 | |
| 72 | unloadModule(m_module); |
| 73 | m_module = 0; |
| 74 | } |
| 75 | |
alp@webkit.org | a55698b | 2008-05-01 18:15:39 +0000 | [diff] [blame] | 76 | |
| 77 | int PluginPackage::compare(const PluginPackage& compareTo) const |
| 78 | { |
| 79 | // Sort plug-ins that allow multiple instances first. |
| 80 | bool AallowsMultipleInstances = !quirks().contains(PluginQuirkDontAllowMultipleInstances); |
| 81 | bool BallowsMultipleInstances = !compareTo.quirks().contains(PluginQuirkDontAllowMultipleInstances); |
| 82 | if (AallowsMultipleInstances != BallowsMultipleInstances) |
| 83 | return AallowsMultipleInstances ? -1 : 1; |
| 84 | |
| 85 | // Sort plug-ins in a preferred path first. |
| 86 | bool AisInPreferredDirectory = PluginDatabase::isPreferredPluginDirectory(parentDirectory()); |
| 87 | bool BisInPreferredDirectory = PluginDatabase::isPreferredPluginDirectory(compareTo.parentDirectory()); |
| 88 | if (AisInPreferredDirectory != BisInPreferredDirectory) |
| 89 | return AisInPreferredDirectory ? -1 : 1; |
| 90 | |
| 91 | int diff = strcmp(name().utf8().data(), compareTo.name().utf8().data()); |
| 92 | if (diff) |
| 93 | return diff; |
| 94 | |
staikos@webkit.org | 08b1829 | 2009-03-25 21:31:44 +0000 | [diff] [blame] | 95 | diff = compareFileVersion(compareTo.version()); |
| 96 | if (diff) |
alp@webkit.org | a55698b | 2008-05-01 18:15:39 +0000 | [diff] [blame] | 97 | return diff; |
| 98 | |
| 99 | return strcmp(parentDirectory().utf8().data(), compareTo.parentDirectory().utf8().data()); |
| 100 | } |
| 101 | |
aroben@apple.com | cc718fb | 2008-03-31 16:53:33 +0000 | [diff] [blame] | 102 | PluginPackage::PluginPackage(const String& path, const time_t& lastModified) |
kenneth@webkit.org | bb7c59d | 2009-07-29 14:36:15 +0000 | [diff] [blame] | 103 | : m_isEnabled(true) |
| 104 | , m_isLoaded(false) |
jchaffraix@webkit.org | 660eccc | 2008-05-14 15:50:31 +0000 | [diff] [blame] | 105 | , m_loadCount(0) |
| 106 | , m_path(path) |
pewtermoose@webkit.org | fa3bc3f | 2008-02-28 20:46:37 +0000 | [diff] [blame] | 107 | , m_moduleVersion(0) |
| 108 | , m_module(0) |
| 109 | , m_lastModified(lastModified) |
pewtermoose@webkit.org | fa3bc3f | 2008-02-28 20:46:37 +0000 | [diff] [blame] | 110 | , m_freeLibraryTimer(this, &PluginPackage::freeLibraryTimerFired) |
commit-queue@webkit.org | 67b334a | 2010-08-28 04:32:17 +0000 | [diff] [blame] | 111 | #if ENABLE(NETSCAPE_PLUGIN_METADATA_CACHE) |
| 112 | , m_infoIsFromCache(true) |
| 113 | #endif |
pewtermoose@webkit.org | fa3bc3f | 2008-02-28 20:46:37 +0000 | [diff] [blame] | 114 | { |
| 115 | m_fileName = pathGetFileName(m_path); |
| 116 | m_parentDirectory = m_path.left(m_path.length() - m_fileName.length() - 1); |
| 117 | } |
| 118 | |
| 119 | void PluginPackage::unload() |
| 120 | { |
| 121 | if (!m_isLoaded) |
| 122 | return; |
| 123 | |
| 124 | if (--m_loadCount > 0) |
| 125 | return; |
| 126 | |
| 127 | m_NPP_Shutdown(); |
| 128 | |
| 129 | unloadWithoutShutdown(); |
| 130 | } |
| 131 | |
| 132 | void PluginPackage::unloadWithoutShutdown() |
| 133 | { |
| 134 | if (!m_isLoaded) |
| 135 | return; |
| 136 | |
kenneth@webkit.org | 4939593 | 2009-07-28 20:29:19 +0000 | [diff] [blame] | 137 | ASSERT(!m_loadCount); |
pewtermoose@webkit.org | fa3bc3f | 2008-02-28 20:46:37 +0000 | [diff] [blame] | 138 | ASSERT(m_module); |
| 139 | |
| 140 | // <rdar://5530519>: Crash when closing tab with pdf file (Reader 7 only) |
| 141 | // If the plugin has subclassed its parent window, as with Reader 7, we may have |
| 142 | // gotten here by way of the plugin's internal window proc forwarding a message to our |
| 143 | // original window proc. If we free the plugin library from here, we will jump back |
| 144 | // to code we just freed when we return, so delay calling FreeLibrary at least until |
| 145 | // the next message loop |
| 146 | freeLibrarySoon(); |
| 147 | |
| 148 | m_isLoaded = false; |
| 149 | } |
| 150 | |
kenneth@webkit.org | bb7c59d | 2009-07-29 14:36:15 +0000 | [diff] [blame] | 151 | void PluginPackage::setEnabled(bool enabled) |
| 152 | { |
| 153 | m_isEnabled = enabled; |
| 154 | } |
| 155 | |
aroben@apple.com | cc718fb | 2008-03-31 16:53:33 +0000 | [diff] [blame] | 156 | PassRefPtr<PluginPackage> PluginPackage::createPackage(const String& path, const time_t& lastModified) |
pewtermoose@webkit.org | fa3bc3f | 2008-02-28 20:46:37 +0000 | [diff] [blame] | 157 | { |
aroben@apple.com | 7cc6f85 | 2008-03-31 16:52:39 +0000 | [diff] [blame] | 158 | RefPtr<PluginPackage> package = adoptRef(new PluginPackage(path, lastModified)); |
pewtermoose@webkit.org | fa3bc3f | 2008-02-28 20:46:37 +0000 | [diff] [blame] | 159 | |
aroben@apple.com | 7cc6f85 | 2008-03-31 16:52:39 +0000 | [diff] [blame] | 160 | if (!package->fetchInfo()) |
pewtermoose@webkit.org | fa3bc3f | 2008-02-28 20:46:37 +0000 | [diff] [blame] | 161 | return 0; |
hausmann@webkit.org | 49f9766 | 2008-11-05 15:31:10 +0000 | [diff] [blame] | 162 | |
aroben@apple.com | 7cc6f85 | 2008-03-31 16:52:39 +0000 | [diff] [blame] | 163 | return package.release(); |
pewtermoose@webkit.org | fa3bc3f | 2008-02-28 20:46:37 +0000 | [diff] [blame] | 164 | } |
| 165 | |
commit-queue@webkit.org | 67b334a | 2010-08-28 04:32:17 +0000 | [diff] [blame] | 166 | #if ENABLE(NETSCAPE_PLUGIN_METADATA_CACHE) |
| 167 | PassRefPtr<PluginPackage> PluginPackage::createPackageFromCache(const String& path, const time_t& lastModified, const String& name, const String& description, const String& mimeDescription) |
| 168 | { |
| 169 | RefPtr<PluginPackage> package = adoptRef(new PluginPackage(path, lastModified)); |
| 170 | package->m_name = name; |
| 171 | package->m_description = description; |
| 172 | package->determineModuleVersionFromDescription(); |
| 173 | package->setMIMEDescription(mimeDescription); |
| 174 | package->m_infoIsFromCache = true; |
| 175 | return package.release(); |
| 176 | } |
| 177 | #endif |
| 178 | |
hausmann@webkit.org | 49f9766 | 2008-11-05 15:31:10 +0000 | [diff] [blame] | 179 | #if defined(XP_UNIX) |
| 180 | void PluginPackage::determineQuirks(const String& mimeType) |
| 181 | { |
| 182 | if (MIMETypeRegistry::isJavaAppletMIMEType(mimeType)) { |
| 183 | // Because a single process cannot create multiple VMs, and we cannot reliably unload a |
| 184 | // Java VM, we cannot unload the Java plugin, or we'll lose reference to our only VM |
| 185 | m_quirks.add(PluginQuirkDontUnloadPlugin); |
| 186 | |
| 187 | // Setting the window region to an empty region causes bad scrolling repaint problems |
| 188 | // with the Java plug-in. |
| 189 | m_quirks.add(PluginQuirkDontClipToZeroRectWhenScrolling); |
| 190 | return; |
| 191 | } |
| 192 | |
| 193 | if (mimeType == "application/x-shockwave-flash") { |
| 194 | static const PlatformModuleVersion flashTenVersion(0x0a000000); |
| 195 | |
| 196 | if (compareFileVersion(flashTenVersion) >= 0) { |
| 197 | // Flash 10.0 b218 doesn't like having a NULL window handle |
| 198 | m_quirks.add(PluginQuirkDontSetNullWindowHandleOnDestroy); |
hausmann@webkit.org | f9c8873 | 2008-11-05 15:31:22 +0000 | [diff] [blame] | 199 | #if PLATFORM(QT) |
| 200 | m_quirks.add(PluginQuirkRequiresGtkToolKit); |
| 201 | #endif |
hausmann@webkit.org | 49f9766 | 2008-11-05 15:31:10 +0000 | [diff] [blame] | 202 | } else { |
| 203 | // Flash 9 and older requests windowless plugins if we return a mozilla user agent |
| 204 | m_quirks.add(PluginQuirkWantsMozillaUserAgent); |
| 205 | } |
| 206 | |
andreas.kling@nokia.com | 973afea | 2010-10-05 21:41:41 +0000 | [diff] [blame] | 207 | #if PLATFORM(QT) |
| 208 | // Flash will crash on repeated calls to SetWindow in windowed mode |
andreas.kling@nokia.com | c16990f | 2010-09-27 11:45:31 +0000 | [diff] [blame] | 209 | m_quirks.add(PluginQuirkDontCallSetWindowMoreThanOnce); |
mrobinson@webkit.org | 1da881f | 2011-11-18 06:09:25 +0000 | [diff] [blame] | 210 | #endif |
girish@forwardbias.in | 6ec53c4 | 2010-10-12 21:12:27 +0000 | [diff] [blame] | 211 | |
| 212 | #if CPU(X86_64) |
| 213 | // 64-bit Flash freezes if right-click is sent in windowless mode |
| 214 | m_quirks.add(PluginQuirkIgnoreRightClickInWindowlessMode); |
| 215 | #endif |
andreas.kling@nokia.com | c16990f | 2010-09-27 11:45:31 +0000 | [diff] [blame] | 216 | |
girish@forwardbias.in | 82054cb | 2010-08-17 18:39:54 +0000 | [diff] [blame] | 217 | m_quirks.add(PluginQuirkRequiresDefaultScreenDepth); |
hausmann@webkit.org | 49f9766 | 2008-11-05 15:31:10 +0000 | [diff] [blame] | 218 | m_quirks.add(PluginQuirkThrottleInvalidate); |
| 219 | m_quirks.add(PluginQuirkThrottleWMUserPlusOneMessages); |
| 220 | m_quirks.add(PluginQuirkFlashURLNotifyBug); |
| 221 | } |
| 222 | } |
| 223 | #endif |
| 224 | |
mjs@apple.com | acbcc28 | 2010-01-05 08:58:28 +0000 | [diff] [blame] | 225 | #if !OS(WINDOWS) |
hausmann@webkit.org | 49f9766 | 2008-11-05 15:31:10 +0000 | [diff] [blame] | 226 | void PluginPackage::determineModuleVersionFromDescription() |
| 227 | { |
| 228 | // It's a bit lame to detect the plugin version by parsing it |
| 229 | // from the plugin description string, but it doesn't seem that |
| 230 | // version information is available in any standardized way at |
| 231 | // the module level, like in Windows |
| 232 | |
| 233 | if (m_description.isEmpty()) |
| 234 | return; |
| 235 | |
| 236 | if (m_description.startsWith("Shockwave Flash") && m_description.length() >= 19) { |
| 237 | // The flash version as a PlatformModuleVersion differs on Unix from Windows |
| 238 | // since the revision can be larger than a 8 bits, so we allow it 16 here and |
| 239 | // push the major/minor up 8 bits. Thus on Unix, Flash's version may be |
| 240 | // 0x0a000000 instead of 0x000a0000. |
| 241 | |
| 242 | Vector<String> versionParts; |
| 243 | m_description.substring(16).split(' ', /*allowEmptyEntries =*/ false, versionParts); |
| 244 | if (versionParts.isEmpty()) |
| 245 | return; |
| 246 | |
| 247 | if (versionParts.size() >= 1) { |
| 248 | Vector<String> majorMinorParts; |
| 249 | versionParts[0].split('.', majorMinorParts); |
| 250 | if (majorMinorParts.size() >= 1) { |
| 251 | bool converted = false; |
| 252 | unsigned major = majorMinorParts[0].toUInt(&converted); |
| 253 | if (converted) |
| 254 | m_moduleVersion = (major & 0xff) << 24; |
| 255 | } |
| 256 | if (majorMinorParts.size() == 2) { |
| 257 | bool converted = false; |
| 258 | unsigned minor = majorMinorParts[1].toUInt(&converted); |
| 259 | if (converted) |
| 260 | m_moduleVersion |= (minor & 0xff) << 16; |
| 261 | } |
| 262 | } |
| 263 | |
| 264 | if (versionParts.size() >= 2) { |
| 265 | String revision = versionParts[1]; |
| 266 | if (revision.length() > 1 && (revision[0] == 'r' || revision[0] == 'b')) { |
| 267 | revision.remove(0, 1); |
| 268 | m_moduleVersion |= revision.toInt() & 0xffff; |
| 269 | } |
| 270 | } |
| 271 | } |
| 272 | } |
sfalken@apple.com | 206de2b | 2008-11-05 18:23:10 +0000 | [diff] [blame] | 273 | #endif |
hausmann@webkit.org | 49f9766 | 2008-11-05 15:31:10 +0000 | [diff] [blame] | 274 | |
ariya@webkit.org | 32c4356 | 2009-06-08 12:05:46 +0000 | [diff] [blame] | 275 | #if ENABLE(NETSCAPE_PLUGIN_API) |
zecke@webkit.org | 05363c9 | 2009-05-25 03:28:41 +0000 | [diff] [blame] | 276 | void PluginPackage::initializeBrowserFuncs() |
| 277 | { |
| 278 | memset(&m_browserFuncs, 0, sizeof(m_browserFuncs)); |
kenneth@webkit.org | 4939593 | 2009-07-28 20:29:19 +0000 | [diff] [blame] | 279 | m_browserFuncs.size = sizeof(m_browserFuncs); |
xan@webkit.org | b77d55e | 2010-02-18 08:06:03 +0000 | [diff] [blame] | 280 | m_browserFuncs.version = NPVersion(); |
zecke@webkit.org | 05363c9 | 2009-05-25 03:28:41 +0000 | [diff] [blame] | 281 | |
| 282 | m_browserFuncs.geturl = NPN_GetURL; |
| 283 | m_browserFuncs.posturl = NPN_PostURL; |
| 284 | m_browserFuncs.requestread = NPN_RequestRead; |
| 285 | m_browserFuncs.newstream = NPN_NewStream; |
| 286 | m_browserFuncs.write = NPN_Write; |
| 287 | m_browserFuncs.destroystream = NPN_DestroyStream; |
| 288 | m_browserFuncs.status = NPN_Status; |
| 289 | m_browserFuncs.uagent = NPN_UserAgent; |
| 290 | m_browserFuncs.memalloc = NPN_MemAlloc; |
| 291 | m_browserFuncs.memfree = NPN_MemFree; |
| 292 | m_browserFuncs.memflush = NPN_MemFlush; |
| 293 | m_browserFuncs.reloadplugins = NPN_ReloadPlugins; |
| 294 | m_browserFuncs.geturlnotify = NPN_GetURLNotify; |
| 295 | m_browserFuncs.posturlnotify = NPN_PostURLNotify; |
| 296 | m_browserFuncs.getvalue = NPN_GetValue; |
| 297 | m_browserFuncs.setvalue = NPN_SetValue; |
| 298 | m_browserFuncs.invalidaterect = NPN_InvalidateRect; |
| 299 | m_browserFuncs.invalidateregion = NPN_InvalidateRegion; |
| 300 | m_browserFuncs.forceredraw = NPN_ForceRedraw; |
| 301 | m_browserFuncs.getJavaEnv = NPN_GetJavaEnv; |
| 302 | m_browserFuncs.getJavaPeer = NPN_GetJavaPeer; |
| 303 | m_browserFuncs.pushpopupsenabledstate = NPN_PushPopupsEnabledState; |
| 304 | m_browserFuncs.poppopupsenabledstate = NPN_PopPopupsEnabledState; |
| 305 | m_browserFuncs.pluginthreadasynccall = NPN_PluginThreadAsyncCall; |
| 306 | |
| 307 | m_browserFuncs.releasevariantvalue = _NPN_ReleaseVariantValue; |
| 308 | m_browserFuncs.getstringidentifier = _NPN_GetStringIdentifier; |
| 309 | m_browserFuncs.getstringidentifiers = _NPN_GetStringIdentifiers; |
| 310 | m_browserFuncs.getintidentifier = _NPN_GetIntIdentifier; |
| 311 | m_browserFuncs.identifierisstring = _NPN_IdentifierIsString; |
| 312 | m_browserFuncs.utf8fromidentifier = _NPN_UTF8FromIdentifier; |
| 313 | m_browserFuncs.intfromidentifier = _NPN_IntFromIdentifier; |
| 314 | m_browserFuncs.createobject = _NPN_CreateObject; |
| 315 | m_browserFuncs.retainobject = _NPN_RetainObject; |
| 316 | m_browserFuncs.releaseobject = _NPN_ReleaseObject; |
| 317 | m_browserFuncs.invoke = _NPN_Invoke; |
| 318 | m_browserFuncs.invokeDefault = _NPN_InvokeDefault; |
| 319 | m_browserFuncs.evaluate = _NPN_Evaluate; |
| 320 | m_browserFuncs.getproperty = _NPN_GetProperty; |
| 321 | m_browserFuncs.setproperty = _NPN_SetProperty; |
| 322 | m_browserFuncs.removeproperty = _NPN_RemoveProperty; |
| 323 | m_browserFuncs.hasproperty = _NPN_HasProperty; |
| 324 | m_browserFuncs.hasmethod = _NPN_HasMethod; |
| 325 | m_browserFuncs.setexception = _NPN_SetException; |
| 326 | m_browserFuncs.enumerate = _NPN_Enumerate; |
| 327 | m_browserFuncs.construct = _NPN_Construct; |
commit-queue@webkit.org | 4d93a97 | 2010-10-14 22:16:34 +0000 | [diff] [blame] | 328 | m_browserFuncs.getvalueforurl = NPN_GetValueForURL; |
| 329 | m_browserFuncs.setvalueforurl = NPN_SetValueForURL; |
| 330 | m_browserFuncs.getauthenticationinfo = NPN_GetAuthenticationInfo; |
zecke@webkit.org | 05363c9 | 2009-05-25 03:28:41 +0000 | [diff] [blame] | 331 | } |
ariya@webkit.org | 32c4356 | 2009-06-08 12:05:46 +0000 | [diff] [blame] | 332 | #endif |
zecke@webkit.org | 05363c9 | 2009-05-25 03:28:41 +0000 | [diff] [blame] | 333 | |
zecke@webkit.org | 7d1101b | 2009-05-25 03:29:06 +0000 | [diff] [blame] | 334 | #if ENABLE(PLUGIN_PACKAGE_SIMPLE_HASH) |
| 335 | unsigned PluginPackage::hash() const |
| 336 | { |
alexis.menard@openbossa.org | 6a598cf | 2011-05-10 15:25:02 +0000 | [diff] [blame] | 337 | struct HashCodes { |
| 338 | unsigned hash; |
| 339 | time_t modifiedDate; |
| 340 | } hashCodes; |
zecke@webkit.org | 7d1101b | 2009-05-25 03:29:06 +0000 | [diff] [blame] | 341 | |
alexis.menard@openbossa.org | 6a598cf | 2011-05-10 15:25:02 +0000 | [diff] [blame] | 342 | hashCodes.hash = m_path.impl()->hash(); |
| 343 | hashCodes.modifiedDate = m_lastModified; |
| 344 | |
| 345 | return StringHasher::hashMemory<sizeof(hashCodes)>(&hashCodes); |
zecke@webkit.org | 7d1101b | 2009-05-25 03:29:06 +0000 | [diff] [blame] | 346 | } |
| 347 | |
| 348 | bool PluginPackage::equal(const PluginPackage& a, const PluginPackage& b) |
| 349 | { |
| 350 | return a.m_description == b.m_description; |
| 351 | } |
eric@webkit.org | e0fc95d | 2009-10-27 10:17:36 +0000 | [diff] [blame] | 352 | #endif |
zecke@webkit.org | 7d1101b | 2009-05-25 03:29:06 +0000 | [diff] [blame] | 353 | |
| 354 | int PluginPackage::compareFileVersion(const PlatformModuleVersion& compareVersion) const |
| 355 | { |
| 356 | // return -1, 0, or 1 if plug-in version is less than, equal to, or greater than |
| 357 | // the passed version |
eric@webkit.org | e0fc95d | 2009-10-27 10:17:36 +0000 | [diff] [blame] | 358 | |
mjs@apple.com | acbcc28 | 2010-01-05 08:58:28 +0000 | [diff] [blame] | 359 | #if OS(WINDOWS) |
eric@webkit.org | e0fc95d | 2009-10-27 10:17:36 +0000 | [diff] [blame] | 360 | if (m_moduleVersion.mostSig != compareVersion.mostSig) |
| 361 | return m_moduleVersion.mostSig > compareVersion.mostSig ? 1 : -1; |
| 362 | if (m_moduleVersion.leastSig != compareVersion.leastSig) |
| 363 | return m_moduleVersion.leastSig > compareVersion.leastSig ? 1 : -1; |
| 364 | #else |
zecke@webkit.org | 7d1101b | 2009-05-25 03:29:06 +0000 | [diff] [blame] | 365 | if (m_moduleVersion != compareVersion) |
| 366 | return m_moduleVersion > compareVersion ? 1 : -1; |
eric@webkit.org | e0fc95d | 2009-10-27 10:17:36 +0000 | [diff] [blame] | 367 | #endif |
| 368 | |
zecke@webkit.org | 7d1101b | 2009-05-25 03:29:06 +0000 | [diff] [blame] | 369 | return 0; |
| 370 | } |
zecke@webkit.org | 7d1101b | 2009-05-25 03:29:06 +0000 | [diff] [blame] | 371 | |
commit-queue@webkit.org | 67b334a | 2010-08-28 04:32:17 +0000 | [diff] [blame] | 372 | #if ENABLE(NETSCAPE_PLUGIN_METADATA_CACHE) |
| 373 | bool PluginPackage::ensurePluginLoaded() |
| 374 | { |
| 375 | if (!m_infoIsFromCache) |
| 376 | return m_isLoaded; |
| 377 | |
| 378 | m_quirks = PluginQuirkSet(); |
| 379 | m_name = String(); |
| 380 | m_description = String(); |
| 381 | m_fullMIMEDescription = String(); |
| 382 | m_moduleVersion = 0; |
| 383 | |
| 384 | return fetchInfo(); |
| 385 | } |
| 386 | #endif |
| 387 | |
pewtermoose@webkit.org | fa3bc3f | 2008-02-28 20:46:37 +0000 | [diff] [blame] | 388 | } |