Bug 594482 - Java applets broken with content policies. r=josh,bsmedberg a=blocking2.0BetaN+

This commit is contained in:
Steven Michaud 2010-12-07 15:18:50 -06:00
Родитель f10f9caf69
Коммит 7dcde2114e
5 изменённых файлов: 50 добавлений и 43 удалений

Просмотреть файл

@ -267,6 +267,7 @@ public:
class nsPluginInstanceOwner : public nsIPluginInstanceOwner,
public nsIPluginInstanceOwner_MOZILLA_2_0_BRANCH,
public nsIPluginTagInfo,
public nsIDOMMouseListener,
public nsIDOMMouseMotionListener,
@ -282,6 +283,7 @@ public:
//nsIPluginInstanceOwner interface
NS_DECL_NSIPLUGININSTANCEOWNER
NS_DECL_NSIPLUGININSTANCEOWNER_MOZILLA_2_0_BRANCH
NS_IMETHOD GetURL(const char *aURL, const char *aTarget,
nsIInputStream *aPostStream,
@ -387,7 +389,7 @@ public:
void EndCGPaint();
#else // XP_MACOSX
void UpdateWindowPositionAndClipRect(PRBool aSetWindow);
void SetWindow();
void CallSetWindow();
void UpdateWindowVisibility(PRBool aVisible);
#endif // XP_MACOSX
@ -1090,19 +1092,19 @@ nsObjectFrame::FixupWindow(const nsSize& aSize)
NotifyPluginReflowObservers();
}
void
nsresult
nsObjectFrame::CallSetWindow()
{
NPWindow *win = nsnull;
nsresult rv;
nsresult rv = NS_ERROR_FAILURE;
nsCOMPtr<nsIPluginInstance> pi;
if (!mInstanceOwner ||
NS_FAILED(rv = mInstanceOwner->GetInstance(*getter_AddRefs(pi))) ||
!pi ||
NS_FAILED(rv = mInstanceOwner->GetWindow(win)) ||
!win)
return;
return rv;
nsPluginNativeWindow *window = (nsPluginNativeWindow *)win;
#ifdef XP_MACOSX
@ -1110,7 +1112,7 @@ nsObjectFrame::CallSetWindow()
#endif
if (IsHidden())
return;
return NS_ERROR_FAILURE;
// refresh the plugin port as well
window->window = mInstanceOwner->GetPluginPortFromWidget();
@ -1120,7 +1122,7 @@ nsObjectFrame::CallSetWindow()
nsPresContext* presContext = PresContext();
nsRootPresContext* rootPC = presContext->GetRootPresContext();
if (!rootPC)
return;
return NS_ERROR_FAILURE;
PRInt32 appUnitsPerDevPixel = presContext->AppUnitsPerDevPixel();
nsIFrame* rootFrame = rootPC->PresShell()->FrameManager()->GetRootFrame();
nsRect bounds = GetContentRect() + GetParent()->GetOffsetToCrossDoc(rootFrame);
@ -1133,13 +1135,14 @@ nsObjectFrame::CallSetWindow()
// this will call pi->SetWindow and take care of window subclassing
// if needed, see bug 132759.
if (mInstanceOwner->UseLayers()) {
pi->AsyncSetWindow(window);
rv = pi->AsyncSetWindow(window);
}
else {
window->CallSetWindow(pi);
rv = window->CallSetWindow(pi);
}
mInstanceOwner->ReleasePluginPort(window->window);
return rv;
}
PRBool
@ -2907,6 +2910,7 @@ NS_IMPL_RELEASE(nsPluginInstanceOwner)
NS_INTERFACE_MAP_BEGIN(nsPluginInstanceOwner)
NS_INTERFACE_MAP_ENTRY(nsIPluginInstanceOwner)
NS_INTERFACE_MAP_ENTRY(nsIPluginInstanceOwner_MOZILLA_2_0_BRANCH)
NS_INTERFACE_MAP_ENTRY(nsIPluginTagInfo)
NS_INTERFACE_MAP_ENTRY(nsIDOMMouseListener)
NS_INTERFACE_MAP_ENTRY(nsIDOMMouseMotionListener)
@ -3282,6 +3286,12 @@ NS_IMETHODIMP nsPluginInstanceOwner::SetEventModel(PRInt32 eventModel)
#endif
}
NS_IMETHODIMP nsPluginInstanceOwner::SetWindow()
{
NS_ENSURE_TRUE(mObjectFrame, NS_ERROR_NULL_POINTER);
return mObjectFrame->CallSetWindow();
}
NPError nsPluginInstanceOwner::ShowNativeContextMenu(NPMenu* menu, void* event)
{
if (!menu || !event)
@ -6508,12 +6518,12 @@ void nsPluginInstanceOwner::UpdateWindowPositionAndClipRect(PRBool aSetWindow)
mPluginWindow->clipRect.top != oldWindow.clipRect.top ||
mPluginWindow->clipRect.right != oldWindow.clipRect.right ||
mPluginWindow->clipRect.bottom != oldWindow.clipRect.bottom) {
SetWindow();
CallSetWindow();
}
}
void
nsPluginInstanceOwner::SetWindow()
nsPluginInstanceOwner::CallSetWindow()
{
if (!mInstance)
return;

Просмотреть файл

@ -221,7 +221,7 @@ protected:
/**
* Sets up the plugin window and calls SetWindow on the plugin.
*/
void CallSetWindow();
nsresult CallSetWindow();
PRBool IsFocusable(PRInt32 *aTabIndex = nsnull, PRBool aWithMouse = PR_FALSE);

Просмотреть файл

@ -149,3 +149,15 @@ interface nsIPluginInstanceOwner : nsISupports
virtual void SendIdleEvent() = 0;
%}
};
/**
* This interface extends nsIPluginInstanceOwner for the 2.0 branch
*/
[uuid(20504739-4519-45f3-a8f7-fc8afba7ea87)]
interface nsIPluginInstanceOwner_MOZILLA_2_0_BRANCH : nsISupports
{
/**
* Call NPP_SetWindow on the plugin.
*/
void setWindow();
};

