Fixing bug 690952. Move window.navigator from the outer window to the inner window, and stop persisting it across same origin page navigations. r=mrbkap@gmail.com

This commit is contained in:
Johnny Stenback 2011-12-01 00:28:16 -08:00
parent 0f825bbcf1
commit 996178d61f
10 changed files with 111 additions and 259 deletions

View File

@ -90,28 +90,16 @@ Navigator::Init()
false);
}
Navigator::Navigator(nsIDocShell* aDocShell)
: mDocShell(aDocShell)
Navigator::Navigator(nsPIDOMWindow* aWindow)
: mWindow(do_GetWeakReference(aWindow))
{
NS_ASSERTION(aWindow->IsInnerWindow(),
"Navigator must get an inner window!");
}
Navigator::~Navigator()
{
if (mMimeTypes) {
mMimeTypes->Invalidate();
}
if (mPlugins) {
mPlugins->Invalidate();
}
if (mBatteryManager) {
mBatteryManager->Shutdown();
}
if (mSmsManager) {
mSmsManager->Shutdown();
}
Invalidate();
}
NS_INTERFACE_MAP_BEGIN(Navigator)
@ -129,12 +117,13 @@ NS_IMPL_ADDREF(Navigator)
NS_IMPL_RELEASE(Navigator)
void
Navigator::SetDocShell(nsIDocShell* aDocShell)
Navigator::Invalidate()
{
mDocShell = aDocShell;
mWindow = nsnull;
if (mPlugins) {
mPlugins->SetDocShell(aDocShell);
mPlugins->Invalidate();
mPlugins = nsnull;
}
// If there is a page transition, make sure delete the geolocation object.
@ -159,6 +148,15 @@ Navigator::SetDocShell(nsIDocShell* aDocShell)
}
}
nsPIDOMWindow *
Navigator::GetWindow()
{
nsCOMPtr<nsPIDOMWindow> win(do_QueryReferent(mWindow));
return win;
}
//*****************************************************************************
// Navigator::nsIDOMNavigator
//*****************************************************************************
@ -366,7 +364,9 @@ NS_IMETHODIMP
Navigator::GetPlugins(nsIDOMPluginArray** aPlugins)
{
if (!mPlugins) {
mPlugins = new nsPluginArray(this, mDocShell);
nsCOMPtr<nsPIDOMWindow> win(do_QueryReferent(mWindow));
mPlugins = new nsPluginArray(this, win ? win->GetDocShell() : nsnull);
}
NS_ADDREF(*aPlugins = mPlugins);
@ -388,7 +388,13 @@ Navigator::GetCookieEnabled(bool* aCookieEnabled)
// Check whether an exception overrides the global cookie behavior
// Note that the code for getting the URI here matches that in
// nsHTMLDocument::SetCookie.
nsCOMPtr<nsIDocument> doc = do_GetInterface(mDocShell);
nsCOMPtr<nsPIDOMWindow> win(do_QueryReferent(mWindow));
if (!win || !win->GetDocShell()) {
return NS_OK;
}
nsCOMPtr<nsIDocument> doc = do_QueryInterface(win->GetExtantDocument());
if (!doc) {
return NS_OK;
}
@ -508,50 +514,11 @@ Navigator::JavaEnabled(bool* aReturn)
}
void
Navigator::LoadingNewDocument()
{
// Release these so that they will be recreated for the
// new document (if requested). The plugins or mime types
// arrays may have changed. See bug 150087.
if (mMimeTypes) {
mMimeTypes->Invalidate();
mMimeTypes = nsnull;
}
if (mPlugins) {
mPlugins->Invalidate();
mPlugins = nsnull;
}
if (mGeolocation) {
mGeolocation->Shutdown();
mGeolocation = nsnull;
}
if (mNotification) {
mNotification->Shutdown();
mNotification = nsnull;
}
if (mBatteryManager) {
mBatteryManager->Shutdown();
mBatteryManager = nsnull;
}
if (mSmsManager) {
mSmsManager->Shutdown();
mSmsManager = nsnull;
}
}
nsresult
Navigator::RefreshMIMEArray()
{
if (mMimeTypes) {
return mMimeTypes->Refresh();
mMimeTypes->Refresh();
}
return NS_OK;
}
bool
@ -569,7 +536,9 @@ Navigator::RegisterContentHandler(const nsAString& aMIMEType,
const nsAString& aURI,
const nsAString& aTitle)
{
if (!mDocShell) {
nsCOMPtr<nsPIDOMWindow> win(do_QueryReferent(mWindow));
if (!win || !win->GetOuterWindow() || !win->GetDocShell()) {
return NS_OK;
}
@ -579,13 +548,8 @@ Navigator::RegisterContentHandler(const nsAString& aMIMEType,
return NS_OK;
}
nsCOMPtr<nsIDOMWindow> contentDOMWindow = do_GetInterface(mDocShell);
if (!contentDOMWindow) {
return NS_OK;
}
return registrar->RegisterContentHandler(aMIMEType, aURI, aTitle,
contentDOMWindow);
win->GetOuterWindow());
}
NS_IMETHODIMP
@ -593,7 +557,9 @@ Navigator::RegisterProtocolHandler(const nsAString& aProtocol,
const nsAString& aURI,
const nsAString& aTitle)
{
if (!mDocShell) {
nsCOMPtr<nsPIDOMWindow> win(do_QueryReferent(mWindow));
if (!win || !win->GetOuterWindow() || !win->GetDocShell()) {
return NS_OK;
}
@ -603,13 +569,8 @@ Navigator::RegisterProtocolHandler(const nsAString& aProtocol,
return NS_OK;
}
nsCOMPtr<nsIDOMWindow> contentDOMWindow = do_GetInterface(mDocShell);
if (!contentDOMWindow) {
return NS_OK;
}
return registrar->RegisterProtocolHandler(aProtocol, aURI, aTitle,
contentDOMWindow);
win->GetOuterWindow());
}
NS_IMETHODIMP
@ -702,12 +663,9 @@ NS_IMETHODIMP Navigator::GetGeolocation(nsIDOMGeoGeolocation** _retval)
return NS_OK;
}
if (!mDocShell) {
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsPIDOMWindow> win(do_QueryReferent(mWindow));
nsCOMPtr<nsIDOMWindow> contentDOMWindow = do_GetInterface(mDocShell);
if (!contentDOMWindow) {
if (!win || !win->GetOuterWindow() || !win->GetDocShell()) {
return NS_ERROR_FAILURE;
}
@ -716,7 +674,7 @@ NS_IMETHODIMP Navigator::GetGeolocation(nsIDOMGeoGeolocation** _retval)
return NS_ERROR_FAILURE;
}
if (NS_FAILED(mGeolocation->Init(contentDOMWindow))) {
if (NS_FAILED(mGeolocation->Init(win->GetOuterWindow()))) {
mGeolocation = nsnull;
return NS_ERROR_FAILURE;
}
@ -739,20 +697,14 @@ NS_IMETHODIMP Navigator::GetMozNotification(nsIDOMDesktopNotificationCenter** aR
return NS_OK;
}
nsCOMPtr<nsPIDOMWindow> window = do_GetInterface(mDocShell);
NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
nsCOMPtr<nsIDocument> document = do_GetInterface(mDocShell);
NS_ENSURE_TRUE(document, NS_ERROR_FAILURE);
nsIScriptGlobalObject* sgo = document->GetScopeObject();
NS_ENSURE_TRUE(sgo, NS_ERROR_FAILURE);
nsCOMPtr<nsPIDOMWindow> win(do_QueryReferent(mWindow));
nsCOMPtr<nsIScriptGlobalObject> sgo(do_QueryInterface(win));
NS_ENSURE_TRUE(sgo && win->GetDocShell(), NS_ERROR_FAILURE);
nsIScriptContext* scx = sgo->GetContext();
NS_ENSURE_TRUE(scx, NS_ERROR_FAILURE);
mNotification = new nsDesktopNotificationCenter(window->GetCurrentInnerWindow(),
scx);
mNotification = new nsDesktopNotificationCenter(win, scx);
NS_ADDREF(*aRetVal = mNotification);
return NS_OK;
@ -768,20 +720,15 @@ Navigator::GetMozBattery(nsIDOMMozBatteryManager** aBattery)
if (!mBatteryManager) {
*aBattery = nsnull;
nsCOMPtr<nsPIDOMWindow> window = do_GetInterface(mDocShell);
NS_ENSURE_TRUE(window, NS_OK);
nsCOMPtr<nsIDocument> document = do_GetInterface(mDocShell);
NS_ENSURE_TRUE(document, NS_OK);
nsIScriptGlobalObject* sgo = document->GetScopeObject();
NS_ENSURE_TRUE(sgo, NS_OK);
nsCOMPtr<nsPIDOMWindow> win(do_QueryReferent(mWindow));
nsCOMPtr<nsIScriptGlobalObject> sgo(do_QueryInterface(win));
NS_ENSURE_TRUE(sgo && win->GetDocShell(), NS_OK);
nsIScriptContext* scx = sgo->GetContext();
NS_ENSURE_TRUE(scx, NS_OK);
mBatteryManager = new battery::BatteryManager();
mBatteryManager->Init(window->GetCurrentInnerWindow(), scx);
mBatteryManager->Init(win, scx);
}
NS_ADDREF(*aBattery = mBatteryManager);
@ -809,7 +756,13 @@ Navigator::IsSmsAllowed() const
// For local files, "file://" must be listed.
// For data-urls: "moz-nullprincipal:".
// Chrome files also have to be whitelisted for the moment.
nsCOMPtr<nsIDocument> doc = do_GetInterface(mDocShell);
nsCOMPtr<nsPIDOMWindow> win(do_QueryReferent(mWindow));
if (!win || !win->GetDocShell()) {
return defaultSmsPermission;
}
nsCOMPtr<nsIDocument> doc = do_QueryInterface(win->GetExtantDocument());
if (!doc) {
return defaultSmsPermission;
}
@ -864,20 +817,17 @@ Navigator::GetMozSms(nsIDOMMozSmsManager** aSmsManager)
return NS_OK;
}
nsCOMPtr<nsPIDOMWindow> window = do_GetInterface(mDocShell);
NS_ENSURE_TRUE(window, NS_OK);
nsCOMPtr<nsPIDOMWindow> window = do_QueryReferent(mWindow);
NS_ENSURE_TRUE(window && window->GetDocShell(), NS_OK);
nsCOMPtr<nsIDocument> document = do_GetInterface(mDocShell);
NS_ENSURE_TRUE(document, NS_OK);
nsIScriptGlobalObject* sgo = document->GetScopeObject();
nsCOMPtr<nsIScriptGlobalObject> sgo = do_QueryInterface(window);
NS_ENSURE_TRUE(sgo, NS_OK);
nsIScriptContext* scx = sgo->GetContext();
NS_ENSURE_TRUE(scx, NS_OK);
mSmsManager = new sms::SmsManager();
mSmsManager->Init(window->GetCurrentInnerWindow(), scx);
mSmsManager->Init(window, scx);
}
NS_ADDREF(*aSmsManager = mSmsManager);

