Bug 283276 - Plugin finder service freezes when attempting to install plugins and not accepting first license. r=mkaply

This commit is contained in:
doronr%us.ibm.com 2005-02-25 16:18:11 +00:00
Родитель 003772fd36
Коммит d9dd4ddf58
1 изменённых файлов: 54 добавлений и 16 удалений

Просмотреть файл

@ -64,7 +64,9 @@ function nsPluginInstallerWizard(){
if ("arguments" in window) { if ("arguments" in window) {
for (var item in window.arguments[0].plugins){ for (var item in window.arguments[0].plugins){
this.mPluginRequestArray[window.arguments[0].plugins[item].mimetype] = new nsPluginRequest(window.arguments[0].plugins[item]); this.mPluginRequestArray[window.arguments[0].plugins[item].mimetype] =
new nsPluginRequest(window.arguments[0].plugins[item]);
this.mPluginRequestArrayLength++; this.mPluginRequestArrayLength++;
} }
@ -73,14 +75,14 @@ function nsPluginInstallerWizard(){
this.WSPluginCounter = 0; this.WSPluginCounter = 0;
this.licenseAcceptCounter = 0; this.licenseAcceptCounter = 0;
this.prefBranch = null; this.prefBranch = null;
} }
nsPluginInstallerWizard.prototype.getPluginData = function (){ nsPluginInstallerWizard.prototype.getPluginData = function (){
// for each mPluginRequestArray item, call the datasource // for each mPluginRequestArray item, call the datasource
this.WSPluginCounter = 0; this.WSPluginCounter = 0;
// initiate the datasource call // initiate the datasource call
var rdfUpdater = new nsRDFItemUpdater(this.getOS(), this.getChromeLocale()); var rdfUpdater = new nsRDFItemUpdater(this.getOS(), this.getChromeLocale());
@ -108,7 +110,7 @@ nsPluginInstallerWizard.prototype.pluginInfoReceived = function (aPluginInfo){
if (progressMeter.getAttribute("mode") == "undetermined") if (progressMeter.getAttribute("mode") == "undetermined")
progressMeter.setAttribute("mode", "determined"); progressMeter.setAttribute("mode", "determined");
progressMeter.setAttribute("value", progressMeter.setAttribute("value",
((this.WSPluginCounter / this.mPluginRequestArrayLength) * 100) + "%"); ((this.WSPluginCounter / this.mPluginRequestArrayLength) * 100) + "%");
if (this.WSPluginCounter == this.mPluginRequestArrayLength) { if (this.WSPluginCounter == this.mPluginRequestArrayLength) {
@ -117,11 +119,11 @@ nsPluginInstallerWizard.prototype.pluginInfoReceived = function (aPluginInfo){
this.advancePage("lastpage", true, false, false); this.advancePage("lastpage", true, false, false);
} else { } else {
this.advancePage(null, true, false, true); this.advancePage(null, true, false, true);
} }
} else { } else {
// process more. // process more.
} }
} }
nsPluginInstallerWizard.prototype.showPluginList = function (){ nsPluginInstallerWizard.prototype.showPluginList = function (){
var myPluginList = document.getElementById("pluginList"); var myPluginList = document.getElementById("pluginList");
@ -145,7 +147,7 @@ nsPluginInstallerWizard.prototype.showPluginList = function (){
myCheckbox.setAttribute("src", pluginInfo.IconUrl); myCheckbox.setAttribute("src", pluginInfo.IconUrl);
myPluginList.appendChild(myCheckbox); myPluginList.appendChild(myCheckbox);
if (pluginInfo.InstallerShowsUI == "true") if (pluginInfo.InstallerShowsUI == "true")
hasPluginWithInstallerUI = true; hasPluginWithInstallerUI = true;
} }
@ -155,7 +157,7 @@ nsPluginInstallerWizard.prototype.showPluginList = function (){
this.canAdvance(true); this.canAdvance(true);
this.canRewind(false); this.canRewind(false);
} }
nsPluginInstallerWizard.prototype.toggleInstallPlugin = function (aPid, aCheckbox) { nsPluginInstallerWizard.prototype.toggleInstallPlugin = function (aPid, aCheckbox) {
this.mPluginInfoArray[aPid].toBeInstalled = aCheckbox.checked; this.mPluginInfoArray[aPid].toBeInstalled = aCheckbox.checked;
@ -202,7 +204,14 @@ nsPluginInstallerWizard.prototype.showLicenses = function (){
this.advancePage(null, false, false, false); this.advancePage(null, false, false, false);
} else { } else {
this.licenseAcceptCounter = 0; this.licenseAcceptCounter = 0;
document.getElementById("licenseIFrame").contentWindow.addEventListener("load", gPluginInstaller.enableNext, false);
// add a nsIWebProgress listener to the license iframe.
var docShell = document.getElementById("licenseIFrame").docShell;
var iiReq = docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor);
var webProgress = iiReq.getInterface(Components.interfaces.nsIWebProgress);
webProgress.addProgressListener(gPluginInstaller.progressListener,
Components.interfaces.nsIWebProgress.NOTIFY_ALL);
this.showLicense(); this.showLicense();
} }
} }
@ -213,11 +222,40 @@ nsPluginInstallerWizard.prototype.enableNext = function (){
document.getElementById("licenseRadioGroup2").disabled = false; document.getElementById("licenseRadioGroup2").disabled = false;
} }
const nsIWebProgressListener = Components.interfaces.nsIWebProgressListener;
nsPluginInstallerWizard.prototype.progressListener = {
onStateChange : function(aWebProgress, aRequest, aStateFlags, aStatus)
{
if ((aStateFlags & nsIWebProgressListener.STATE_STOP) &&
(aStateFlags & nsIWebProgressListener.STATE_IS_NETWORK)) {
// iframe loaded
gPluginInstaller.enableNext();
}
},
onProgressChange : function(aWebProgress, aRequest, aCurSelfProgress,
aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress)
{},
onStatusChange : function(aWebProgress, aRequest, aStatus, aMessage)
{},
QueryInterface : function(aIID)
{
if (aIID.equals(Components.interfaces.nsIWebProgressListener) ||
aIID.equals(Components.interfaces.nsISupportsWeakReference) ||
aIID.equals(Components.interfaces.nsISupports))
return this;
throw Components.results.NS_NOINTERFACE;
}
}
nsPluginInstallerWizard.prototype.showLicense = function (){ nsPluginInstallerWizard.prototype.showLicense = function (){
var pluginInfo = this.mPluginInfoArray[this.mPluginLicenseArray[this.licenseAcceptCounter]]; var pluginInfo = this.mPluginInfoArray[this.mPluginLicenseArray[this.licenseAcceptCounter]];
this.canAdvance(false); this.canAdvance(false);
document.getElementById("licenseIFrame").setAttribute("src", pluginInfo.licenseURL);
loadFlags = Components.interfaces.nsIWebNavigation.LOAD_FLAGS_NONE;
document.getElementById("licenseIFrame").webNavigation.loadURI(pluginInfo.licenseURL, loadFlags, null, null, null);
document.getElementById("pluginLicenseLabel").firstChild.nodeValue = document.getElementById("pluginLicenseLabel").firstChild.nodeValue =
this.getFormattedString("pluginLicenseAgreement.label", [pluginInfo.name]); this.getFormattedString("pluginLicenseAgreement.label", [pluginInfo.name]);
@ -274,7 +312,7 @@ nsPluginInstallerWizard.prototype.advancePage = function (aPageId, aCanAdvance,
this.canAdvance(aCanAdvance); this.canAdvance(aCanAdvance);
this.canRewind(aCanRewind); this.canRewind(aCanRewind);
this.canCancel(aCanCancel); this.canCancel(aCanCancel);
} }
nsPluginInstallerWizard.prototype.startPluginInstallation = function (){ nsPluginInstallerWizard.prototype.startPluginInstallation = function (){
this.canAdvance(false); this.canAdvance(false);
@ -292,7 +330,7 @@ nsPluginInstallerWizard.prototype.startPluginInstallation = function (){
if (pluginItem.toBeInstalled && pluginItem.licenseAccepted) { if (pluginItem.toBeInstalled && pluginItem.licenseAccepted) {
pluginURLArray.push(pluginItem.XPILocation); pluginURLArray.push(pluginItem.XPILocation);
pluginPidArray.push(pluginItem.pid); pluginPidArray.push(pluginItem.pid);
} }
} }
if (pluginURLArray.length > 0) if (pluginURLArray.length > 0)
@ -308,24 +346,24 @@ nsPluginInstallerWizard.prototype.startPluginInstallation = function (){
3 finished installation 3 finished installation
4 all done 4 all done
*/ */
nsPluginInstallerWizard.prototype.pluginInstallationProgress = function (aPid, aProgress, aError){ nsPluginInstallerWizard.prototype.pluginInstallationProgress = function (aPid, aProgress, aError) {
var statMsg = null; var statMsg = null;
var pluginInfo = gPluginInstaller.mPluginInfoArray[aPid]; var pluginInfo = gPluginInstaller.mPluginInfoArray[aPid];
switch (aProgress) { switch (aProgress) {
case 0: case 0:
statMsg = this.getFormattedString("pluginInstallation.download.start", [pluginInfo.name]); statMsg = this.getFormattedString("pluginInstallation.download.start", [pluginInfo.name]);
break; break;
case 1: case 1:
statMsg = this.getFormattedString("pluginInstallation.download.finish", [pluginInfo.name]); statMsg = this.getFormattedString("pluginInstallation.download.finish", [pluginInfo.name]);
break; break;
case 2: case 2:
statMsg = this.getFormattedString("pluginInstallation.install.start", [pluginInfo.name]); statMsg = this.getFormattedString("pluginInstallation.install.start", [pluginInfo.name]);
break; break;
case 3: case 3:
if (aError) { if (aError) {