Просмотреть файл

@ -1075,19 +1075,15 @@ nsPluginHost::DoInstantiateEmbeddedPlugin(const char *aMimeType, nsIURI* aURL,
// if we are here then we have loaded a plugin for this mimetype
nsNPAPIPluginInstance *instance = static_cast<nsNPAPIPluginInstance*>(instanceCOMPtr.get());
NPWindow *window = nsnull;
//we got a plugin built, now stream
aOwner->GetWindow(window);
if (instance) {
instance->Start();
aOwner->CreateWidget();
// If we've got a native window, the let the plugin know about it.
if (window->window) {
((nsPluginNativeWindow*)window)->CallSetWindow(instanceCOMPtr);
}
nsCOMPtr<nsIPluginInstanceOwner_MOZILLA_2_0_BRANCH> owner = do_QueryInterface(aOwner);
if (owner)
owner->SetWindow();
// create an initial stream with data
// don't make the stream if it's a java applet or we don't have SRC or DATA attribute
@ -1162,15 +1158,15 @@ NS_IMETHODIMP nsPluginHost::InstantiateFullPagePlugin(const char *aMimeType,
aOwner->CreateWidget();
// If we've got a native window, the let the plugin know about it.
nsPluginNativeWindow * window = (nsPluginNativeWindow *)win;
if (window->window)
window->CallSetWindow(instanceCOMPtr);
nsCOMPtr<nsIPluginInstanceOwner_MOZILLA_2_0_BRANCH> owner = do_QueryInterface(aOwner);
if (owner)
owner->SetWindow();
rv = NewFullPagePluginStream(aURI, instance, aStreamListener);
// If we've got a native window, the let the plugin know about it.
if (window->window)
window->CallSetWindow(instanceCOMPtr);
if (owner)
owner->SetWindow();
}
}
@ -1218,9 +1214,6 @@ nsresult nsPluginHost::FindStoppedPluginForURL(nsIURI* aURL,
nsNPAPIPluginInstance *instance = FindStoppedInstance(url.get());
if (instance && !instance->IsRunning()) {
NPWindow* window = nsnull;
aOwner->GetWindow(window);
aOwner->SetInstance(instance);
instance->SetOwner(aOwner);
@ -1228,10 +1221,9 @@ nsresult nsPluginHost::FindStoppedPluginForURL(nsIURI* aURL,
aOwner->CreateWidget();
// If we've got a native window, the let the plugin know about it.
if (window->window) {
nsCOMPtr<nsIPluginInstance> inst = instance;
((nsPluginNativeWindow*)window)->CallSetWindow(inst);
}
nsCOMPtr<nsIPluginInstanceOwner_MOZILLA_2_0_BRANCH> owner = do_QueryInterface(aOwner);
if (owner)
owner->SetWindow();
return NS_OK;
}

Просмотреть файл

@ -608,15 +608,9 @@ nsPluginStreamListenerPeer::OnStartRequest(nsIRequest *request,
mPluginInstance->Start();
mOwner->CreateWidget();
// If we've got a native window, the let the plugin know about it.
if (window->window) {
((nsPluginNativeWindow*)window)->CallSetWindow(pluginInstCOMPtr);
} else {
PRBool useAsyncPainting = PR_FALSE;
mPluginInstance->UseAsyncPainting(&useAsyncPainting);
if (useAsyncPainting) {
mPluginInstance->AsyncSetWindow(window);
}
}
nsCOMPtr<nsIPluginInstanceOwner_MOZILLA_2_0_BRANCH> owner = do_QueryInterface(mOwner);
if (owner)
owner->SetWindow();
}
}
}
@ -815,10 +809,9 @@ nsresult nsPluginStreamListenerPeer::ServeStreamAsFile(nsIRequest *request,
window->window = widget->GetNativeData(NS_NATIVE_PLUGIN_PORT);
}
#endif
if (window->window) {
nsCOMPtr<nsIPluginInstance> pluginInstCOMPtr = mPluginInstance.get();
((nsPluginNativeWindow*)window)->CallSetWindow(pluginInstCOMPtr);
}
nsCOMPtr<nsIPluginInstanceOwner_MOZILLA_2_0_BRANCH> owner = do_QueryInterface(mOwner);
if (owner)
owner->SetWindow();
}
mSeekable = PR_FALSE;