Title: [124259] trunk/Source/WebKit2
Revision
124259
Author
ander...@apple.com
Date
2012-07-31 15:44:53 -0700 (Tue, 31 Jul 2012)

Log Message

Prefer the Oracle Java plug-in over the Apple Java plug-in
https://bugs.webkit.org/show_bug.cgi?id=92780

Reviewed by Oliver Hunt.

* UIProcess/Plugins/mac/PluginInfoStoreMac.mm:
(WebKit::findPluginWithBundleIdentifier):
Add a new helper for finding a plug-in with the given bundle identifier.

(WebKit::checkForPreferredPlugin):
Helper function for making sure that an old plug-in is never loaded if a new plug-in is found, and that the old plug-in
is removed from the list of loaded plug-ins if the new plug-in is found.

(WebKit::PluginInfoStore::shouldUsePlugin):
Prefer the Oracle Java plug-in over the Apple Java plug-in.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (124258 => 124259)


--- trunk/Source/WebKit2/ChangeLog	2012-07-31 22:36:20 UTC (rev 124258)
+++ trunk/Source/WebKit2/ChangeLog	2012-07-31 22:44:53 UTC (rev 124259)
@@ -1,3 +1,21 @@
+2012-07-31  Anders Carlsson  <ander...@apple.com>
+
+        Prefer the Oracle Java plug-in over the Apple Java plug-in
+        https://bugs.webkit.org/show_bug.cgi?id=92780
+
+        Reviewed by Oliver Hunt.
+
+        * UIProcess/Plugins/mac/PluginInfoStoreMac.mm:
+        (WebKit::findPluginWithBundleIdentifier):
+        Add a new helper for finding a plug-in with the given bundle identifier.
+
+        (WebKit::checkForPreferredPlugin):
+        Helper function for making sure that an old plug-in is never loaded if a new plug-in is found, and that the old plug-in
+        is removed from the list of loaded plug-ins if the new plug-in is found.
+
+        (WebKit::PluginInfoStore::shouldUsePlugin):
+        Prefer the Oracle Java plug-in over the Apple Java plug-in.
+
 2012-07-31  Alexey Proskuryakov  <a...@apple.com>
 
         [WK2] Use an actual WebProcessProxy when decoding messages

Modified: trunk/Source/WebKit2/UIProcess/Plugins/mac/PluginInfoStoreMac.mm (124258 => 124259)


--- trunk/Source/WebKit2/UIProcess/Plugins/mac/PluginInfoStoreMac.mm	2012-07-31 22:36:20 UTC (rev 124258)
+++ trunk/Source/WebKit2/UIProcess/Plugins/mac/PluginInfoStoreMac.mm	2012-07-31 22:44:53 UTC (rev 124259)
@@ -82,6 +82,33 @@
 #endif
 }
 
+static size_t findPluginWithBundleIdentifier(const Vector<PluginModuleInfo>& plugins, const String& bundleIdentifier)
+{
+    for (size_t i = 0; i < plugins.size(); ++i) {
+        if (plugins[i].bundleIdentifier == bundleIdentifier)
+            return i;
+    }
+
+    return notFound;
+}
+
+// Returns true if the given plug-in should be loaded, false otherwise.
+static bool checkForPreferredPlugin(Vector<PluginModuleInfo>& alreadyLoadedPlugins, const PluginModuleInfo& plugin, const String& oldPluginBundleIdentifier, const String& newPluginBundleIdentifier)
+{
+    if (plugin.bundleIdentifier == oldPluginBundleIdentifier) {
+        // If we've already found the new plug-in, we don't want to load the old plug-in.
+        if (findPluginWithBundleIdentifier(alreadyLoadedPlugins, newPluginBundleIdentifier) != notFound)
+            return false;
+    } else if (plugin.bundleIdentifier == newPluginBundleIdentifier) {
+        // If we've already found the old plug-in, remove it from the list of loaded plug-ins.
+        size_t oldPluginIndex = findPluginWithBundleIdentifier(alreadyLoadedPlugins, oldPluginBundleIdentifier);
+        if (oldPluginIndex != notFound)
+            alreadyLoadedPlugins.remove(oldPluginIndex);
+    }
+
+    return true;
+}
+
 bool PluginInfoStore::shouldUsePlugin(Vector<PluginModuleInfo>& alreadyLoadedPlugins, const PluginModuleInfo& plugin)
 {
     for (size_t i = 0; i < alreadyLoadedPlugins.size(); ++i) {
@@ -92,6 +119,10 @@
             return false;
     }
 
+    // Prefer the Oracle Java plug-in over the Apple java plug-in.
+    if (!checkForPreferredPlugin(alreadyLoadedPlugins, plugin, "com.apple.java.JavaAppletPlugin", "com.oracle.java.JavaAppletPlugin"))
+        return false;
+
     return true;
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to