Bug 852848 - Add support for app-specific redirections r=bz,ferjm
This commit is contained in:
@@ -202,6 +202,8 @@
|
||||
#include "nsIAppShellService.h"
|
||||
#include "nsAppShellCID.h"
|
||||
|
||||
#include "nsIAppsService.h"
|
||||
|
||||
static NS_DEFINE_CID(kDOMScriptObjectFactoryCID,
|
||||
NS_DOM_SCRIPT_OBJECT_FACTORY_CID);
|
||||
static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
|
||||
@@ -6436,6 +6438,30 @@ nsDocShell::OnRedirectStateChange(nsIChannel* aOldChannel,
|
||||
if (!oldURI || !newURI) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if we have a redirect registered for this url.
|
||||
uint32_t appId;
|
||||
nsresult rv = GetAppId(&appId);
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (appId != nsIScriptSecurityManager::NO_APP_ID &&
|
||||
appId != nsIScriptSecurityManager::UNKNOWN_APP_ID) {
|
||||
nsCOMPtr<nsIAppsService> appsService =
|
||||
do_GetService(APPS_SERVICE_CONTRACTID);
|
||||
NS_ASSERTION(appsService, "No AppsService available");
|
||||
nsCOMPtr<nsIURI> redirect;
|
||||
rv = appsService->GetRedirect(appId, newURI, getter_AddRefs(redirect));
|
||||
if (NS_SUCCEEDED(rv) && redirect) {
|
||||
aNewChannel->Cancel(NS_BINDING_ABORTED);
|
||||
rv = LoadURI(redirect, nullptr, 0, false);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// On session restore we get a redirect from page to itself. Don't count it.
|
||||
bool equals = false;
|
||||
if (mTiming &&
|
||||
|
||||
Reference in New Issue
Block a user