View File

@ -50,12 +50,13 @@
#include "nsIDOMNavigatorBattery.h"
#include "nsIDOMNavigatorSms.h"
#include "nsAutoPtr.h"
#include "nsWeakReference.h"
class nsPluginArray;
class nsMimeTypeArray;
class nsGeolocation;
class nsDesktopNotificationCenter;
class nsIDocShell;
class nsPIDOMWindow;
//*****************************************************************************
// Navigator: Script "navigator" object
@ -80,7 +81,7 @@ class Navigator : public nsIDOMNavigator,
public nsIDOMMozNavigatorSms
{
public:
Navigator(nsIDocShell *aDocShell);
Navigator(nsPIDOMWindow *aInnerWindow);
virtual ~Navigator();
NS_DECL_ISUPPORTS
@ -93,14 +94,10 @@ public:
static void Init();
void SetDocShell(nsIDocShell *aDocShell);
nsIDocShell *GetDocShell()
{
return mDocShell;
}
void Invalidate();
nsPIDOMWindow *GetWindow();
void LoadingNewDocument();
nsresult RefreshMIMEArray();
void RefreshMIMEArray();
static bool HasDesktopNotificationSupport();
@ -118,7 +115,7 @@ private:
nsRefPtr<nsDesktopNotificationCenter> mNotification;
nsRefPtr<battery::BatteryManager> mBatteryManager;
nsRefPtr<sms::SmsManager> mSmsManager;
nsIDocShell* mDocShell; // weak reference
nsWeakPtr mWindow;
};
} // namespace dom

