Bug 575561 - External links from within app tabs should always open in new tabs instead of replacing the app tab's page. r=gavin+bz, a=blocking-beta7

This commit is contained in:
Margaret Leibovic
2010-10-28 15:00:31 -07:00
parent b5fd5c70bc
commit f819993ce1
13 changed files with 177 additions and 8 deletions

View File

@@ -159,7 +159,7 @@
#include "nsIController.h"
#include "nsPICommandUpdater.h"
#include "nsIDOMHTMLAnchorElement.h"
#include "nsIWebBrowserChrome2.h"
#include "nsIWebBrowserChrome3.h"
#include "nsITabChild.h"
#include "nsIStrictTransportSecurityService.h"
@@ -711,6 +711,7 @@ nsDocShell::nsDocShell():
mAllowKeywordFixup(PR_FALSE),
mIsOffScreenBrowser(PR_FALSE),
mIsActive(PR_TRUE),
mIsAppTab(PR_FALSE),
mFiredUnloadEvent(PR_FALSE),
mEODForCurrentDocument(PR_FALSE),
mURIResultedInDocument(PR_FALSE),
@@ -4802,6 +4803,20 @@ nsDocShell::GetIsActive(PRBool *aIsActive)
return NS_OK;
}
NS_IMETHODIMP
nsDocShell::SetIsAppTab(PRBool aIsAppTab)
{
mIsAppTab = aIsAppTab;
return NS_OK;
}
NS_IMETHODIMP
nsDocShell::GetIsAppTab(PRBool *aIsAppTab)
{
*aIsAppTab = mIsAppTab;
return NS_OK;
}
NS_IMETHODIMP
nsDocShell::SetVisibility(PRBool aVisibility)
{
@@ -11311,8 +11326,22 @@ nsDocShell::OnLinkClick(nsIContent* aContent,
return NS_OK;
}
nsresult rv = NS_ERROR_FAILURE;
nsAutoString target;
nsCOMPtr<nsIWebBrowserChrome3> browserChrome3 = do_GetInterface(mTreeOwner);
if (browserChrome3) {
nsCOMPtr<nsIDOMNode> linkNode = do_QueryInterface(aContent);
nsAutoString oldTarget(aTargetSpec);
rv = browserChrome3->OnBeforeLinkTraversal(oldTarget, aURI,
linkNode, mIsAppTab, target);
}
if (NS_FAILED(rv))
target = aTargetSpec;
nsCOMPtr<nsIRunnable> ev =
new OnLinkClickEvent(this, aContent, aURI, aTargetSpec,
new OnLinkClickEvent(this, aContent, aURI, target.get(),
aPostDataStream, aHeadersDataStream);
return NS_DispatchToCurrentThread(ev);
}