Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Feb 26th, 2012  |  syntax: None  |  size: 13.06 KB  |  views: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
  2. index 9fb1e54..ed6f3ca 100644
  3. --- a/WebCore/ChangeLog
  4. +++ b/WebCore/ChangeLog
  5. @@ -1,3 +1,26 @@
  6. +2010-09-23  Balazs Kelemen  <kbalazs@webkit.org>
  7. +
  8. +        Reviewed by NOBODY (OOPS!).
  9. +
  10. +        [Qt] [WebKit2] Workarounds for the flash plugin
  11. +        https://bugs.webkit.org/show_bug.cgi?id=46262
  12. +        No new functionality so no new tests.
  13. +
  14. +        Factoring the logic in PluginPackageQt.cpp
  15. +        that deals with workarounding problems with the flash
  16. +        plugin into a new class with static methods.
  17. +        * WebCore.pro:
  18. +        * plugins/qt/FlashPluginWorkarounds.cpp: Added.
  19. +        (WebCore::FlashPluginWorkarounds::isFlashPlugin):
  20. +        (WebCore::FlashPluginWorkarounds::isFlashPluginNPWrapper):
  21. +        (WebCore::FlashPluginWorkarounds::initializeGTK):
  22. +        * plugins/qt/FlashPluginWorkarounds.h: Added.
  23. +        * plugins/qt/PluginPackageQt.cpp: Removed the static function we used to
  24. +        override NPN_GetValue for the npwrapper. That was redundant since we can
  25. +        achieve the same effect by setting the appropriate quirk.
  26. +        (WebCore::PluginPackage::load): Set the PluginQuirkRequiresGtkToolKit
  27. +        quirk if we are dealing with the npwrapper.
  28. +
  29.  2010-10-19  Philippe Normand  <pnormand@igalia.com>
  30.  
  31.          Reviewed by Xan Lopez.
  32. diff --git a/WebCore/WebCore.pro b/WebCore/WebCore.pro
  33. index a964d89..3940997 100644
  34. --- a/WebCore/WebCore.pro
  35. +++ b/WebCore/WebCore.pro
  36. @@ -2764,10 +2764,12 @@ contains(DEFINES, ENABLE_NETSCAPE_PLUGIN_API=1) {
  37.                      DEFINES += MOZ_PLATFORM_MAEMO=6
  38.                  }
  39.                  SOURCES += \
  40. +                    plugins/qt/PluginQuirks.cpp \
  41.                      plugins/qt/PluginContainerQt.cpp \
  42.                      plugins/qt/PluginPackageQt.cpp \
  43.                      plugins/qt/PluginViewQt.cpp
  44.                  HEADERS += \
  45. +                    plugins/qt/PluginQuirks.h \
  46.                      plugins/qt/PluginContainerQt.h
  47.                  DEFINES += XP_UNIX
  48.                  DEFINES += ENABLE_NETSCAPE_PLUGIN_METADATA_CACHE=1
  49. diff --git a/WebCore/plugins/qt/PluginPackageQt.cpp b/WebCore/plugins/qt/PluginPackageQt.cpp
  50. index e7058c7..4f82c43 100644
  51. --- a/WebCore/plugins/qt/PluginPackageQt.cpp
  52. +++ b/WebCore/plugins/qt/PluginPackageQt.cpp
  53. @@ -1,6 +1,7 @@
  54.  /*
  55.   * Copyright (C) 2006, 2007 Apple Inc.  All rights reserved.
  56.   * Copyright (C) 2008 Collabora Ltd. All rights reserved.
  57. + * Copyright (C) 2010 University of Szeged. All rights reserved.
  58.   *
  59.   * Redistribution and use in source and binary forms, with or without
  60.   * modification, are permitted provided that the following conditions
  61. @@ -31,6 +32,7 @@
  62.  #include "npruntime_impl.h"
  63.  #include "PluginDatabase.h"
  64.  #include "PluginDebug.h"
  65. +#include "PluginQuirks.h"
  66.  #include <wtf/text/CString.h>
  67.  
  68.  namespace WebCore {
  69. @@ -88,49 +90,6 @@ void PluginPackage::setMIMEDescription(const String& mimeDescription)
  70.      }
  71.  }
  72.  
  73. -static NPError staticPluginQuirkRequiresGtkToolKit_NPN_GetValue(NPP instance, NPNVariable variable, void* value)
  74. -{
  75. -    if (variable == NPNVToolkit) {
  76. -        *static_cast<uint32_t*>(value) = 2;
  77. -        return NPERR_NO_ERROR;
  78. -    }
  79. -
  80. -    return NPN_GetValue(instance, variable, value);
  81. -}
  82. -
  83. -static void initializeGtk(QLibrary* module = 0)
  84. -{
  85. -    // Ensures missing Gtk initialization in some versions of Adobe's flash player
  86. -    // plugin do not cause crashes. See BR# 40567, 44324, and 44405 for details.  
  87. -    if (module) {
  88. -        typedef void *(*gtk_init_ptr)(int*, char***);
  89. -        gtk_init_ptr gtkInit = (gtk_init_ptr)module->resolve("gtk_init");
  90. -        if (gtkInit) {
  91. -            // Prevent gtk_init() from replacing the X error handlers, since the Gtk
  92. -            // handlers abort when they receive an X error, thus killing the viewer.
  93. -#ifdef Q_WS_X11
  94. -            int (*old_error_handler)(Display*, XErrorEvent*) = XSetErrorHandler(0);
  95. -            int (*old_io_error_handler)(Display*) = XSetIOErrorHandler(0);
  96. -#endif
  97. -            gtkInit(0, 0);
  98. -#ifdef Q_WS_X11
  99. -            XSetErrorHandler(old_error_handler);
  100. -            XSetIOErrorHandler(old_io_error_handler);
  101. -#endif
  102. -            return;
  103. -        }
  104. -    }
  105. -
  106. -    QLibrary library("libgtk-x11-2.0.so.0");
  107. -    if (library.load()) {
  108. -        typedef void *(*gtk_init_check_ptr)(int*, char***);
  109. -        gtk_init_check_ptr gtkInitCheck = (gtk_init_check_ptr)library.resolve("gtk_init_check");
  110. -        // NOTE: We're using gtk_init_check() since gtk_init() calls exit() on failure.
  111. -        if (gtkInitCheck)
  112. -            (void) gtkInitCheck(0, 0);
  113. -    }
  114. -}
  115. -
  116.  bool PluginPackage::load()
  117.  {
  118.      if (m_isLoaded) {
  119. @@ -162,17 +121,17 @@ bool PluginPackage::load()
  120.  
  121.      initializeBrowserFuncs();
  122.  
  123. -    if (m_path.contains("npwrapper.")) {
  124. +    if (FlashPluginWorkarounds::isFlashPluginNPWrapper(m_path)) {
  125.          // nspluginwrapper relies on the toolkit value to know if glib is available
  126.          // It does so in NP_Initialize with a null instance, therefore it is done this way:
  127. -        m_browserFuncs.getvalue = staticPluginQuirkRequiresGtkToolKit_NPN_GetValue;
  128. +        m_quirks.add(PluginQuirkRequiresGtkToolKit);
  129.          // Workaround Adobe's failure to properly initialize Gtk in some versions
  130.          // of their flash player plugin.
  131. -        initializeGtk();
  132. -    } else if (m_path.contains("flashplayer")) {
  133. +        FlashPluginWorkarounds::initializeGTK();
  134. +    } else if (FlashPluginWorkarounds::isFlashPlugin(m_path)) {
  135.          // Workaround Adobe's failure to properly initialize Gtk in some versions
  136.          // of their flash player plugin.
  137. -        initializeGtk(m_module);
  138. +        FlashPluginWorkarounds::initializeGTK(m_module);
  139.      }
  140.  
  141.  #if defined(XP_UNIX)
  142. diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
  143. index b83dc19..8b169ff 100644
  144. --- a/WebKit2/ChangeLog
  145. +++ b/WebKit2/ChangeLog
  146. @@ -1,3 +1,28 @@
  147. +2010-09-23  Balazs Kelemen  <kbalazs@webkit.org>
  148. +
  149. +        Reviewed by NOBODY (OOPS!).
  150. +
  151. +        [Qt] [WebKit2] Workarounds for the flash plugin
  152. +        https://bugs.webkit.org/show_bug.cgi?id=46262
  153. +
  154. +        Apply the same workarounds for the flash plugin
  155. +        that we use in WebCore.
  156. +        * Platform/qt/ModuleQt.cpp:
  157. +        (WebKit::Module::load): Use the ResolveAllSymbolsHint
  158. +        hint when we loading the library as we do in WebCore.
  159. +        * WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp:
  160. +        (WebKit::NPN_GetValue): Applying the workaround we use in WebCore
  161. +        for the flash plugin npwrapper.
  162. +        * WebProcess/Plugins/Netscape/NetscapePlugin.h:
  163. +        (WebKit::NetscapePlugin::quirks): Added a PluginQuirkSet
  164. +        member for Qt and a getter.
  165. +        * WebProcess/Plugins/Netscape/NetscapePluginModule.h:
  166. +        (WebKit::NetscapePluginModule::path): Added getter for the path.
  167. +        We need it in NetscapePlugin::platformPostInitialize.
  168. +        * WebProcess/Plugins/Netscape/qt/NetscapePluginQt.cpp:
  169. +        (WebKit::NetscapePlugin::platformPostInitialize): Applying the
  170. +        workarounds we use in WebCore for the flash plugin and the npwrapper.
  171. +
  172.  2010-10-18  Anders Carlsson  <andersca@apple.com>
  173.  
  174.          Reviewed by Sam Weinig.
  175. diff --git a/WebKit2/Platform/qt/ModuleQt.cpp b/WebKit2/Platform/qt/ModuleQt.cpp
  176. index 8a68cf4..b195f72 100644
  177. --- a/WebKit2/Platform/qt/ModuleQt.cpp
  178. +++ b/WebKit2/Platform/qt/ModuleQt.cpp
  179. @@ -26,11 +26,14 @@
  180.  
  181.  #include "Module.h"
  182.  
  183. +#include <cstdio>
  184. +
  185.  namespace WebKit {
  186.  
  187.  bool Module::load()
  188.  {
  189.      m_lib.setFileName(static_cast<QString>(m_path));
  190. +    m_lib.setLoadHints(QLibrary::ResolveAllSymbolsHint);
  191.      return m_lib.load();
  192.  }
  193.  
  194. diff --git a/WebKit2/UIProcess/Plugins/qt/PluginInfoStoreQt.cpp b/WebKit2/UIProcess/Plugins/qt/PluginInfoStoreQt.cpp
  195. index 3e50da0..e71a9dd 100644
  196. --- a/WebKit2/UIProcess/Plugins/qt/PluginInfoStoreQt.cpp
  197. +++ b/WebKit2/UIProcess/Plugins/qt/PluginInfoStoreQt.cpp
  198. @@ -72,18 +72,20 @@ bool PluginInfoStore::getPluginInfo(const String& pluginPath, Plugin& plugin)
  199.  
  200.      const MIMEToDescriptionsMap& descriptions = package->mimeToDescriptions();
  201.      const MIMEToExtensionsMap& extensions = package->mimeToExtensions();
  202. -    Vector<MimeClassInfo> mimes(descriptions.size());
  203.      MIMEToDescriptionsMap::const_iterator descEnd = descriptions.end();
  204. -    unsigned i = 0;
  205. +    plugin.info.mimes.reserveCapacity(descriptions.size());
  206.      for (MIMEToDescriptionsMap::const_iterator it = descriptions.begin(); it != descEnd; ++it) {
  207. -        MimeClassInfo& mime = mimes[i++];
  208. +        MimeClassInfo mime;
  209.          mime.type = it->first;
  210.          mime.desc = it->second;
  211.          MIMEToExtensionsMap::const_iterator extensionIt = extensions.find(it->first);
  212.          ASSERT(extensionIt != extensions.end());
  213.          mime.extensions = extensionIt->second;
  214. +        plugin.info.mimes.uncheckedAppend(mime);
  215.      }
  216.  
  217. +    printf("found plugin: %s\n", qPrintable(static_cast<QString>(pluginPath)));
  218. +
  219.      package->unload();
  220.      return true;
  221.  }
  222. diff --git a/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp b/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp
  223. index c5c705b..df76767 100644
  224. --- a/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp
  225. +++ b/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp
  226. @@ -455,6 +455,14 @@ static NPError NPN_GetValue(NPP npp, NPNVariable variable, void *value)
  227.         case NPNVSupportsWindowless:
  228.             *(NPBool*)value = true;
  229.             break;
  230. +#elif PLATFORM(QT)
  231. +        case NPNVToolkit: {
  232. +            RefPtr<NetscapePlugin> plugin = NetscapePlugin::fromNPP(npp);
  233. +
  234. +            if (plugin->quirks().contains(PluginQuirkRequiresGtkToolKit))
  235. +                *reinterpret_cast<uint32_t*>(value) = 2;
  236. +            break;
  237. +        }
  238.  #endif
  239.          default:
  240.              notImplemented();
  241. diff --git a/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h b/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h
  242. index c9ab440..a4c38a3 100644
  243. --- a/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h
  244. +++ b/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h
  245. @@ -31,6 +31,7 @@
  246.  #include "RunLoop.h"
  247.  #include <WebCore/GraphicsLayer.h>
  248.  #include <WebCore/IntRect.h>
  249. +#include <WebCore/PluginQuirkSet.h>
  250.  #include <wtf/HashMap.h>
  251.  #include <wtf/text/CString.h>
  252.  #include <wtf/text/StringHash.h>
  253. @@ -73,6 +74,7 @@ public:
  254.      static void setException(const String&);
  255.      bool evaluate(NPObject*, const String&scriptString, NPVariant* result);
  256.      bool isPrivateBrowsingEnabled();
  257. +    WebCore::PluginQuirkSet quirks() const { return m_quirks; }
  258.  
  259.      // These return retained objects.
  260.      NPObject* windowScriptNPObject();
  261. @@ -186,6 +188,8 @@ private:
  262.      bool m_loadManually;
  263.      RefPtr<NetscapePluginStream> m_manualStream;
  264.  
  265. +    WebCore::PluginQuirkSet m_quirks;
  266. +
  267.  #if PLATFORM(MAC)
  268.      NPDrawingModel m_drawingModel;
  269.      NPEventModel m_eventModel;
  270. diff --git a/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginModule.cpp b/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginModule.cpp
  271. index b7d4a8e..0d2be45 100644
  272. --- a/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginModule.cpp
  273. +++ b/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginModule.cpp
  274. @@ -141,6 +141,9 @@ bool NetscapePluginModule::tryLoad()
  275.  #elif PLATFORM(WIN)
  276.      if (getEntryPointsFuncPtr(&m_pluginFuncs) != NPERR_NO_ERROR || initializeFuncPtr(netscapeBrowserFuncs()) != NPERR_NO_ERROR)
  277.          return false;
  278. +#elif PLATFORM(QT)
  279. +    if (initializeFuncPtr(browserFuncs, &m_pluginFuncs) != NPERR_NO_ERROR)
  280. +        return false;
  281.  #endif
  282.  
  283.      return true;
  284. diff --git a/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginModule.h b/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginModule.h
  285. index e495242..586bd13 100644
  286. --- a/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginModule.h
  287. +++ b/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginModule.h
  288. @@ -43,6 +43,8 @@ public:
  289.      void pluginCreated();
  290.      void pluginDestroyed();
  291.  
  292. +    String path() const { return m_pluginPath; }
  293. +
  294.  private:
  295.      explicit NetscapePluginModule(const String& pluginPath);
  296.  
  297. diff --git a/WebKit2/WebProcess/Plugins/Netscape/qt/NetscapePluginQt.cpp b/WebKit2/WebProcess/Plugins/Netscape/qt/NetscapePluginQt.cpp
  298. index 206859a..7137bbe 100644
  299. --- a/WebKit2/WebProcess/Plugins/Netscape/qt/NetscapePluginQt.cpp
  300. +++ b/WebKit2/WebProcess/Plugins/Netscape/qt/NetscapePluginQt.cpp
  301. @@ -28,15 +28,36 @@
  302.  
  303.  #include "NotImplemented.h"
  304.  #include "WebEvent.h"
  305. +#include <WebCore/PluginQuirks.h>
  306.  #include <WebCore/GraphicsContext.h>
  307.  
  308.  using namespace WebCore;
  309.  
  310.  namespace WebKit {
  311.  
  312. +bool NetscapePlugin::platformPreInitialize()
  313. +{
  314. +    // nspluginwrapper relies on the toolkit value to know if glib is available.
  315. +    if (PluginQuirks::isNPWrapper(m_pluginModule->path()))
  316. +        m_quirks.add(PluginQuirkRequiresGtkToolKit);
  317. +
  318. +    return true;
  319. +}
  320. +
  321.  bool NetscapePlugin::platformPostInitialize()
  322.  {
  323. -    notImplemented();
  324. +    // Workaround Adobe's failure to properly initialize Gtk
  325. +    // in some versions of their flash player plugin.
  326. +    if (PluginQuirks::isFlashPlugin(m_pluginModule->path())) {
  327. +        // We have already loaded the plugin but initializeGTK
  328. +        // needs a QLibrary for resolving gtk_init.
  329. +        QLibrary flashPlugin(m_pluginModule->path());
  330. +        if (!flashPlugin.load())
  331. +            return false;
  332. +
  333. +        PluginQuirks::initializeGTK(&flashPlugin);
  334. +    }
  335. +
  336.      return true;
  337.  }
clone this paste RAW Paste Data