Bug 804495 - Allow nsGlobalWindow to support GetInterface(nsILoadContext) r=bz

This commit is contained in:
Jason Duell 2012-10-24 21:25:00 -07:00
parent 9cd57f4799
commit 7e1293e86e
2 changed files with 13 additions and 21 deletions

View File

@ -8539,25 +8539,15 @@ nsGlobalWindow::GetInterface(const nsIID & aIID, void **aSink)
if (aIID.Equals(NS_GET_IID(nsIDocCharset))) {
FORWARD_TO_OUTER(GetInterface, (aIID, aSink), NS_ERROR_NOT_INITIALIZED);
if (mDocShell) {
nsCOMPtr<nsIDocCharset> docCharset(do_QueryInterface(mDocShell));
if (docCharset) {
NS_WARNING("Using deprecated nsIDocCharset: use nsIDocShell.GetCharset() instead ");
*aSink = docCharset;
NS_ADDREF(((nsISupports *) *aSink));
}
}
NS_WARNING("Using deprecated nsIDocCharset: use nsIDocShell.GetCharset() instead ");
nsCOMPtr<nsIDocCharset> docCharset(do_QueryInterface(mDocShell));
docCharset.forget(aSink);
}
else if (aIID.Equals(NS_GET_IID(nsIWebNavigation))) {
FORWARD_TO_OUTER(GetInterface, (aIID, aSink), NS_ERROR_NOT_INITIALIZED);
if (mDocShell) {
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mDocShell));
if (webNav) {
*aSink = webNav;
NS_ADDREF(((nsISupports *) *aSink));
}
}
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mDocShell));
webNav.forget(aSink);
}
else if (aIID.Equals(NS_GET_IID(nsIDocShell))) {
FORWARD_TO_OUTER(GetInterface, (aIID, aSink), NS_ERROR_NOT_INITIALIZED);
@ -8574,10 +8564,7 @@ nsGlobalWindow::GetInterface(const nsIID & aIID, void **aSink)
mDocShell->GetContentViewer(getter_AddRefs(viewer));
if (viewer) {
nsCOMPtr<nsIWebBrowserPrint> webBrowserPrint(do_QueryInterface(viewer));
if (webBrowserPrint) {
*aSink = webBrowserPrint;
NS_ADDREF(((nsISupports *) *aSink));
}
webBrowserPrint.forget(aSink);
}
}
}
@ -8592,6 +8579,12 @@ nsGlobalWindow::GetInterface(const nsIID & aIID, void **aSink)
*aSink = mWindowUtils;
NS_ADDREF(((nsISupports *) *aSink));
}
else if (aIID.Equals(NS_GET_IID(nsILoadContext))) {
FORWARD_TO_OUTER(GetInterface, (aIID, aSink), NS_ERROR_NOT_INITIALIZED);
nsCOMPtr<nsILoadContext> loadContext(do_QueryInterface(mDocShell));
loadContext.forget(aSink);
}
else {
return QueryInterface(aIID, aSink);
}

View File

@ -95,8 +95,7 @@ GetAppIDAndInBrowserFromWindow(nsIDOMWindow *aWindow,
return NS_OK;
}
nsCOMPtr<nsIWebNavigation> webNav = do_GetInterface(aWindow);
nsCOMPtr<nsILoadContext> loadContext = do_QueryInterface(webNav);
nsCOMPtr<nsILoadContext> loadContext = do_GetInterface(aWindow);
if (!loadContext) {
return NS_OK;
}