[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-10851-g50815da
andersca at apple.com
andersca at apple.com
Wed Dec 22 18:37:52 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 022531bd3387d5bbb5ce6d084da9fbf9e66ae4cd
Author: andersca at apple.com <andersca at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Dec 14 22:40:05 2010 +0000
Move PluginInfoStore::getPluginInfo to NetscapePluginModule
https://bugs.webkit.org/show_bug.cgi?id=51058
Reviewed by Adam Roben.
* Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm:
Move implementation of PluginInfoStore::getPluginInfo and related
helper functions here.
* UIProcess/Plugins/mac/PluginInfoStoreMac.mm:
(WebKit::PluginInfoStore::getPluginInfo):
Just call NetscapePluginModule::getPluginInfo here for now.
* WebKit2.xcodeproj/project.pbxproj:
Add NetscapePluginModuleMac.mm.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@74061 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index dfa15fe..84db60a 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,5 +1,23 @@
2010-12-14 Anders Carlsson <andersca at apple.com>
+ Reviewed by Adam Roben.
+
+ Move PluginInfoStore::getPluginInfo to NetscapePluginModule
+ https://bugs.webkit.org/show_bug.cgi?id=51058
+
+ * Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm:
+ Move implementation of PluginInfoStore::getPluginInfo and related
+ helper functions here.
+
+ * UIProcess/Plugins/mac/PluginInfoStoreMac.mm:
+ (WebKit::PluginInfoStore::getPluginInfo):
+ Just call NetscapePluginModule::getPluginInfo here for now.
+
+ * WebKit2.xcodeproj/project.pbxproj:
+ Add NetscapePluginModuleMac.mm.
+
+2010-12-14 Anders Carlsson <andersca at apple.com>
+
Reviewed by John Sullivan.
Switch name and description order when fetching Carbon plug-in info
diff --git a/WebKit2/Shared/Plugins/Netscape/NetscapePluginModule.h b/WebKit2/Shared/Plugins/Netscape/NetscapePluginModule.h
index e495242..0988821 100644
--- a/WebKit2/Shared/Plugins/Netscape/NetscapePluginModule.h
+++ b/WebKit2/Shared/Plugins/Netscape/NetscapePluginModule.h
@@ -31,6 +31,11 @@
#include <wtf/RefCounted.h>
#include <wtf/text/WTFString.h>
+// FIXME: We should not include PluginInfoStore.h here. Instead,
+// PluginInfoStore::Plugin should be moved out into its own header which we can
+// put in Shared/Plugins.
+#include "PluginInfoStore.h"
+
namespace WebKit {
class NetscapePluginModule : public RefCounted<NetscapePluginModule> {
@@ -43,6 +48,8 @@ public:
void pluginCreated();
void pluginDestroyed();
+ static bool getPluginInfo(const String& pluginPath, PluginInfoStore::Plugin&);
+
private:
explicit NetscapePluginModule(const String& pluginPath);
diff --git a/WebKit2/Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm b/WebKit2/Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm
new file mode 100644
index 0000000..c4f1a5e
--- /dev/null
+++ b/WebKit2/Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm
@@ -0,0 +1,326 @@
+/*
+ * Copyright (C) 2010 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. 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 INC. 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.
+ */
+
+#include "NetscapePluginModule.h"
+
+#include <WebCore/WebCoreNSStringExtras.h>
+#include <wtf/HashSet.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+static bool getPluginArchitecture(CFBundleRef bundle, cpu_type_t& pluginArchitecture)
+{
+ RetainPtr<CFArrayRef> pluginArchitecturesArray(AdoptCF, CFBundleCopyExecutableArchitectures(bundle));
+ if (!pluginArchitecturesArray)
+ return false;
+
+ // Turn the array into a set.
+ HashSet<unsigned> architectures;
+ for (CFIndex i = 0, numPluginArchitectures = CFArrayGetCount(pluginArchitecturesArray.get()); i < numPluginArchitectures; ++i) {
+ CFNumberRef number = static_cast<CFNumberRef>(CFArrayGetValueAtIndex(pluginArchitecturesArray.get(), i));
+
+ SInt32 architecture;
+ if (!CFNumberGetValue(number, kCFNumberSInt32Type, &architecture))
+ continue;
+ architectures.add(architecture);
+ }
+
+#ifdef __x86_64__
+ // We only support 64-bit Intel plug-ins on 64-bit Intel.
+ if (architectures.contains(kCFBundleExecutableArchitectureX86_64)) {
+ pluginArchitecture = CPU_TYPE_X86_64;
+ return true;
+ }
+
+ // We also support 32-bit Intel plug-ins on 64-bit Intel.
+ if (architectures.contains(kCFBundleExecutableArchitectureI386)) {
+ pluginArchitecture = CPU_TYPE_X86;
+ return true;
+ }
+#elif defined(__i386__)
+ // We only support 32-bit Intel plug-ins on 32-bit Intel.
+ if (architectures.contains(kCFBundleExecutableArchitectureI386)) {
+ pluginArchitecture = CPU_TYPE_X86;
+ return true;
+ }
+#elif defined(__ppc64__)
+ // We only support 64-bit PPC plug-ins on 64-bit PPC.
+ if (architectures.contains(kCFBundleExecutableArchitecturePPC64)) {
+ pluginArchitecture = CPU_TYPE_POWERPC64;
+ return true;
+ }
+#elif defined(__ppc__)
+ // We only support 32-bit PPC plug-ins on 32-bit PPC.
+ if (architectures.contains(kCFBundleExecutableArchitecturePPC)) {
+ pluginArchitecture = CPU_TYPE_POWERPC;
+ return true;
+ }
+#else
+#error "Unhandled architecture"
+#endif
+
+ return false;
+}
+
+static bool getPluginInfoFromPropertyLists(CFBundleRef bundle, PluginInfo& pluginInfo)
+{
+ // FIXME: Handle WebPluginMIMETypesFilenameKey.
+
+ CFDictionaryRef mimeTypes = static_cast<CFDictionaryRef>(CFBundleGetValueForInfoDictionaryKey(bundle, CFSTR("WebPluginMIMETypes")));
+ if (!mimeTypes || CFGetTypeID(mimeTypes) != CFDictionaryGetTypeID())
+ return false;
+
+ // Get the plug-in name.
+ CFStringRef pluginName = static_cast<CFStringRef>(CFBundleGetValueForInfoDictionaryKey(bundle, CFSTR("WebPluginName")));
+ if (pluginName && CFGetTypeID(pluginName) == CFStringGetTypeID())
+ pluginInfo.name = pluginName;
+
+ // Get the plug-in description.
+ CFStringRef pluginDescription = static_cast<CFStringRef>(CFBundleGetValueForInfoDictionaryKey(bundle, CFSTR("WebPluginDescription")));
+ if (pluginDescription && CFGetTypeID(pluginDescription) == CFStringGetTypeID())
+ pluginInfo.desc = pluginDescription;
+
+ // Get the MIME type mapping dictionary.
+ CFIndex numMimeTypes = CFDictionaryGetCount(mimeTypes);
+ Vector<CFStringRef> mimeTypesVector(numMimeTypes);
+ Vector<CFDictionaryRef> mimeTypeInfoVector(numMimeTypes);
+ CFDictionaryGetKeysAndValues(mimeTypes, reinterpret_cast<const void**>(mimeTypesVector.data()), reinterpret_cast<const void**>(mimeTypeInfoVector.data()));
+
+ for (CFIndex i = 0; i < numMimeTypes; ++i) {
+ MimeClassInfo mimeClassInfo;
+
+ // If this MIME type is invalid, ignore it.
+ CFStringRef mimeType = mimeTypesVector[i];
+ if (!mimeType || CFGetTypeID(mimeType) != CFStringGetTypeID() || CFStringGetLength(mimeType) == 0)
+ continue;
+
+ // If this MIME type doesn't have a valid info dictionary, ignore it.
+ CFDictionaryRef mimeTypeInfo = mimeTypeInfoVector[i];
+ if (!mimeTypeInfo || CFGetTypeID(mimeTypeInfo) != CFDictionaryGetTypeID())
+ continue;
+
+ // Get the MIME type description.
+ CFStringRef mimeTypeDescription = static_cast<CFStringRef>(CFDictionaryGetValue(mimeTypeInfo, CFSTR("WebPluginTypeDescription")));
+ if (mimeTypeDescription && CFGetTypeID(mimeTypeDescription) != CFStringGetTypeID())
+ mimeTypeDescription = 0;
+
+ mimeClassInfo.type = String(mimeType).lower();
+ mimeClassInfo.desc = mimeTypeDescription;
+
+ // Now get the extensions for this MIME type.
+ CFIndex numExtensions = 0;
+ CFArrayRef extensionsArray = static_cast<CFArrayRef>(CFDictionaryGetValue(mimeTypeInfo, CFSTR("WebPluginExtensions")));
+ if (extensionsArray && CFGetTypeID(extensionsArray) == CFArrayGetTypeID())
+ numExtensions = CFArrayGetCount(extensionsArray);
+
+ for (CFIndex i = 0; i < numExtensions; ++i) {
+ CFStringRef extension = static_cast<CFStringRef>(CFArrayGetValueAtIndex(extensionsArray, i));
+ if (!extension || CFGetTypeID(extension) != CFStringGetTypeID())
+ continue;
+
+ mimeClassInfo.extensions.append(String(extension).lower());
+ }
+
+ // Add this MIME type.
+ pluginInfo.mimes.append(mimeClassInfo);
+ }
+
+ return true;
+}
+
+class ResourceMap {
+public:
+ explicit ResourceMap(CFBundleRef bundle)
+ : m_bundle(bundle)
+ , m_currentResourceFile(CurResFile())
+ , m_bundleResourceMap(CFBundleOpenBundleResourceMap(m_bundle))
+ {
+ UseResFile(m_bundleResourceMap);
+ }
+
+ ~ResourceMap()
+ {
+ // Close the resource map.
+ CFBundleCloseBundleResourceMap(m_bundle, m_bundleResourceMap);
+
+ // And restore the old resource.
+ UseResFile(m_currentResourceFile);
+ }
+
+ bool isValid() const { return m_bundleResourceMap != -1; }
+
+private:
+ CFBundleRef m_bundle;
+ ResFileRefNum m_currentResourceFile;
+ ResFileRefNum m_bundleResourceMap;
+};
+
+static bool getStringListResource(ResID resourceID, Vector<String>& stringList) {
+ Handle stringListHandle = Get1Resource('STR#', resourceID);
+ if (!stringListHandle || !*stringListHandle)
+ return false;
+
+ // Get the string list size.
+ Size stringListSize = GetHandleSize(stringListHandle);
+ if (stringListSize < static_cast<Size>(sizeof(UInt16)))
+ return false;
+
+ CFStringEncoding stringEncoding = stringEncodingForResource(stringListHandle);
+
+ unsigned char* ptr = reinterpret_cast<unsigned char*>(*stringListHandle);
+ unsigned char* end = ptr + stringListSize;
+
+ // Get the number of strings in the string list.
+ UInt16 numStrings = *reinterpret_cast<UInt16*>(ptr);
+ ptr += sizeof(UInt16);
+
+ for (UInt16 i = 0; i < numStrings; ++i) {
+ // We're past the end of the string, bail.
+ if (ptr >= end)
+ return false;
+
+ // Get the string length.
+ unsigned char stringLength = *ptr++;
+
+ RetainPtr<CFStringRef> cfString(AdoptCF, CFStringCreateWithBytesNoCopy(kCFAllocatorDefault, ptr, stringLength, stringEncoding, false, kCFAllocatorNull));
+ if (!cfString.get())
+ return false;
+
+ stringList.append(cfString.get());
+ ptr += stringLength;
+ }
+
+ if (ptr != end)
+ return false;
+
+ return true;
+}
+
+static const ResID PluginNameOrDescriptionStringNumber = 126;
+static const ResID MIMEDescriptionStringNumber = 127;
+static const ResID MIMEListStringStringNumber = 128;
+
+static bool getPluginInfoFromCarbonResources(CFBundleRef bundle, PluginInfo& pluginInfo)
+{
+ ResourceMap resourceMap(bundle);
+ if (!resourceMap.isValid())
+ return false;
+
+ // Get the description and name string list.
+ Vector<String> descriptionAndName;
+ if (!getStringListResource(PluginNameOrDescriptionStringNumber, descriptionAndName))
+ return false;
+
+ // Get the MIME types and extensions string list. This list needs to be a multiple of two.
+ Vector<String> mimeTypesAndExtensions;
+ if (!getStringListResource(MIMEListStringStringNumber, mimeTypesAndExtensions))
+ return false;
+
+ if (mimeTypesAndExtensions.size() % 2)
+ return false;
+
+ size_t numMimeTypes = mimeTypesAndExtensions.size() / 2;
+
+ // Now get the MIME type descriptions string list. This string list needs to be the same length as the number of MIME types.
+ Vector<String> mimeTypeDescriptions;
+ if (!getStringListResource(MIMEDescriptionStringNumber, mimeTypeDescriptions))
+ return false;
+
+ if (mimeTypeDescriptions.size() != numMimeTypes)
+ return false;
+
+ // Add all MIME types.
+ for (size_t i = 0; i < mimeTypesAndExtensions.size() / 2; ++i) {
+ MimeClassInfo mimeClassInfo;
+
+ const String& mimeType = mimeTypesAndExtensions[i * 2];
+ const String& description = mimeTypeDescriptions[i];
+
+ mimeClassInfo.type = mimeType.lower();
+ mimeClassInfo.desc = description;
+
+ Vector<String> extensions;
+ mimeTypesAndExtensions[i * 2 + 1].split(',', extensions);
+
+ for (size_t i = 0; i < extensions.size(); ++i)
+ mimeClassInfo.extensions.append(extensions[i].lower());
+
+ pluginInfo.mimes.append(mimeClassInfo);
+ }
+
+ // Set the description and name if they exist.
+ if (descriptionAndName.size() > 0)
+ pluginInfo.desc = descriptionAndName[0];
+ if (descriptionAndName.size() > 1)
+ pluginInfo.name = descriptionAndName[1];
+
+ return true;
+}
+
+bool NetscapePluginModule::getPluginInfo(const String& pluginPath, PluginInfoStore::Plugin& plugin)
+{
+ RetainPtr<CFStringRef> bundlePath(AdoptCF, pluginPath.createCFString());
+ RetainPtr<CFURLRef> bundleURL(AdoptCF, CFURLCreateWithFileSystemPath(kCFAllocatorDefault, bundlePath.get(), kCFURLPOSIXPathStyle, false));
+
+ // Try to initialize the bundle.
+ RetainPtr<CFBundleRef> bundle(AdoptCF, CFBundleCreate(kCFAllocatorDefault, bundleURL.get()));
+ if (!bundle)
+ return false;
+
+ // Check if this bundle is an NPAPI plug-in.
+ UInt32 packageType = 0;
+ CFBundleGetPackageInfo(bundle.get(), &packageType, 0);
+ if (packageType != FOUR_CHAR_CODE('BRPL'))
+ return false;
+
+ // Check that the architecture is valid.
+ cpu_type_t pluginArchitecture = 0;
+ if (!getPluginArchitecture(bundle.get(), pluginArchitecture))
+ return false;
+
+ // Check that there's valid info for this plug-in.
+ if (!getPluginInfoFromPropertyLists(bundle.get(), plugin.info) &&
+ !getPluginInfoFromCarbonResources(bundle.get(), plugin.info))
+ return false;
+
+ plugin.path = pluginPath;
+ plugin.pluginArchitecture = pluginArchitecture;
+ plugin.bundleIdentifier = CFBundleGetIdentifier(bundle.get());
+ plugin.versionNumber = CFBundleGetVersionNumber(bundle.get());
+
+ RetainPtr<CFStringRef> filename(AdoptCF, CFURLCopyLastPathComponent(bundleURL.get()));
+ plugin.info.file = filename.get();
+
+ if (plugin.info.name.isNull())
+ plugin.info.name = plugin.info.file;
+ if (plugin.info.desc.isNull())
+ plugin.info.desc = plugin.info.file;
+
+ return true;
+}
+
+} // namespace WebKit
diff --git a/WebKit2/UIProcess/Plugins/mac/PluginInfoStoreMac.mm b/WebKit2/UIProcess/Plugins/mac/PluginInfoStoreMac.mm
index 7a2f357..b787101 100644
--- a/WebKit2/UIProcess/Plugins/mac/PluginInfoStoreMac.mm
+++ b/WebKit2/UIProcess/Plugins/mac/PluginInfoStoreMac.mm
@@ -25,6 +25,7 @@
#include "PluginInfoStore.h"
+#include "NetscapePluginModule.h"
#include "WebKitSystemInterface.h"
#include <WebCore/WebCoreNSStringExtras.h>
#include <wtf/HashSet.h>
@@ -69,295 +70,9 @@ Vector<String> PluginInfoStore::individualPluginPaths()
return Vector<String>();
}
-static bool getPluginArchitecture(CFBundleRef bundle, cpu_type_t& pluginArchitecture)
-{
- RetainPtr<CFArrayRef> pluginArchitecturesArray(AdoptCF, CFBundleCopyExecutableArchitectures(bundle));
- if (!pluginArchitecturesArray)
- return false;
-
- // Turn the array into a set.
- HashSet<unsigned> architectures;
- for (CFIndex i = 0, numPluginArchitectures = CFArrayGetCount(pluginArchitecturesArray.get()); i < numPluginArchitectures; ++i) {
- CFNumberRef number = static_cast<CFNumberRef>(CFArrayGetValueAtIndex(pluginArchitecturesArray.get(), i));
-
- SInt32 architecture;
- if (!CFNumberGetValue(number, kCFNumberSInt32Type, &architecture))
- continue;
- architectures.add(architecture);
- }
-
-#ifdef __x86_64__
- // We only support 64-bit Intel plug-ins on 64-bit Intel.
- if (architectures.contains(kCFBundleExecutableArchitectureX86_64)) {
- pluginArchitecture = CPU_TYPE_X86_64;
- return true;
- }
-
- // We also support 32-bit Intel plug-ins on 64-bit Intel.
- if (architectures.contains(kCFBundleExecutableArchitectureI386)) {
- pluginArchitecture = CPU_TYPE_X86;
- return true;
- }
-#elif defined(__i386__)
- // We only support 32-bit Intel plug-ins on 32-bit Intel.
- if (architectures.contains(kCFBundleExecutableArchitectureI386)) {
- pluginArchitecture = CPU_TYPE_X86;
- return true;
- }
-#elif defined(__ppc64__)
- // We only support 64-bit PPC plug-ins on 64-bit PPC.
- if (architectures.contains(kCFBundleExecutableArchitecturePPC64)) {
- pluginArchitecture = CPU_TYPE_POWERPC64;
- return true;
- }
-#elif defined(__ppc__)
- // We only support 32-bit PPC plug-ins on 32-bit PPC.
- if (architectures.contains(kCFBundleExecutableArchitecturePPC)) {
- pluginArchitecture = CPU_TYPE_POWERPC;
- return true;
- }
-#else
-#error "Unhandled architecture"
-#endif
-
- return false;
-}
-
-static bool getPluginInfoFromPropertyLists(CFBundleRef bundle, PluginInfo& pluginInfo)
-{
- // FIXME: Handle WebPluginMIMETypesFilenameKey.
-
- CFDictionaryRef mimeTypes = static_cast<CFDictionaryRef>(CFBundleGetValueForInfoDictionaryKey(bundle, CFSTR("WebPluginMIMETypes")));
- if (!mimeTypes || CFGetTypeID(mimeTypes) != CFDictionaryGetTypeID())
- return false;
-
- // Get the plug-in name.
- CFStringRef pluginName = static_cast<CFStringRef>(CFBundleGetValueForInfoDictionaryKey(bundle, CFSTR("WebPluginName")));
- if (pluginName && CFGetTypeID(pluginName) == CFStringGetTypeID())
- pluginInfo.name = pluginName;
-
- // Get the plug-in description.
- CFStringRef pluginDescription = static_cast<CFStringRef>(CFBundleGetValueForInfoDictionaryKey(bundle, CFSTR("WebPluginDescription")));
- if (pluginDescription && CFGetTypeID(pluginDescription) == CFStringGetTypeID())
- pluginInfo.desc = pluginDescription;
-
- // Get the MIME type mapping dictionary.
- CFIndex numMimeTypes = CFDictionaryGetCount(mimeTypes);
- Vector<CFStringRef> mimeTypesVector(numMimeTypes);
- Vector<CFDictionaryRef> mimeTypeInfoVector(numMimeTypes);
- CFDictionaryGetKeysAndValues(mimeTypes, reinterpret_cast<const void**>(mimeTypesVector.data()), reinterpret_cast<const void**>(mimeTypeInfoVector.data()));
-
- for (CFIndex i = 0; i < numMimeTypes; ++i) {
- MimeClassInfo mimeClassInfo;
-
- // If this MIME type is invalid, ignore it.
- CFStringRef mimeType = mimeTypesVector[i];
- if (!mimeType || CFGetTypeID(mimeType) != CFStringGetTypeID() || CFStringGetLength(mimeType) == 0)
- continue;
-
- // If this MIME type doesn't have a valid info dictionary, ignore it.
- CFDictionaryRef mimeTypeInfo = mimeTypeInfoVector[i];
- if (!mimeTypeInfo || CFGetTypeID(mimeTypeInfo) != CFDictionaryGetTypeID())
- continue;
-
- // Get the MIME type description.
- CFStringRef mimeTypeDescription = static_cast<CFStringRef>(CFDictionaryGetValue(mimeTypeInfo, CFSTR("WebPluginTypeDescription")));
- if (mimeTypeDescription && CFGetTypeID(mimeTypeDescription) != CFStringGetTypeID())
- mimeTypeDescription = 0;
-
- mimeClassInfo.type = String(mimeType).lower();
- mimeClassInfo.desc = mimeTypeDescription;
-
- // Now get the extensions for this MIME type.
- CFIndex numExtensions = 0;
- CFArrayRef extensionsArray = static_cast<CFArrayRef>(CFDictionaryGetValue(mimeTypeInfo, CFSTR("WebPluginExtensions")));
- if (extensionsArray && CFGetTypeID(extensionsArray) == CFArrayGetTypeID())
- numExtensions = CFArrayGetCount(extensionsArray);
-
- for (CFIndex i = 0; i < numExtensions; ++i) {
- CFStringRef extension = static_cast<CFStringRef>(CFArrayGetValueAtIndex(extensionsArray, i));
- if (!extension || CFGetTypeID(extension) != CFStringGetTypeID())
- continue;
-
- mimeClassInfo.extensions.append(String(extension).lower());
- }
-
- // Add this MIME type.
- pluginInfo.mimes.append(mimeClassInfo);
- }
-
- return true;
-}
-
-class ResourceMap {
-public:
- explicit ResourceMap(CFBundleRef bundle)
- : m_bundle(bundle)
- , m_currentResourceFile(CurResFile())
- , m_bundleResourceMap(CFBundleOpenBundleResourceMap(m_bundle))
- {
- UseResFile(m_bundleResourceMap);
- }
-
- ~ResourceMap()
- {
- // Close the resource map.
- CFBundleCloseBundleResourceMap(m_bundle, m_bundleResourceMap);
-
- // And restore the old resource.
- UseResFile(m_currentResourceFile);
- }
-
- bool isValid() const { return m_bundleResourceMap != -1; }
-
-private:
- CFBundleRef m_bundle;
- ResFileRefNum m_currentResourceFile;
- ResFileRefNum m_bundleResourceMap;
-};
-
-static bool getStringListResource(ResID resourceID, Vector<String>& stringList) {
- Handle stringListHandle = Get1Resource('STR#', resourceID);
- if (!stringListHandle || !*stringListHandle)
- return false;
-
- // Get the string list size.
- Size stringListSize = GetHandleSize(stringListHandle);
- if (stringListSize < static_cast<Size>(sizeof(UInt16)))
- return false;
-
- CFStringEncoding stringEncoding = stringEncodingForResource(stringListHandle);
-
- unsigned char* ptr = reinterpret_cast<unsigned char*>(*stringListHandle);
- unsigned char* end = ptr + stringListSize;
-
- // Get the number of strings in the string list.
- UInt16 numStrings = *reinterpret_cast<UInt16*>(ptr);
- ptr += sizeof(UInt16);
-
- for (UInt16 i = 0; i < numStrings; ++i) {
- // We're past the end of the string, bail.
- if (ptr >= end)
- return false;
-
- // Get the string length.
- unsigned char stringLength = *ptr++;
-
- RetainPtr<CFStringRef> cfString(AdoptCF, CFStringCreateWithBytesNoCopy(kCFAllocatorDefault, ptr, stringLength, stringEncoding, false, kCFAllocatorNull));
- if (!cfString.get())
- return false;
-
- stringList.append(cfString.get());
- ptr += stringLength;
- }
-
- if (ptr != end)
- return false;
-
- return true;
-}
-
-static const ResID PluginNameOrDescriptionStringNumber = 126;
-static const ResID MIMEDescriptionStringNumber = 127;
-static const ResID MIMEListStringStringNumber = 128;
-
-static bool getPluginInfoFromCarbonResources(CFBundleRef bundle, PluginInfo& pluginInfo)
-{
- ResourceMap resourceMap(bundle);
- if (!resourceMap.isValid())
- return false;
-
- // Get the description and name string list.
- Vector<String> descriptionAndName;
- if (!getStringListResource(PluginNameOrDescriptionStringNumber, descriptionAndName))
- return false;
-
- // Get the MIME types and extensions string list. This list needs to be a multiple of two.
- Vector<String> mimeTypesAndExtensions;
- if (!getStringListResource(MIMEListStringStringNumber, mimeTypesAndExtensions))
- return false;
-
- if (mimeTypesAndExtensions.size() % 2)
- return false;
-
- size_t numMimeTypes = mimeTypesAndExtensions.size() / 2;
-
- // Now get the MIME type descriptions string list. This string list needs to be the same length as the number of MIME types.
- Vector<String> mimeTypeDescriptions;
- if (!getStringListResource(MIMEDescriptionStringNumber, mimeTypeDescriptions))
- return false;
-
- if (mimeTypeDescriptions.size() != numMimeTypes)
- return false;
-
- // Add all MIME types.
- for (size_t i = 0; i < mimeTypesAndExtensions.size() / 2; ++i) {
- MimeClassInfo mimeClassInfo;
-
- const String& mimeType = mimeTypesAndExtensions[i * 2];
- const String& description = mimeTypeDescriptions[i];
-
- mimeClassInfo.type = mimeType.lower();
- mimeClassInfo.desc = description;
-
- Vector<String> extensions;
- mimeTypesAndExtensions[i * 2 + 1].split(',', extensions);
-
- for (size_t i = 0; i < extensions.size(); ++i)
- mimeClassInfo.extensions.append(extensions[i].lower());
-
- pluginInfo.mimes.append(mimeClassInfo);
- }
-
- // Set the description and name if they exist.
- if (descriptionAndName.size() > 0)
- pluginInfo.desc = descriptionAndName[0];
- if (descriptionAndName.size() > 1)
- pluginInfo.name = descriptionAndName[1];
-
- return true;
-}
-
bool PluginInfoStore::getPluginInfo(const String& pluginPath, Plugin& plugin)
{
- RetainPtr<CFStringRef> bundlePath(AdoptCF, safeCreateCFString(pluginPath));
- RetainPtr<CFURLRef> bundleURL(AdoptCF, CFURLCreateWithFileSystemPath(kCFAllocatorDefault, bundlePath.get(), kCFURLPOSIXPathStyle, false));
-
- // Try to initialize the bundle.
- RetainPtr<CFBundleRef> bundle(AdoptCF, CFBundleCreate(kCFAllocatorDefault, bundleURL.get()));
- if (!bundle)
- return false;
-
- // Check if this bundle is an NPAPI plug-in.
- UInt32 packageType = 0;
- CFBundleGetPackageInfo(bundle.get(), &packageType, 0);
- if (packageType != FOUR_CHAR_CODE('BRPL'))
- return false;
-
- // Check that the architecture is valid.
- cpu_type_t pluginArchitecture = 0;
- if (!getPluginArchitecture(bundle.get(), pluginArchitecture))
- return false;
-
- // Check that there's valid info for this plug-in.
- if (!getPluginInfoFromPropertyLists(bundle.get(), plugin.info) &&
- !getPluginInfoFromCarbonResources(bundle.get(), plugin.info))
- return false;
-
- plugin.path = pluginPath;
- plugin.pluginArchitecture = pluginArchitecture;
- plugin.bundleIdentifier = CFBundleGetIdentifier(bundle.get());
- plugin.versionNumber = CFBundleGetVersionNumber(bundle.get());
-
- RetainPtr<CFStringRef> filename(AdoptCF, CFURLCopyLastPathComponent(bundleURL.get()));
- plugin.info.file = filename.get();
-
- if (plugin.info.name.isNull())
- plugin.info.name = plugin.info.file;
- if (plugin.info.desc.isNull())
- plugin.info.desc = plugin.info.file;
-
- return true;
+ return NetscapePluginModule::getPluginInfo(pluginPath, plugin);
}
bool PluginInfoStore::shouldUsePlugin(const Plugin& plugin)
diff --git a/WebKit2/WebKit2.xcodeproj/project.pbxproj b/WebKit2/WebKit2.xcodeproj/project.pbxproj
index f75c44d..88dad9b 100644
--- a/WebKit2/WebKit2.xcodeproj/project.pbxproj
+++ b/WebKit2/WebKit2.xcodeproj/project.pbxproj
@@ -112,6 +112,7 @@
1A4A9AA912B7E796008FE984 /* WKTextInputWindowController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A4A9AA712B7E796008FE984 /* WKTextInputWindowController.mm */; };
1A4A9C5512B816CF008FE984 /* NetscapePluginModule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A4A9C5312B816CF008FE984 /* NetscapePluginModule.cpp */; };
1A4A9C5612B816CF008FE984 /* NetscapePluginModule.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A4A9C5412B816CF008FE984 /* NetscapePluginModule.h */; };
+ 1A4A9C9A12B821CD008FE984 /* NetscapePluginModuleMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A4A9C9912B821CD008FE984 /* NetscapePluginModuleMac.mm */; };
1A50DB66110A3D57000D3FE5 /* WebProcess.app in CopyFiles */ = {isa = PBXBuildFile; fileRef = 1A50DB1E110A3BDC000D3FE5 /* WebProcess.app */; };
1A594ABA112A1FB6009DE7C7 /* WebUIClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A594AB8112A1FB6009DE7C7 /* WebUIClient.cpp */; };
1A594ABB112A1FB6009DE7C7 /* WebUIClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A594AB9112A1FB6009DE7C7 /* WebUIClient.h */; };
@@ -744,6 +745,7 @@
1A4A9AA712B7E796008FE984 /* WKTextInputWindowController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKTextInputWindowController.mm; sourceTree = "<group>"; };
1A4A9C5312B816CF008FE984 /* NetscapePluginModule.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetscapePluginModule.cpp; sourceTree = "<group>"; };
1A4A9C5412B816CF008FE984 /* NetscapePluginModule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetscapePluginModule.h; sourceTree = "<group>"; };
+ 1A4A9C9912B821CD008FE984 /* NetscapePluginModuleMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NetscapePluginModuleMac.mm; sourceTree = "<group>"; };
1A4F976A100E7B6600637A18 /* Base.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Base.xcconfig; sourceTree = "<group>"; };
1A4F976B100E7B6600637A18 /* DebugRelease.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = DebugRelease.xcconfig; sourceTree = "<group>"; };
1A4F976C100E7B6600637A18 /* FeatureDefines.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = FeatureDefines.xcconfig; sourceTree = "<group>"; };
@@ -1411,12 +1413,21 @@
1A4A9C5212B816CF008FE984 /* Netscape */ = {
isa = PBXGroup;
children = (
+ 1A4A9C9812B821C0008FE984 /* mac */,
1A4A9C5312B816CF008FE984 /* NetscapePluginModule.cpp */,
1A4A9C5412B816CF008FE984 /* NetscapePluginModule.h */,
);
path = Netscape;
sourceTree = "<group>";
};
+ 1A4A9C9812B821C0008FE984 /* mac */ = {
+ isa = PBXGroup;
+ children = (
+ 1A4A9C9912B821CD008FE984 /* NetscapePluginModuleMac.mm */,
+ );
+ path = mac;
+ sourceTree = "<group>";
+ };
1A4F9769100E7B6600637A18 /* Configurations */ = {
isa = PBXGroup;
children = (
@@ -3122,6 +3133,7 @@
BC857E8712B71EBB00EDEB2E /* WebPageProxyMac.mm in Sources */,
1A4A9AA912B7E796008FE984 /* WKTextInputWindowController.mm in Sources */,
1A4A9C5512B816CF008FE984 /* NetscapePluginModule.cpp in Sources */,
+ 1A4A9C9A12B821CD008FE984 /* NetscapePluginModuleMac.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list