View File

@ -6822,6 +6822,8 @@ nsWindowSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
&v, getter_AddRefs(holder));
NS_ENSURE_SUCCESS(rv, rv);
// Hold on to the navigator object as a global property so we
// don't need to worry about losing expando properties etc.
if (!::JS_DefinePropertyById(cx, obj, id, v, nsnull, nsnull,
JSPROP_READONLY | JSPROP_PERMANENT |
JSPROP_ENUMERATE)) {
@ -7154,11 +7156,9 @@ nsresult
nsNavigatorSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
JSObject *globalObj, JSObject **parentObj)
{
// window.navigator is persisted across document transitions if
// we're loading a page from the same origin. Because of that we
// need to parent the navigator wrapper at the outer window to avoid
// holding on to the inner window where the navigator was initially
// created too long.
// window.navigator can hold expandos and thus we need to only ever
// create one wrapper per navigator object so that expandos are
// visible independently of who's looking it up.
*parentObj = globalObj;
nsCOMPtr<nsIDOMNavigator> safeNav(do_QueryInterface(nativeObj));
@ -7170,20 +7170,17 @@ nsNavigatorSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
}
Navigator *nav = static_cast<Navigator*>(safeNav.get());
nsIDocShell *ds = nav->GetDocShell();
if (!ds) {
nsGlobalWindow *win = static_cast<nsGlobalWindow*>(nav->GetWindow());
if (!win) {
NS_WARNING("Refusing to create a navigator in the wrong scope");
return NS_ERROR_UNEXPECTED;
}
nsCOMPtr<nsIScriptGlobalObject> sgo = do_GetInterface(ds);
JSObject *global = win->GetGlobalJSObject();
if (sgo) {
JSObject *global = sgo->GetGlobalJSObject();
if (global) {
*parentObj = global;
}
if (global) {
*parentObj = global;
}
return NS_OK;

View File

@ -1272,6 +1272,11 @@ nsGlobalWindow::FreeInnerObjects(bool aClearScope)
{
NS_ASSERTION(IsInnerWindow(), "Don't free inner objects on an outer window");
// Make sure that this is called before we null out the document and
// other members that the window destroyed observers could
// re-create.
NotifyDOMWindowDestroyed(this);
// Kill all of the workers for this window.
nsIScriptContext *scx = GetContextInternal();
JSContext *cx = scx ? scx->GetNativeContext() : nsnull;
@ -1296,6 +1301,11 @@ nsGlobalWindow::FreeInnerObjects(bool aClearScope)
mLocation = nsnull;
mHistory = nsnull;
if (mNavigator) {
mNavigator->Invalidate();
mNavigator = nsnull;
}
if (mDocument) {
NS_ASSERTION(mDoc, "Why is mDoc null?");
@ -1308,9 +1318,6 @@ nsGlobalWindow::FreeInnerObjects(bool aClearScope)
nsCycleCollector_DEBUG_shouldBeFreed(nsCOMPtr<nsISupports>(do_QueryInterface(mDocument)));
#endif
// Make sure that this is called before we null out the document.
NotifyDOMWindowDestroyed(this);
// Remove our reference to the document and the document principal.
mDocument = nsnull;
mDoc = nsnull;
@ -1733,7 +1740,6 @@ public:
WindowStateHolder(nsGlobalWindow *aWindow,
nsIXPConnectJSObjectHolder *aHolder,
Navigator *aNavigator,
nsIXPConnectJSObjectHolder *aOuterProto,
nsIXPConnectJSObjectHolder *aOuterRealProto);
@ -1741,7 +1747,6 @@ public:
nsIXPConnectJSObjectHolder *GetInnerWindowHolder()
{ return mInnerWindowHolder; }
Navigator* GetNavigator() { return mNavigator; }
nsIXPConnectJSObjectHolder* GetOuterProto() { return mOuterProto; }
nsIXPConnectJSObjectHolder* GetOuterRealProto() { return mOuterRealProto; }
@ -1750,7 +1755,6 @@ public:
mInnerWindow = nsnull;
mInnerWindowHolder = nsnull;
mNavigator = nsnull;
mOuterProto = nsnull;
mOuterRealProto = nsnull;
}
@ -1762,7 +1766,6 @@ protected:
// We hold onto this to make sure the inner window doesn't go away. The outer
// window ends up recalculating it anyway.
nsCOMPtr<nsIXPConnectJSObjectHolder> mInnerWindowHolder;
nsRefPtr<Navigator> mNavigator;
nsCOMPtr<nsIXPConnectJSObjectHolder> mOuterProto;
nsCOMPtr<nsIXPConnectJSObjectHolder> mOuterRealProto;
};
@ -1771,11 +1774,9 @@ NS_DEFINE_STATIC_IID_ACCESSOR(WindowStateHolder, WINDOWSTATEHOLDER_IID)
WindowStateHolder::WindowStateHolder(nsGlobalWindow *aWindow,
nsIXPConnectJSObjectHolder *aHolder,
Navigator *aNavigator,
nsIXPConnectJSObjectHolder *aOuterProto,
nsIXPConnectJSObjectHolder *aOuterRealProto)
: mInnerWindow(aWindow),
mNavigator(aNavigator),
mOuterProto(aOuterProto),
mOuterRealProto(aOuterRealProto)
{
@ -1930,32 +1931,6 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
nsresult rv = NS_OK;
// Drop our reference to the navigator object unless we're reusing
// the existing inner window or the new document is from the same
// origin as the old document.
if (!reUseInnerWindow && mNavigator && oldPrincipal) {
bool equal;
rv = oldPrincipal->Equals(aDocument->NodePrincipal(), &equal);
if (NS_FAILED(rv) || !equal) {
// Different origins. Release the navigator object so it gets
// recreated for the new document. The plugins or mime types
// arrays may have changed. See bug 150087.
mNavigator->SetDocShell(nsnull);
mNavigator = nsnull;
}
}
if (mNavigator && aDocument != oldDoc) {
// We didn't drop our reference to our old navigator object and
// we're loading a new document. Notify the navigator object about
// the new document load so that it can make sure it is ready for
// the new document.
mNavigator->LoadingNewDocument();
}
// Set mDocument even if this is an outer window to avoid
// having to *always* reach into the inner window to find the
// document.
@ -1973,8 +1948,6 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
nsRefPtr<nsGlobalWindow> newInnerWindow;
bool thisChrome = IsChromeWindow();
nsCOMPtr<nsIXPConnectJSObjectHolder> navigatorHolder;
jsval nav;
bool isChrome = false;
@ -1994,11 +1967,6 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
// inner scope.
mContext->ClearScope(mJSObject, false);
// This code should not be called during shutdown any more (now that
// we don't ever call SetNewDocument(nsnull), so no need to null
// check xpc here.
nsIXPConnect *xpc = nsContentUtils::XPConnect();
nsCOMPtr<nsIXPConnectWrappedNative> wrapper;
if (reUseInnerWindow) {
// We're reusing the current inner window.
NS_ASSERTION(!currentInner->IsFrozen(),
@ -2023,15 +1991,6 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
mInnerWindowHolder = wsh->GetInnerWindowHolder();
NS_ASSERTION(newInnerWindow, "Got a state without inner window");
// These assignments addref.
mNavigator = wsh->GetNavigator();
if (mNavigator) {
// Update mNavigator's docshell pointer now.
mNavigator->SetDocShell(mDocShell);
mNavigator->LoadingNewDocument();
}
} else if (thisChrome) {
newInnerWindow = new nsGlobalChromeWindow(this);
isChrome = true;
@ -2041,21 +2000,6 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
newInnerWindow = new nsGlobalWindow(this);
}
if (currentInner && currentInner->mJSObject) {
if (mNavigator && !aState) {
// Hold on to the navigator wrapper so that we can set
// window.navigator in the new window to point to the same
// object (assuming we didn't change origins etc). See bug
// 163645 for more on why we need this.
nsIDOMNavigator* navigator =
static_cast<nsIDOMNavigator*>(mNavigator.get());
nsContentUtils::WrapNative(cx, currentInner->mJSObject, navigator,
&NS_GET_IID(nsIDOMNavigator), &nav,
getter_AddRefs(navigatorHolder));
}
}
if (!aState) {
// This is redundant if we're restoring from a previous inner window.
nsIScriptGlobalObject *sgo =
@ -2289,33 +2233,6 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
// Initialize DOM classes etc on the inner window.
rv = mContext->InitClasses(newInnerWindow->mJSObject);
NS_ENSURE_SUCCESS(rv, rv);
if (navigatorHolder) {
JS_ASSERT(JSVAL_IS_OBJECT(nav));
if (js::GetObjectCompartment(JSVAL_TO_OBJECT(nav)) ==
js::GetObjectCompartment(newInnerWindow->mJSObject)) {
// Restore window.navigator onto the new inner window.
::JS_DefineProperty(cx, newInnerWindow->mJSObject, "navigator",
nav, nsnull, nsnull,
JSPROP_ENUMERATE | JSPROP_PERMANENT |
JSPROP_READONLY);
// The Navigator's prototype object keeps a reference to the
// window in which it was first created and can thus cause that
// window to stay alive for too long. Reparenting it here allows
// the window to be collected sooner.
nsIDOMNavigator* navigator =
static_cast<nsIDOMNavigator*>(mNavigator);
xpc->
ReparentWrappedNativeIfFound(cx, JSVAL_TO_OBJECT(nav),
newInnerWindow->mJSObject,
navigator,
getter_AddRefs(navigatorHolder));
}
}
}
if (mArguments) {
@ -2502,8 +2419,8 @@ nsGlobalWindow::SetDocShell(nsIDocShell* aDocShell)
mDocShell = aDocShell; // Weak Reference
if (mNavigator)
mNavigator->SetDocShell(aDocShell);
NS_ASSERTION(!mNavigator, "Non-null mNavigator in outer window!");
if (mFrames)
mFrames->SetDocShell(aDocShell);
if (mScreen)
@ -2999,12 +2916,12 @@ nsGlobalWindow::GetSelf(nsIDOMWindow** aWindow)
NS_IMETHODIMP
nsGlobalWindow::GetNavigator(nsIDOMNavigator** aNavigator)
{
FORWARD_TO_OUTER(GetNavigator, (aNavigator), NS_ERROR_NOT_INITIALIZED);
FORWARD_TO_INNER(GetNavigator, (aNavigator), NS_ERROR_NOT_INITIALIZED);
*aNavigator = nsnull;
if (!mNavigator) {
mNavigator = new Navigator(mDocShell);
mNavigator = new Navigator(this);
}
NS_ADDREF(*aNavigator = mNavigator);
@ -9960,7 +9877,6 @@ nsGlobalWindow::SaveWindowState(nsISupports **aState)
nsCOMPtr<nsISupports> state = new WindowStateHolder(inner,
mInnerWindowHolder,
mNavigator,
proto,
realProtoHolder);
NS_ENSURE_TRUE(state, NS_ERROR_OUT_OF_MEMORY);

View File

@ -210,20 +210,23 @@ nsMimeTypeArray::NamedItem(const nsAString& aName, nsIDOMMimeType** aReturn)
return rv;
}
void nsMimeTypeArray::Clear()
void
nsMimeTypeArray::Clear()
{
mInited = false;
mMimeTypeArray.Clear();
mPluginMimeTypeCount = 0;
}
nsresult nsMimeTypeArray::Refresh()
void
nsMimeTypeArray::Refresh()
{
Clear();
return GetMimeTypes();
GetMimeTypes();
}
nsresult nsMimeTypeArray::GetMimeTypes()
nsresult
nsMimeTypeArray::GetMimeTypes()
{
NS_PRECONDITION(!mInited && mPluginMimeTypeCount==0,
"already initialized");

View File

@ -58,7 +58,7 @@ public:
NS_DECL_ISUPPORTS
NS_DECL_NSIDOMMIMETYPEARRAY
nsresult Refresh();
void Refresh();
nsIDOMMimeType* GetItemAt(PRUint32 aIndex, nsresult* aResult);
nsIDOMMimeType* GetNamedItem(const nsAString& aName, nsresult* aResult);

View File

@ -55,13 +55,12 @@ using namespace mozilla::dom;
nsPluginArray::nsPluginArray(Navigator* navigator,
nsIDocShell *aDocShell)
: mNavigator(navigator),
mPluginHost(do_GetService(MOZ_PLUGIN_HOST_CONTRACTID)),
mPluginCount(0),
mPluginArray(nsnull),
mDocShell(do_GetWeakReference(aDocShell))
{
nsresult rv;
mNavigator = navigator; // don't ADDREF here, needed for parent of script object.
mPluginHost = do_GetService(MOZ_PLUGIN_HOST_CONTRACTID, &rv);
mPluginCount = 0;
mPluginArray = nsnull;
mDocShell = aDocShell;
}
nsPluginArray::~nsPluginArray()
@ -101,8 +100,10 @@ bool
nsPluginArray::AllowPlugins()
{
bool allowPlugins = false;
if (mDocShell)
if (NS_FAILED(mDocShell->GetAllowPlugins(&allowPlugins)))
nsCOMPtr<nsIDocShell> docShell = do_QueryReferent(mDocShell);
if (docShell)
if (NS_FAILED(docShell->GetAllowPlugins(&allowPlugins)))
allowPlugins = false;
return allowPlugins;
@ -193,12 +194,6 @@ nsPluginArray::GetPluginHost(nsIPluginHost** aPluginHost)
return rv;
}
void
nsPluginArray::SetDocShell(nsIDocShell *aDocShell)
{
mDocShell = aDocShell;
}
void
nsPluginArray::Invalidate()
{
@ -232,7 +227,7 @@ nsPluginArray::Refresh(bool aReloadDocuments)
if(pluginsNotChanged)
return res;
nsCOMPtr<nsIWebNavigation> webNav = do_QueryInterface(mDocShell);
nsCOMPtr<nsIWebNavigation> webNav = do_QueryReferent(mDocShell);
if (mPluginArray != nsnull) {
for (PRUint32 i = 0; i < mPluginCount; i++)

View File

@ -43,6 +43,7 @@
#include "nsIDOMPlugin.h"
#include "nsIPluginHost.h"
#include "nsIURL.h"
#include "nsWeakReference.h"
namespace mozilla {
namespace dom {
@ -92,7 +93,6 @@ private:
bool AllowPlugins();
public:
void SetDocShell(nsIDocShell *aDocShell);
void Invalidate();
protected:
@ -100,7 +100,7 @@ protected:
nsCOMPtr<nsIPluginHost> mPluginHost;
PRUint32 mPluginCount;
nsIDOMPlugin** mPluginArray;
nsIDocShell* mDocShell; // weak reference
nsWeakPtr mDocShell;
};
class nsPluginElement : public nsIDOMPlugin

View File

@ -154,8 +154,6 @@ IsPermitted(const char *name, JSFlatString *prop, bool set)
NAME('L', "Location",
PROP('h', W("hash") W("href"))
PROP('r', R("replace")))
NAME('N', "Navigator",
PROP('p', RW("preference")))
NAME('W', "Window",
PROP('b', R("blur"))
PROP('c', R("close") R("closed"))

View File

@ -418,10 +418,6 @@ pref("capability.policy.default.Location.hash.set", "allAccess");
pref("capability.policy.default.Location.href.set", "allAccess");
pref("capability.policy.default.Location.replace.get", "allAccess");
pref("capability.policy.default.Navigator.preference", "allAccess");
pref("capability.policy.default.Navigator.preferenceinternal.get", "UniversalPreferencesRead");
pref("capability.policy.default.Navigator.preferenceinternal.set", "UniversalPreferencesWrite");
pref("capability.policy.default.Window.blur.get", "allAccess");
pref("capability.policy.default.Window.close.get", "allAccess");
pref("capability.policy.default.Window.closed.get", "allAccess");