Fix for 93351 -- preventing endless reload loop on plugins.refresh(1), r=peterl, sr=jst

This commit is contained in:
av%netscape.com 2001-08-10 01:12:05 +00:00
Родитель f40aa5e803
Коммит 9b6cbdd8d5
2 изменённых файлов: 22 добавлений и 8 удалений

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

@ -57,7 +57,6 @@ PluginArrayImpl::~PluginArrayImpl()
}
}
// QueryInterface implementation for PluginArrayImpl
NS_INTERFACE_MAP_BEGIN(PluginArrayImpl)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMPluginArray)
@ -66,11 +65,9 @@ NS_INTERFACE_MAP_BEGIN(PluginArrayImpl)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(PluginArray)
NS_INTERFACE_MAP_END
NS_IMPL_ADDREF(PluginArrayImpl)
NS_IMPL_RELEASE(PluginArrayImpl)
NS_IMETHODIMP
PluginArrayImpl::GetLength(PRUint32* aLength)
{
@ -161,6 +158,23 @@ PluginArrayImpl::Refresh(PRBool aReloadDocuments)
{
nsresult res = NS_OK;
nsCOMPtr<nsIWebNavigation> webNav = do_QueryInterface(mDocShell);
if(aReloadDocuments && webNav) {
// we should take some measures to prevent recursive reload,
// check the URL and don't do anything if we just saw it.
nsCOMPtr<nsIURI> uri;
webNav->GetCurrentURI(getter_AddRefs(uri));
if(uri) {
PRBool sameURI = PR_FALSE;
uri->Equals(mLastURI, &sameURI);
if(sameURI) {
mLastURI = nsnull;
return res;
}
}
}
if (mPluginArray != nsnull) {
for (PRUint32 i = 0; i < mPluginCount; i++)
NS_IF_RELEASE(mPluginArray[i]);
@ -187,11 +201,9 @@ PluginArrayImpl::Refresh(PRBool aReloadDocuments)
if (mNavigator)
mNavigator->RefreshMIMEArray();
if (aReloadDocuments && mDocShell) {
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mDocShell));
if (webNav)
webNav->Reload(nsIWebNavigation::LOAD_FLAGS_NONE);
if (aReloadDocuments && webNav) {
webNav->GetCurrentURI(getter_AddRefs(mLastURI));
webNav->Reload(nsIWebNavigation::LOAD_FLAGS_NONE);
}
return res;

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

@ -26,6 +26,7 @@
#include "nsIDOMPluginArray.h"
#include "nsIDOMPlugin.h"
#include "nsIPluginHost.h"
#include "nsIURL.h"
class NavigatorImpl;
class nsIDocShell;
@ -60,6 +61,7 @@ protected:
PRUint32 mPluginCount;
nsIDOMPlugin** mPluginArray;
nsIDocShell* mDocShell; // weak reference
nsCOMPtr<nsIURI> mLastURI;
};
class PluginElementImpl : public nsIDOMPlugin