PluginModuleInfo PluginInfoStore::findPlugin(String& mimeType, const KURL& url) { loadPluginsIfNecessary(); // First, check if we can get the plug-in based on its MIME type. if (!mimeType.isNull()) { PluginModuleInfo plugin = findPluginForMIMEType(mimeType); if (!plugin.path.isNull()) return plugin; } // Next, check if any plug-ins claim to support the URL extension. String extension = pathExtension(url).lower(); if (!extension.isNull() && mimeType.isEmpty()) { PluginModuleInfo plugin = findPluginForExtension(extension, mimeType); if (!plugin.path.isNull()) return plugin; // Finally, try to get the MIME type from the extension in a platform specific manner and use that. String extensionMimeType = getMIMETypeForExtension(extension); if (!extensionMimeType.isNull()) { PluginModuleInfo plugin = findPluginForMIMEType(extensionMimeType); if (!plugin.path.isNull()) { mimeType = extensionMimeType; return plugin; } } } return PluginModuleInfo(); }
String MIMETypeRegistry::getMIMETypeForPath(const String& path) { int pos = path.reverseFind('.'); if (pos >= 0) { String extension = path.substring(pos + 1); return getMIMETypeForExtension(extension); } return "application/octet-stream"; }
String MIMETypeRegistry::getMIMETypeForPath(const String& path) { size_t pos = path.reverseFind('.'); if (pos != notFound) { String extension = path.substring(pos + 1); String result = getMIMETypeForExtension(extension); if (result.length()) return result; } return "application/octet-stream"; }
String MIMETypeRegistry::getMediaMIMETypeForExtension(const String& ext) { // Check with system specific implementation first. String mimeType = getMIMETypeForExtension(ext); if (!mimeType.isEmpty()) return mimeType; // No match, look in the static mapping. if (!mediaMIMETypeForExtensionMap) initializeMediaTypeMaps(); return mediaMIMETypeForExtensionMap->get(ext); }
String MIMETypeRegistry::getMediaMIMETypeForExtension(const String& ext) { // Look in the system-specific registry first. String type = getMIMETypeForExtension(ext); if (!type.isEmpty()) return type; Vector<String>* typeList = mediaMIMETypeMap().get(ext); if (typeList) return (*typeList)[0]; return String(); }
String MIMETypeRegistry::getMIMETypeForPath(const String& path) { int pos = path.reverseFind('.'); if (pos < 0) return "application/octet-stream"; String extension = path.substring(pos + 1); String mimeType = getMIMETypeForExtension(extension); if (mimeType.isEmpty()) { // If there's no mimetype registered for the extension, check to see // if a plugin can handle the extension. mimeType = getPluginMimeTypeFromExtension(extension); } return mimeType; }
Vector<String> MIMETypeRegistry::getMediaMIMETypesForExtension(const String& ext) { Vector<String>* typeList = mediaMIMETypeMap().get(ext); if (typeList) return *typeList; // Only need to look in the system-specific registry if mediaMIMETypeMap() doesn't contain // the extension at all, because it always contains the system-specific type if the // extension is in the static mapping table. String type = getMIMETypeForExtension(ext); if (!type.isEmpty()) { Vector<String> typeList; typeList.append(type); return typeList; } return Vector<String>(); }