Modified: branches/safari-536.26-branch/Source/WebCore/loader/SubframeLoader.cpp (125104 => 125105)
--- branches/safari-536.26-branch/Source/WebCore/loader/SubframeLoader.cpp 2012-08-08 23:09:37 UTC (rev 125104)
+++ branches/safari-536.26-branch/Source/WebCore/loader/SubframeLoader.cpp 2012-08-08 23:14:58 UTC (rev 125105)
@@ -134,21 +134,52 @@
return loadPlugin(ownerElement, url, mimeType, paramNames, paramValues, useFallback);
}
-static void logPluginRequest(Page* page, const String& mimeType, bool success)
+static String findPluginMIMETypeFromURL(Page* page, const String& url)
{
+ if (!url)
+ return String();
+
+ size_t dotIndex = url.reverseFind('.');
+ if (dotIndex == notFound)
+ return String();
+
+ String extension = url.substring(dotIndex + 1);
+
+ PluginData* pluginData = page->pluginData();
+ for (size_t i = 0; i < pluginData->mimes().size(); ++i) {
+ const MimeClassInfo& mimeClassInfo = pluginData->mimes()[i];
+ for (size_t j = 0; j < mimeClassInfo.extensions.size(); ++j) {
+ if (equalIgnoringCase(extension, mimeClassInfo.extensions[j]))
+ return mimeClassInfo.type;
+ }
+ }
+
+ return String();
+}
+
+static void logPluginRequest(Page* page, const String& mimeType, const String& url, bool success)
+{
if (!page || !page->settings()->diagnosticLoggingEnabled())
return;
-
+
+ String newMIMEType = mimeType;
+ if (!newMIMEType) {
+ // Try to figure out the MIME type from the URL extension.
+ newMIMEType = findPluginMIMETypeFromURL(page, url);
+ if (!newMIMEType)
+ return;
+ }
+
ChromeClient* client = page->chrome()->client();
- client->logDiagnosticMessage(success ? DiagnosticLoggingKeys::pluginLoadedKey() : DiagnosticLoggingKeys::pluginLoadingFailedKey(), mimeType, DiagnosticLoggingKeys::noopKey());
+ client->logDiagnosticMessage(success ? DiagnosticLoggingKeys::pluginLoadedKey() : DiagnosticLoggingKeys::pluginLoadingFailedKey(), newMIMEType, DiagnosticLoggingKeys::noopKey());
if (!page->hasSeenAnyPlugin())
client->logDiagnosticMessage(DiagnosticLoggingKeys::pageContainsAtLeastOnePluginKey(), emptyString(), DiagnosticLoggingKeys::noopKey());
- if (!page->hasSeenPlugin(mimeType))
- client->logDiagnosticMessage(DiagnosticLoggingKeys::pageContainsPluginKey(), mimeType, DiagnosticLoggingKeys::noopKey());
+ if (!page->hasSeenPlugin(newMIMEType))
+ client->logDiagnosticMessage(DiagnosticLoggingKeys::pageContainsPluginKey(), newMIMEType, DiagnosticLoggingKeys::noopKey());
- page->sawPlugin(mimeType);
+ page->sawPlugin(newMIMEType);
}
bool SubframeLoader::requestObject(HTMLPlugInImageElement* ownerElement, const String& url, const AtomicString& frameName, const String& mimeType, const Vector<String>& paramNames, const Vector<String>& paramValues)
@@ -169,7 +200,7 @@
bool useFallback;
if (shouldUsePlugin(completedURL, mimeType, ownerElement->shouldPreferPlugInsForImages(), renderer->hasFallbackContent(), useFallback)) {
bool success = requestPlugin(ownerElement, completedURL, mimeType, paramNames, paramValues, useFallback);
- logPluginRequest(document()->page(), mimeType, success);
+ logPluginRequest(document()->page(), mimeType, completedURL, success);
return success;
}
@@ -253,7 +284,7 @@
if (allowPlugins(AboutToInstantiatePlugin))
widget = m_frame->loader()->client()->createJavaAppletWidget(size, element, baseURL, paramNames, paramValues);
- logPluginRequest(document()->page(), element->serviceType(), widget);
+ logPluginRequest(document()->page(), element->serviceType(), String(), widget);
if (!widget) {
RenderEmbeddedObject* renderer = element->renderEmbeddedObject();