Bug 629401: Carbon plugins that cannot load in X64 Mac should send an event or notifyObservers of failure. r=BenWa, a=blocks-betaN

This commit is contained in:
Josh Aas 2011-02-03 09:31:01 -08:00
parent 90729fb263
commit 5c32597cfd
6 changed files with 75 additions and 1 deletions

View File

@ -204,6 +204,11 @@ parent:
NPCoordinateSpace destSpace)
returns (double destX, double destY, bool result);
// Send notification that a plugin tried to negotiate Carbon NPAPI so that
// users can be notified that restarting the browser in i386 mode may allow
// them to use the plugin.
sync NegotiatedCarbon();
both:
async PPluginScriptableObject();

View File

@ -56,6 +56,7 @@
#include "gfxContext.h"
#include "gfxColor.h"
#include "gfxUtils.h"
#include "nsNPAPIPluginInstance.h"
#if defined(OS_WIN)
#include <windowsx.h>
@ -1241,6 +1242,17 @@ PluginInstanceParent::AnswerNPN_ConvertPoint(const double& sourceX,
return true;
}
bool
PluginInstanceParent::RecvNegotiatedCarbon()
{
nsNPAPIPluginInstance *inst = static_cast<nsNPAPIPluginInstance*>(mNPP->ndata);
if (!inst) {
return false;
}
inst->CarbonNPAPIFailure();
return true;
}
#if defined(OS_WIN)
/*

View File

@ -221,6 +221,9 @@ public:
double *destY,
bool *result);
NS_OVERRIDE virtual bool
RecvNegotiatedCarbon();
NPError NPP_SetWindow(const NPWindow* aWindow);
NPError NPP_GetValue(NPPVariable variable, void* retval);

View File

@ -1884,7 +1884,13 @@ PluginModuleChild::AnswerPPluginInstanceConstructor(PPluginInstanceChild* aActor
// plugins need to actively negotiate something else in order to work
// out of process.
if (childInstance->EventModel() == NPEventModelCarbon) {
*rv = NPERR_MODULE_LOAD_FAILED_ERROR;
// Send notification that a plugin tried to negotiate Carbon NPAPI so that
// users can be notified that restarting the browser in i386 mode may allow
// them to use the plugin.
childInstance->SendNegotiatedCarbon();
// Fail to instantiate.
*rv = NPERR_MODULE_LOAD_FAILED_ERROR;
}
#endif

View File

@ -49,6 +49,7 @@
#include "nsPluginSafety.h"
#include "nsPluginLogging.h"
#include "nsIPrivateBrowsingService.h"
#include "nsContentUtils.h"
#include "nsIDocument.h"
#include "nsIScriptGlobalObject.h"
@ -1254,3 +1255,46 @@ nsNPAPIPluginInstance::URLRedirectResponse(void* notifyData, NPBool allow)
}
}
}
class CarbonEventModelFailureEvent : public nsRunnable {
public:
nsCOMPtr<nsIContent> mContent;
CarbonEventModelFailureEvent(nsIContent* aContent)
: mContent(aContent)
{}
~CarbonEventModelFailureEvent() {}
NS_IMETHOD Run();
};
NS_IMETHODIMP
CarbonEventModelFailureEvent::Run()
{
nsString type = NS_LITERAL_STRING("npapi-carbon-event-model-failure");
nsContentUtils::DispatchTrustedEvent(mContent->GetDocument(), mContent,
type, PR_TRUE, PR_TRUE);
return NS_OK;
}
void
nsNPAPIPluginInstance::CarbonNPAPIFailure()
{
nsCOMPtr<nsIDOMElement> element;
GetDOMElement(getter_AddRefs(element));
if (!element) {
return;
}
nsCOMPtr<nsIContent> content(do_QueryInterface(element));
if (!content) {
return;
}
nsCOMPtr<nsIRunnable> e = new CarbonEventModelFailureEvent(content);
nsresult rv = NS_DispatchToCurrentThread(e);
if (NS_FAILED(rv)) {
NS_WARNING("Failed to dispatch CarbonEventModelFailureEvent.");
}
}

View File

@ -146,6 +146,10 @@ public:
void URLRedirectResponse(void* notifyData, NPBool allow);
// Called when the instance fails to instantiate beceause the Carbon
// event model is not supported.
void CarbonNPAPIFailure();
protected:
nsresult InitializePlugin();