Bug 307770: pass the blocked host to xpinstall-install-blocked observers so that they can offer to whitelist the correct URI (fix installation of XPIs from target="blank" links), r=mano, sr=dveditz

This commit is contained in:
gavin@gavinsharp.com 2007-08-19 13:51:30 -07:00
parent aa99ae9139
commit 0995a3d991
2 changed files with 12 additions and 10 deletions

View File

@ -668,7 +668,7 @@ const gXPInstallObserver = {
var shell = aSubject.QueryInterface(Components.interfaces.nsIDocShell);
browser = this._getBrowser(shell);
if (browser) {
var host = browser.docShell.QueryInterface(Components.interfaces.nsIWebNavigation).currentURI.host;
var host = aData;
var brandShortName = brandBundle.getString("brandShortName");
var notificationName, messageString, buttons;
if (!gPrefService.getBoolPref("xpinstall.enabled")) {
@ -693,9 +693,6 @@ const gXPInstallObserver = {
}
}
else {
// XXXben - use regular software install warnings for now until we can
// properly differentiate themes. It's likely in fact that themes won't
// be blocked so this code path will only be reached for extensions.
notificationName = "xpinstall"
messageString = browserBundle.getFormattedString("xpinstallPromptWarning",
[brandShortName, host]);
@ -704,7 +701,7 @@ const gXPInstallObserver = {
label: browserBundle.getString("xpinstallPromptWarningButton"),
accessKey: browserBundle.getString("xpinstallPromptWarningButton.accesskey"),
popup: null,
callback: function() { return xpinstallEditPermissions(shell); }
callback: function() { return xpinstallEditPermissions(shell, host); }
}];
}
@ -721,16 +718,15 @@ const gXPInstallObserver = {
}
};
function xpinstallEditPermissions(aDocShell)
function xpinstallEditPermissions(aDocShell, aHost)
{
var browser = gXPInstallObserver._getBrowser(aDocShell);
if (browser) {
var bundlePreferences = document.getElementById("bundle_preferences");
var webNav = aDocShell.QueryInterface(Components.interfaces.nsIWebNavigation);
var params = { blockVisible : false,
sessionVisible : false,
allowVisible : true,
prefilledHost : webNav.currentURI.host,
prefilledHost : aHost,
permissionType : "install",
windowTitle : bundlePreferences.getString("addons_permissions_title"),
introText : bundlePreferences.getString("addonspermissionstext") };

View File

@ -193,6 +193,10 @@ nsInstallTrigger::HandleContent(const char * aContentType,
// We have what we need to start an XPInstall, now figure out if we are
// going to honor this request based on PermissionManager settings
PRBool enabled = PR_FALSE;
// Keep the host so that it can be sent to the
// xpinstall-install-blocked observers to display the host to be
// whitelisted
nsCAutoString host;
if ( useReferrer )
{
@ -205,6 +209,7 @@ nsInstallTrigger::HandleContent(const char * aContentType,
// site is one which is allowed to annoy the user with modal dialogs.
enabled = AllowInstall( referringURI );
referringURI->GetHost(host);
}
else
{
@ -241,6 +246,7 @@ nsInstallTrigger::HandleContent(const char * aContentType,
// trusted sites.
enabled = AllowInstall( uri );
uri->GetHost(host);
}
@ -257,8 +263,8 @@ nsInstallTrigger::HandleContent(const char * aContentType,
nsCOMPtr<nsIObserverService> os(do_GetService("@mozilla.org/observer-service;1"));
if (os) {
os->NotifyObservers(win->GetDocShell(),
"xpinstall-install-blocked",
NS_LITERAL_STRING("install-chrome").get());
"xpinstall-install-blocked",
NS_ConvertUTF8toUTF16(host).get());
}
rv = NS_ERROR_ABORT;
}