From b1750cf16adfa2c7b269073b71af7ed94242ca1d Mon Sep 17 00:00:00 2001 From: "dtownsend%oxymoronical.com" Date: Wed, 27 Feb 2008 00:29:02 +0000 Subject: [PATCH] Bug 409025: OBJECTs with type attribute but no data attribute do not fire plugin errors. r=biesi, sr=jst --- content/base/src/nsObjectLoadingContent.cpp | 55 +++++++++++++++------ content/base/src/nsObjectLoadingContent.h | 9 ++++ 2 files changed, 48 insertions(+), 16 deletions(-) diff --git a/content/base/src/nsObjectLoadingContent.cpp b/content/base/src/nsObjectLoadingContent.cpp index 95473094b81..67c327614ad 100644 --- a/content/base/src/nsObjectLoadingContent.cpp +++ b/content/base/src/nsObjectLoadingContent.cpp @@ -876,6 +876,24 @@ IsAboutBlank(nsIURI* aURI) return str.EqualsLiteral("about:blank"); } +void +nsObjectLoadingContent::UpdateFallbackState(nsIContent* aContent, + AutoFallback& fallback, + const nsCString& aTypeHint) +{ + PluginSupportState pluginState = GetPluginDisabledState(aTypeHint); + if (pluginState == ePluginUnsupported) { + // For unknown plugins notify the UI and allow the unknown plugin binding + // to attach. + FirePluginError(aContent, PR_FALSE); + fallback.TypeUnsupported(); + } + else if (pluginState == ePluginBlocklisted) { + // For blocklisted plugins just send a notification to the UI. + FirePluginError(aContent, PR_TRUE); + } +} + nsresult nsObjectLoadingContent::LoadObject(nsIURI* aURI, PRBool aNotify, @@ -1052,18 +1070,8 @@ nsObjectLoadingContent::LoadObject(nsIURI* aURI, case eType_Loading: NS_NOTREACHED("Should not have a loading type here!"); case eType_Null: - // No need to load anything - PluginSupportState pluginState = GetPluginSupportState(thisContent, - aTypeHint); - if (pluginState == ePluginUnsupported || - pluginState == ePluginBlocklisted) { - FirePluginError(thisContent, pluginState == ePluginBlocklisted); - } - if (pluginState != ePluginDisabled && - pluginState != ePluginBlocklisted) { - fallback.TypeUnsupported(); - } - + // No need to load anything, notify of the failure. + UpdateFallbackState(thisContent, fallback, aTypeHint); break; }; return NS_OK; @@ -1124,22 +1132,37 @@ nsObjectLoadingContent::LoadObject(nsIURI* aURI, } if (!aURI) { - // No URI and no type... nothing we can do. + // No URI and if we have got this far no enabled plugin supports the type LOG(("OBJLC [%p]: no URI\n", this)); rv = NS_ERROR_NOT_AVAILABLE; + + // We should only notify the UI if there is at least a type to go on for + // finding a plugin to use. + if (!aTypeHint.IsEmpty()) { + UpdateFallbackState(thisContent, fallback, aTypeHint); + } + return NS_OK; } + // E.g. mms:// if (!CanHandleURI(aURI)) { LOG(("OBJLC [%p]: can't handle URI\n", this)); if (aTypeHint.IsEmpty()) { rv = NS_ERROR_NOT_AVAILABLE; return NS_OK; } - // E.g. mms:// - mType = eType_Plugin; - rv = TryInstantiate(aTypeHint, aURI); + if (IsSupportedPlugin(aTypeHint)) { + mType = eType_Plugin; + + rv = TryInstantiate(aTypeHint, aURI); + } else { + rv = NS_ERROR_NOT_AVAILABLE; + // No plugin to load, notify of the failure. + UpdateFallbackState(thisContent, fallback, aTypeHint); + } + return NS_OK; } diff --git a/content/base/src/nsObjectLoadingContent.h b/content/base/src/nsObjectLoadingContent.h index b2c64a9fa80..adf1d17e2ba 100644 --- a/content/base/src/nsObjectLoadingContent.h +++ b/content/base/src/nsObjectLoadingContent.h @@ -338,6 +338,15 @@ class nsObjectLoadingContent : public nsImageLoadingContent static PluginSupportState GetPluginDisabledState(const nsCString& aContentType); + /** + * When there is no usable plugin available this will send UI events and + * update the AutoFallback object appropriate to the reason for there being + * no plugin available. + */ + static void + UpdateFallbackState(nsIContent* aContent, AutoFallback& fallback, + const nsCString& aTypeHint); + /** * The final listener to ship the data to (imagelib, uriloader, etc) */