зеркало из https://github.com/mozilla/pjs.git
Part of the 61388 fix. Adding mechanism for refreshing plugin list and reloading the page to DOM, sr=vidur, a=r=jst.
This commit is contained in:
Родитель
10c05fc460
Коммит
e4eac223fb
|
@ -428,6 +428,8 @@ NS_IMETHODIMP GlobalWindowImpl::SetDocShell(nsIDocShell* aDocShell)
|
|||
|
||||
if (mLocation)
|
||||
mLocation->SetDocShell(aDocShell);
|
||||
if (mNavigator)
|
||||
mNavigator->SetDocShell(aDocShell);
|
||||
if (mHistory)
|
||||
mHistory->SetDocShell(aDocShell);
|
||||
if (mFrames)
|
||||
|
@ -680,7 +682,7 @@ NS_IMETHODIMP GlobalWindowImpl::GetSelf(nsIDOMWindowInternal** aWindow)
|
|||
NS_IMETHODIMP GlobalWindowImpl::GetNavigator(nsIDOMNavigator** aNavigator)
|
||||
{
|
||||
if (!mNavigator) {
|
||||
mNavigator = new NavigatorImpl();
|
||||
mNavigator = new NavigatorImpl(mDocShell);
|
||||
NS_ENSURE_TRUE(mNavigator, NS_ERROR_OUT_OF_MEMORY);
|
||||
NS_ADDREF(mNavigator);
|
||||
}
|
||||
|
@ -4499,8 +4501,11 @@ extern
|
|||
//*** NavigatorImpl: Object Management
|
||||
//*****************************************************************************
|
||||
|
||||
NavigatorImpl::NavigatorImpl():mScriptObject(nsnull), mMimeTypes(nsnull),
|
||||
mPlugins(nsnull)
|
||||
NavigatorImpl::NavigatorImpl(nsIDocShell *aDocShell) :
|
||||
mScriptObject(nsnull),
|
||||
mMimeTypes(nsnull),
|
||||
mPlugins(nsnull),
|
||||
mDocShell(aDocShell)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
@ -4551,6 +4556,14 @@ NS_IMETHODIMP NavigatorImpl::GetScriptObject(nsIScriptContext *aContext,
|
|||
return res;
|
||||
}
|
||||
|
||||
|
||||
void NavigatorImpl::SetDocShell(nsIDocShell *aDocShell)
|
||||
{
|
||||
mDocShell = aDocShell;
|
||||
if (mPlugins)
|
||||
mPlugins->SetDocShell(aDocShell);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
// NavigatorImpl::nsIDOMNavigator
|
||||
//*****************************************************************************
|
||||
|
@ -4764,7 +4777,7 @@ NS_IMETHODIMP NavigatorImpl::GetMimeTypes(nsIDOMMimeTypeArray **aMimeTypes)
|
|||
NS_IMETHODIMP NavigatorImpl::GetPlugins(nsIDOMPluginArray **aPlugins)
|
||||
{
|
||||
if (!mPlugins) {
|
||||
mPlugins = new PluginArrayImpl(this);
|
||||
mPlugins = new PluginArrayImpl(this, mDocShell);
|
||||
NS_IF_ADDREF(mPlugins);
|
||||
}
|
||||
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
#include "nsIDOMPkcs11.h"
|
||||
#include "nsISidebar.h"
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsPluginArray.h"
|
||||
|
||||
#define DEFAULT_HOME_PAGE "www.mozilla.org"
|
||||
#define PREF_BROWSER_STARTUP_HOMEPAGE "browser.startup.homepage"
|
||||
|
@ -302,7 +303,7 @@ struct nsTimeoutImpl {
|
|||
class NavigatorImpl : public nsIScriptObjectOwner, public nsIDOMNavigator
|
||||
{
|
||||
public:
|
||||
NavigatorImpl();
|
||||
NavigatorImpl(nsIDocShell *aDocShell);
|
||||
virtual ~NavigatorImpl();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
@ -312,10 +313,13 @@ public:
|
|||
NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject);
|
||||
NS_IMETHOD SetScriptObject(void *aScriptObject);
|
||||
|
||||
void SetDocShell(nsIDocShell *aDocShell);
|
||||
|
||||
protected:
|
||||
void *mScriptObject;
|
||||
nsIDOMMimeTypeArray* mMimeTypes;
|
||||
nsIDOMPluginArray* mPlugins;
|
||||
PluginArrayImpl* mPlugins;
|
||||
nsIDocShell* mDocShell; // weak reference
|
||||
};
|
||||
|
||||
class nsIURI;
|
||||
|
|
|
@ -28,11 +28,14 @@
|
|||
#include "nsIDOMMimeType.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIPluginHost.h"
|
||||
#include "nsIDocShell.h"
|
||||
|
||||
#include "nsIWebNavigation.h"
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_CID(kPluginManagerCID, NS_PLUGINMANAGER_CID);
|
||||
|
||||
PluginArrayImpl::PluginArrayImpl(nsIDOMNavigator* navigator)
|
||||
PluginArrayImpl::PluginArrayImpl(nsIDOMNavigator* navigator, nsIDocShell *aDocShell)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
mScriptObject = nsnull;
|
||||
|
@ -46,6 +49,7 @@ PluginArrayImpl::PluginArrayImpl(nsIDOMNavigator* navigator)
|
|||
|
||||
mPluginCount = 0;
|
||||
mPluginArray = nsnull;
|
||||
mDocShell = aDocShell;
|
||||
}
|
||||
|
||||
PluginArrayImpl::~PluginArrayImpl()
|
||||
|
@ -168,24 +172,50 @@ PluginArrayImpl::NamedItem(const nsAReadableString& aName,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
PluginArrayImpl::SetDocShell(nsIDocShell* aDocShell)
|
||||
{
|
||||
mDocShell = aDocShell;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
PluginArrayImpl::Refresh(PRBool aReloadDocuments)
|
||||
{
|
||||
if(mPluginHost == nsnull)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsresult res = NS_OK;
|
||||
|
||||
res = nsServiceManager::GetService(kPluginManagerCID, NS_GET_IID(nsIPluginHost), (nsISupports**)&mPluginHost);
|
||||
if (mPluginArray != nsnull)
|
||||
{
|
||||
for (PRUint32 i = 0; i < mPluginCount; i++)
|
||||
NS_IF_RELEASE(mPluginArray[i]);
|
||||
|
||||
delete[] mPluginArray;
|
||||
}
|
||||
|
||||
mPluginCount = 0;
|
||||
mPluginArray = nsnull;
|
||||
|
||||
if (mPluginHost == nsnull)
|
||||
res = nsServiceManager::GetService(kPluginManagerCID, NS_GET_IID(nsIPluginHost), (nsISupports**)&mPluginHost);
|
||||
|
||||
if(NS_FAILED(res))
|
||||
{
|
||||
mPluginHost = nsnull;
|
||||
return res;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPluginManager> pm = do_QueryInterface(mPluginHost);
|
||||
nsCOMPtr<nsIPluginManager> pm(do_QueryInterface(mPluginHost));
|
||||
|
||||
if(pm)
|
||||
pm->ReloadPlugins(aReloadDocuments);
|
||||
|
||||
if (aReloadDocuments && mDocShell)
|
||||
{
|
||||
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mDocShell));
|
||||
|
||||
if (webNav)
|
||||
webNav->Reload(nsIWebNavigation::LOAD_FLAGS_NONE);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,11 +28,12 @@
|
|||
#include "nsIDOMPlugin.h"
|
||||
|
||||
class nsIDOMNavigator;
|
||||
class nsIDocShell;
|
||||
struct nsIPluginHost;
|
||||
|
||||
class PluginArrayImpl : public nsIScriptObjectOwner, public nsIDOMPluginArray {
|
||||
public:
|
||||
PluginArrayImpl(nsIDOMNavigator* navigator);
|
||||
PluginArrayImpl(nsIDOMNavigator* navigator, nsIDocShell *aDocShell);
|
||||
virtual ~PluginArrayImpl();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
@ -48,12 +49,16 @@ public:
|
|||
private:
|
||||
nsresult GetPlugins();
|
||||
|
||||
public:
|
||||
void SetDocShell(nsIDocShell* aDocShell);
|
||||
|
||||
protected:
|
||||
void *mScriptObject;
|
||||
nsIDOMNavigator* mNavigator;
|
||||
nsIPluginHost* mPluginHost;
|
||||
PRUint32 mPluginCount;
|
||||
nsIDOMPlugin** mPluginArray;
|
||||
nsIDocShell* mDocShell; // weak reference
|
||||
};
|
||||
|
||||
class PluginElementImpl : public nsIScriptObjectOwner, public nsIDOMPlugin {
|
||||
|
|
Загрузка…
Ссылка в новой задаче