michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: function nsPluginInstallerWizard(){ michael@0: michael@0: // create the request array michael@0: this.mPluginRequests = new Map(); michael@0: michael@0: // create the plugin info array. michael@0: // a hash indexed by plugin id so we don't install michael@0: // the same plugin more than once. michael@0: this.mPluginInfoArray = new Object(); michael@0: this.mPluginInfoArrayLength = 0; michael@0: michael@0: // holds plugins we couldn't find michael@0: this.mPluginNotFoundArray = new Object(); michael@0: this.mPluginNotFoundArrayLength = 0; michael@0: michael@0: // array holding pids of plugins that require a license michael@0: this.mPluginLicenseArray = new Array(); michael@0: michael@0: // how many plugins are to be installed michael@0: this.pluginsToInstallNum = 0; michael@0: michael@0: this.mBrowser = null; michael@0: this.mSuccessfullPluginInstallation = 0; michael@0: this.mNeedsRestart = false; michael@0: michael@0: // arguments[0] is an object that contains two items: michael@0: // a mimetype->pluginInfo map of missing plugins, michael@0: // a reference to the browser that needs them, michael@0: // so we can notify which browser can be reloaded. michael@0: michael@0: if ("arguments" in window) { michael@0: for (let [mimetype, pluginInfo] of window.arguments[0].plugins){ michael@0: this.mPluginRequests.set(mimetype, new nsPluginRequest(pluginInfo)); michael@0: } michael@0: michael@0: this.mBrowser = window.arguments[0].browser; michael@0: } michael@0: michael@0: this.WSPluginCounter = 0; michael@0: this.licenseAcceptCounter = 0; michael@0: michael@0: this.prefBranch = null; michael@0: } michael@0: michael@0: nsPluginInstallerWizard.prototype.getPluginData = function (){ michael@0: // for each mPluginRequests item, call the datasource michael@0: this.WSPluginCounter = 0; michael@0: michael@0: // initiate the datasource call michael@0: var rdfUpdater = new nsRDFItemUpdater(this.getOS(), this.getChromeLocale()); michael@0: michael@0: for (let [mimetype, pluginRequest] of this.mPluginRequests) { michael@0: rdfUpdater.checkForPlugin(pluginRequest); michael@0: } michael@0: } michael@0: michael@0: // aPluginInfo is null if the datasource call failed, and pid is -1 if michael@0: // no matching plugin was found. michael@0: nsPluginInstallerWizard.prototype.pluginInfoReceived = function (aPluginRequestItem, aPluginInfo){ michael@0: this.WSPluginCounter++; michael@0: michael@0: if (aPluginInfo && (aPluginInfo.pid != -1) ) { michael@0: // hash by id michael@0: this.mPluginInfoArray[aPluginInfo.pid] = new PluginInfo(aPluginInfo); michael@0: this.mPluginInfoArrayLength++; michael@0: } else { michael@0: this.mPluginNotFoundArray[aPluginRequestItem.mimetype] = aPluginRequestItem; michael@0: this.mPluginNotFoundArrayLength++; michael@0: } michael@0: michael@0: var progressMeter = document.getElementById("ws_request_progress"); michael@0: michael@0: if (progressMeter.getAttribute("mode") == "undetermined") michael@0: progressMeter.setAttribute("mode", "determined"); michael@0: michael@0: progressMeter.setAttribute("value", michael@0: ((this.WSPluginCounter / this.mPluginRequests.size) * 100) + "%"); michael@0: michael@0: if (this.WSPluginCounter == this.mPluginRequests.size) { michael@0: // check if no plugins were found michael@0: if (this.mPluginInfoArrayLength == 0) { michael@0: this.advancePage("lastpage"); michael@0: } else { michael@0: this.advancePage(null); michael@0: } michael@0: } else { michael@0: // process more. michael@0: } michael@0: } michael@0: michael@0: nsPluginInstallerWizard.prototype.showPluginList = function (){ michael@0: var myPluginList = document.getElementById("pluginList"); michael@0: var hasPluginWithInstallerUI = false; michael@0: michael@0: // clear children michael@0: for (var run = myPluginList.childNodes.length; run > 0; run--) michael@0: myPluginList.removeChild(myPluginList.childNodes.item(run)); michael@0: michael@0: this.pluginsToInstallNum = 0; michael@0: michael@0: for (var pluginInfoItem in this.mPluginInfoArray){ michael@0: // [plugin image] [Plugin_Name Plugin_Version] michael@0: michael@0: var pluginInfo = this.mPluginInfoArray[pluginInfoItem]; michael@0: michael@0: // create the checkbox michael@0: var myCheckbox = document.createElement("checkbox"); michael@0: myCheckbox.setAttribute("checked", "true"); michael@0: myCheckbox.setAttribute("oncommand", "gPluginInstaller.toggleInstallPlugin('" + pluginInfo.pid + "', this)"); michael@0: // XXXlocalize (nit) michael@0: myCheckbox.setAttribute("label", pluginInfo.name + " " + (pluginInfo.version ? pluginInfo.version : "")); michael@0: myCheckbox.setAttribute("src", pluginInfo.IconUrl); michael@0: michael@0: myPluginList.appendChild(myCheckbox); michael@0: michael@0: if (pluginInfo.InstallerShowsUI == "true") michael@0: hasPluginWithInstallerUI = true; michael@0: michael@0: // keep a running count of plugins the user wants to install michael@0: this.pluginsToInstallNum++; michael@0: } michael@0: michael@0: if (hasPluginWithInstallerUI) michael@0: document.getElementById("installerUI").hidden = false; michael@0: michael@0: this.canAdvance(true); michael@0: this.canRewind(false); michael@0: } michael@0: michael@0: nsPluginInstallerWizard.prototype.toggleInstallPlugin = function (aPid, aCheckbox) { michael@0: this.mPluginInfoArray[aPid].toBeInstalled = aCheckbox.checked; michael@0: michael@0: // if no plugins are checked, don't allow to advance michael@0: this.pluginsToInstallNum = 0; michael@0: for (var pluginInfoItem in this.mPluginInfoArray){ michael@0: if (this.mPluginInfoArray[pluginInfoItem].toBeInstalled) michael@0: this.pluginsToInstallNum++; michael@0: } michael@0: michael@0: if (this.pluginsToInstallNum > 0) michael@0: this.canAdvance(true); michael@0: else michael@0: this.canAdvance(false); michael@0: } michael@0: michael@0: nsPluginInstallerWizard.prototype.canAdvance = function (aBool){ michael@0: document.getElementById("plugin-installer-wizard").canAdvance = aBool; michael@0: } michael@0: michael@0: nsPluginInstallerWizard.prototype.canRewind = function (aBool){ michael@0: document.getElementById("plugin-installer-wizard").canRewind = aBool; michael@0: } michael@0: michael@0: nsPluginInstallerWizard.prototype.canCancel = function (aBool){ michael@0: document.documentElement.getButton("cancel").disabled = !aBool; michael@0: } michael@0: michael@0: nsPluginInstallerWizard.prototype.showLicenses = function (){ michael@0: this.canAdvance(false); michael@0: this.canRewind(false); michael@0: michael@0: // only add if a license is provided and the plugin was selected to michael@0: // be installed michael@0: for (var pluginInfoItem in this.mPluginInfoArray){ michael@0: var myPluginInfoItem = this.mPluginInfoArray[pluginInfoItem]; michael@0: if (myPluginInfoItem.toBeInstalled && myPluginInfoItem.licenseURL && (myPluginInfoItem.licenseURL != "")) michael@0: this.mPluginLicenseArray.push(myPluginInfoItem.pid); michael@0: } michael@0: michael@0: if (this.mPluginLicenseArray.length == 0) { michael@0: // no plugins require licenses michael@0: this.advancePage(null); michael@0: } else { michael@0: this.licenseAcceptCounter = 0; michael@0: michael@0: // add a nsIWebProgress listener to the license iframe. michael@0: var docShell = document.getElementById("licenseIFrame").docShell; michael@0: var iiReq = docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor); michael@0: var webProgress = iiReq.getInterface(Components.interfaces.nsIWebProgress); michael@0: webProgress.addProgressListener(gPluginInstaller.progressListener, michael@0: Components.interfaces.nsIWebProgress.NOTIFY_ALL); michael@0: michael@0: this.showLicense(); michael@0: } michael@0: } michael@0: michael@0: nsPluginInstallerWizard.prototype.enableNext = function (){ michael@0: // if only one plugin exists, don't enable the next button until michael@0: // the license is accepted michael@0: if (gPluginInstaller.pluginsToInstallNum > 1) michael@0: gPluginInstaller.canAdvance(true); michael@0: michael@0: document.getElementById("licenseRadioGroup1").disabled = false; michael@0: document.getElementById("licenseRadioGroup2").disabled = false; michael@0: } michael@0: michael@0: const nsIWebProgressListener = Components.interfaces.nsIWebProgressListener; michael@0: nsPluginInstallerWizard.prototype.progressListener = { michael@0: onStateChange : function(aWebProgress, aRequest, aStateFlags, aStatus) michael@0: { michael@0: if ((aStateFlags & nsIWebProgressListener.STATE_STOP) && michael@0: (aStateFlags & nsIWebProgressListener.STATE_IS_NETWORK)) { michael@0: // iframe loaded michael@0: gPluginInstaller.enableNext(); michael@0: } michael@0: }, michael@0: michael@0: onProgressChange : function(aWebProgress, aRequest, aCurSelfProgress, michael@0: aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress) michael@0: {}, michael@0: onStatusChange : function(aWebProgress, aRequest, aStatus, aMessage) michael@0: {}, michael@0: michael@0: QueryInterface : function(aIID) michael@0: { michael@0: if (aIID.equals(Components.interfaces.nsIWebProgressListener) || michael@0: aIID.equals(Components.interfaces.nsISupportsWeakReference) || michael@0: aIID.equals(Components.interfaces.nsISupports)) michael@0: return this; michael@0: throw Components.results.NS_NOINTERFACE; michael@0: } michael@0: } michael@0: michael@0: nsPluginInstallerWizard.prototype.showLicense = function (){ michael@0: var pluginInfo = this.mPluginInfoArray[this.mPluginLicenseArray[this.licenseAcceptCounter]]; michael@0: michael@0: this.canAdvance(false); michael@0: michael@0: var loadFlags = Components.interfaces.nsIWebNavigation.LOAD_FLAGS_NONE; michael@0: document.getElementById("licenseIFrame").webNavigation.loadURI(pluginInfo.licenseURL, loadFlags, null, null, null); michael@0: michael@0: document.getElementById("pluginLicenseLabel").firstChild.nodeValue = michael@0: this.getFormattedString("pluginLicenseAgreement.label", [pluginInfo.name]); michael@0: michael@0: document.getElementById("licenseRadioGroup1").disabled = true; michael@0: document.getElementById("licenseRadioGroup2").disabled = true; michael@0: document.getElementById("licenseRadioGroup").selectedIndex = michael@0: pluginInfo.licenseAccepted ? 0 : 1; michael@0: } michael@0: michael@0: nsPluginInstallerWizard.prototype.showNextLicense = function (){ michael@0: var rv = true; michael@0: michael@0: if (this.mPluginLicenseArray.length > 0) { michael@0: this.storeLicenseRadioGroup(); michael@0: michael@0: this.licenseAcceptCounter++; michael@0: michael@0: if (this.licenseAcceptCounter < this.mPluginLicenseArray.length) { michael@0: this.showLicense(); michael@0: michael@0: rv = false; michael@0: this.canRewind(true); michael@0: } michael@0: } michael@0: michael@0: return rv; michael@0: } michael@0: michael@0: nsPluginInstallerWizard.prototype.showPreviousLicense = function (){ michael@0: this.storeLicenseRadioGroup(); michael@0: this.licenseAcceptCounter--; michael@0: michael@0: if (this.licenseAcceptCounter > 0) michael@0: this.canRewind(true); michael@0: else michael@0: this.canRewind(false); michael@0: michael@0: this.showLicense(); michael@0: michael@0: // don't allow to return from the license screens michael@0: return false; michael@0: } michael@0: michael@0: nsPluginInstallerWizard.prototype.storeLicenseRadioGroup = function (){ michael@0: var pluginInfo = this.mPluginInfoArray[this.mPluginLicenseArray[this.licenseAcceptCounter]]; michael@0: pluginInfo.licenseAccepted = !document.getElementById("licenseRadioGroup").selectedIndex; michael@0: } michael@0: michael@0: nsPluginInstallerWizard.prototype.licenseRadioGroupChange = function(aAccepted) { michael@0: // only if one plugin is to be installed should selection change the next button michael@0: if (this.pluginsToInstallNum == 1) michael@0: this.canAdvance(aAccepted); michael@0: } michael@0: michael@0: nsPluginInstallerWizard.prototype.advancePage = function (aPageId){ michael@0: this.canAdvance(true); michael@0: document.getElementById("plugin-installer-wizard").advance(aPageId); michael@0: } michael@0: michael@0: nsPluginInstallerWizard.prototype.startPluginInstallation = function (){ michael@0: this.canAdvance(false); michael@0: this.canRewind(false); michael@0: michael@0: var installerPlugins = []; michael@0: var xpiPlugins = []; michael@0: michael@0: for (var pluginInfoItem in this.mPluginInfoArray){ michael@0: var pluginItem = this.mPluginInfoArray[pluginInfoItem]; michael@0: michael@0: if (pluginItem.toBeInstalled && pluginItem.licenseAccepted) { michael@0: if (pluginItem.InstallerLocation) michael@0: installerPlugins.push(pluginItem); michael@0: else if (pluginItem.XPILocation) michael@0: xpiPlugins.push(pluginItem); michael@0: } michael@0: } michael@0: michael@0: if (installerPlugins.length > 0 || xpiPlugins.length > 0) michael@0: PluginInstallService.startPluginInstallation(installerPlugins, michael@0: xpiPlugins); michael@0: else michael@0: this.advancePage(null); michael@0: } michael@0: michael@0: /* michael@0: 0 starting download michael@0: 1 download finished michael@0: 2 starting installation michael@0: 3 finished installation michael@0: 4 all done michael@0: */ michael@0: nsPluginInstallerWizard.prototype.pluginInstallationProgress = function (aPid, aProgress, aError) { michael@0: michael@0: var statMsg = null; michael@0: var pluginInfo = gPluginInstaller.mPluginInfoArray[aPid]; michael@0: michael@0: switch (aProgress) { michael@0: michael@0: case 0: michael@0: statMsg = this.getFormattedString("pluginInstallation.download.start", [pluginInfo.name]); michael@0: break; michael@0: michael@0: case 1: michael@0: statMsg = this.getFormattedString("pluginInstallation.download.finish", [pluginInfo.name]); michael@0: break; michael@0: michael@0: case 2: michael@0: statMsg = this.getFormattedString("pluginInstallation.install.start", [pluginInfo.name]); michael@0: var progressElm = document.getElementById("plugin_install_progress"); michael@0: progressElm.setAttribute("mode", "undetermined"); michael@0: break; michael@0: michael@0: case 3: michael@0: if (aError) { michael@0: statMsg = this.getFormattedString("pluginInstallation.install.error", [pluginInfo.name, aError]); michael@0: pluginInfo.error = aError; michael@0: } else { michael@0: statMsg = this.getFormattedString("pluginInstallation.install.finish", [pluginInfo.name]); michael@0: pluginInfo.error = null; michael@0: } michael@0: break; michael@0: michael@0: case 4: michael@0: statMsg = this.getString("pluginInstallation.complete"); michael@0: break; michael@0: } michael@0: michael@0: if (statMsg) michael@0: document.getElementById("plugin_install_progress_message").value = statMsg; michael@0: michael@0: if (aProgress == 4) { michael@0: this.advancePage(null); michael@0: } michael@0: } michael@0: michael@0: nsPluginInstallerWizard.prototype.pluginInstallationProgressMeter = function (aPid, aValue, aMaxValue){ michael@0: var progressElm = document.getElementById("plugin_install_progress"); michael@0: michael@0: if (progressElm.getAttribute("mode") == "undetermined") michael@0: progressElm.setAttribute("mode", "determined"); michael@0: michael@0: progressElm.setAttribute("value", Math.ceil((aValue / aMaxValue) * 100) + "%") michael@0: } michael@0: michael@0: nsPluginInstallerWizard.prototype.addPluginResultRow = function (aImgSrc, aName, aNameTooltip, aStatus, aStatusTooltip, aManualUrl){ michael@0: var myRows = document.getElementById("pluginResultList"); michael@0: michael@0: var myRow = document.createElement("row"); michael@0: myRow.setAttribute("align", "center"); michael@0: michael@0: // create the image michael@0: var myImage = document.createElement("image"); michael@0: myImage.setAttribute("src", aImgSrc); michael@0: myImage.setAttribute("height", "16px"); michael@0: myImage.setAttribute("width", "16px"); michael@0: myRow.appendChild(myImage) michael@0: michael@0: // create the labels michael@0: var myLabel = document.createElement("label"); michael@0: myLabel.setAttribute("value", aName); michael@0: if (aNameTooltip) michael@0: myLabel.setAttribute("tooltiptext", aNameTooltip); michael@0: myRow.appendChild(myLabel); michael@0: michael@0: if (aStatus) { michael@0: myLabel = document.createElement("label"); michael@0: myLabel.setAttribute("value", aStatus); michael@0: myRow.appendChild(myLabel); michael@0: } michael@0: michael@0: // manual install michael@0: if (aManualUrl) { michael@0: var myButton = document.createElement("button"); michael@0: michael@0: var manualInstallLabel = this.getString("pluginInstallationSummary.manualInstall.label"); michael@0: var manualInstallTooltip = this.getString("pluginInstallationSummary.manualInstall.tooltip"); michael@0: michael@0: myButton.setAttribute("label", manualInstallLabel); michael@0: myButton.setAttribute("tooltiptext", manualInstallTooltip); michael@0: michael@0: myRow.appendChild(myButton); michael@0: michael@0: // XXX: XUL sucks, need to add the listener after it got added into the document michael@0: if (aManualUrl) michael@0: myButton.addEventListener("command", function() { gPluginInstaller.loadURL(aManualUrl) }, false); michael@0: } michael@0: michael@0: myRows.appendChild(myRow); michael@0: } michael@0: michael@0: nsPluginInstallerWizard.prototype.showPluginResults = function (){ michael@0: var notInstalledList = "?action=missingplugins"; michael@0: var myRows = document.getElementById("pluginResultList"); michael@0: michael@0: // clear children michael@0: for (var run = myRows.childNodes.length; run--; run > 0) michael@0: myRows.removeChild(myRows.childNodes.item(run)); michael@0: michael@0: for (var pluginInfoItem in this.mPluginInfoArray){ michael@0: // [plugin image] [Plugin_Name Plugin_Version] [Success/Failed] [Manual Install (if Failed)] michael@0: michael@0: var myPluginItem = this.mPluginInfoArray[pluginInfoItem]; michael@0: michael@0: if (myPluginItem.toBeInstalled) { michael@0: var statusMsg; michael@0: var statusTooltip; michael@0: if (myPluginItem.error){ michael@0: statusMsg = this.getString("pluginInstallationSummary.failed"); michael@0: statusTooltip = myPluginItem.error; michael@0: notInstalledList += "&mimetype=" + pluginInfoItem; michael@0: } else if (!myPluginItem.licenseAccepted) { michael@0: statusMsg = this.getString("pluginInstallationSummary.licenseNotAccepted"); michael@0: } else if (!myPluginItem.XPILocation && !myPluginItem.InstallerLocation) { michael@0: statusMsg = this.getString("pluginInstallationSummary.notAvailable"); michael@0: notInstalledList += "&mimetype=" + pluginInfoItem; michael@0: } else { michael@0: this.mSuccessfullPluginInstallation++; michael@0: statusMsg = this.getString("pluginInstallationSummary.success"); michael@0: michael@0: // only check needsRestart if the plugin was successfully installed. michael@0: if (myPluginItem.needsRestart) michael@0: this.mNeedsRestart = true; michael@0: } michael@0: michael@0: // manual url - either returned from the webservice or the pluginspage attribute michael@0: var manualUrl; michael@0: if ((myPluginItem.error || (!myPluginItem.XPILocation && !myPluginItem.InstallerLocation)) && michael@0: (myPluginItem.manualInstallationURL || this.mPluginRequests.get(myPluginItem.requestedMimetype).pluginsPage)){ michael@0: manualUrl = myPluginItem.manualInstallationURL ? myPluginItem.manualInstallationURL : this.mPluginRequests.get(myPluginItem.requestedMimetype).pluginsPage; michael@0: } michael@0: michael@0: this.addPluginResultRow( michael@0: myPluginItem.IconUrl, michael@0: myPluginItem.name + " " + (myPluginItem.version ? myPluginItem.version : ""), michael@0: null, michael@0: statusMsg, michael@0: statusTooltip, michael@0: manualUrl); michael@0: } michael@0: } michael@0: michael@0: // handle plugins we couldn't find michael@0: for (pluginInfoItem in this.mPluginNotFoundArray){ michael@0: var pluginRequest = this.mPluginNotFoundArray[pluginInfoItem]; michael@0: michael@0: // if there is a pluginspage, show UI michael@0: if (pluginRequest.pluginsPage) { michael@0: this.addPluginResultRow( michael@0: "", michael@0: this.getFormattedString("pluginInstallation.unknownPlugin", [pluginInfoItem]), michael@0: null, michael@0: null, michael@0: null, michael@0: pluginRequest.pluginsPage); michael@0: } michael@0: michael@0: notInstalledList += "&mimetype=" + pluginInfoItem; michael@0: } michael@0: michael@0: // no plugins were found, so change the description of the final page. michael@0: if (this.mPluginInfoArrayLength == 0) { michael@0: var noPluginsFound = this.getString("pluginInstallation.noPluginsFound"); michael@0: document.getElementById("pluginSummaryDescription").setAttribute("value", noPluginsFound); michael@0: } else if (this.mSuccessfullPluginInstallation == 0) { michael@0: // plugins found, but none were installed. michael@0: var noPluginsInstalled = this.getString("pluginInstallation.noPluginsInstalled"); michael@0: document.getElementById("pluginSummaryDescription").setAttribute("value", noPluginsInstalled); michael@0: } michael@0: michael@0: document.getElementById("pluginSummaryRestartNeeded").hidden = !this.mNeedsRestart; michael@0: michael@0: var app = Components.classes["@mozilla.org/xre/app-info;1"] michael@0: .getService(Components.interfaces.nsIXULAppInfo); michael@0: michael@0: // set the get more info link to contain the mimetypes we couldn't install. michael@0: notInstalledList += michael@0: "&appID=" + app.ID + michael@0: "&appVersion=" + app.platformBuildID + michael@0: "&clientOS=" + this.getOS() + michael@0: "&chromeLocale=" + this.getChromeLocale() + michael@0: "&appRelease=" + app.version; michael@0: michael@0: document.getElementById("moreInfoLink").addEventListener("click", function() { gPluginInstaller.loadURL("https://pfs.mozilla.org/plugins/" + notInstalledList) }, false); michael@0: michael@0: if (this.mNeedsRestart) { michael@0: var cancel = document.getElementById("plugin-installer-wizard").getButton("cancel"); michael@0: cancel.label = this.getString("pluginInstallation.close.label"); michael@0: cancel.accessKey = this.getString("pluginInstallation.close.accesskey"); michael@0: var finish = document.getElementById("plugin-installer-wizard").getButton("finish"); michael@0: finish.label = this.getFormattedString("pluginInstallation.restart.label", [app.name]); michael@0: finish.accessKey = this.getString("pluginInstallation.restart.accesskey"); michael@0: this.canCancel(true); michael@0: } michael@0: else { michael@0: this.canCancel(false); michael@0: } michael@0: this.canAdvance(true); michael@0: this.canRewind(false); michael@0: } michael@0: michael@0: nsPluginInstallerWizard.prototype.loadURL = function (aUrl){ michael@0: // Check if the page where the plugin came from can load aUrl before michael@0: // loading it, and do *not* allow loading URIs that would inherit our michael@0: // principal. michael@0: michael@0: var pluginPagePrincipal = michael@0: window.opener.content.document.nodePrincipal; michael@0: michael@0: const nsIScriptSecurityManager = michael@0: Components.interfaces.nsIScriptSecurityManager; michael@0: var secMan = Components.classes["@mozilla.org/scriptsecuritymanager;1"] michael@0: .getService(nsIScriptSecurityManager); michael@0: michael@0: secMan.checkLoadURIStrWithPrincipal(pluginPagePrincipal, aUrl, michael@0: nsIScriptSecurityManager.DISALLOW_INHERIT_PRINCIPAL); michael@0: michael@0: window.opener.open(aUrl); michael@0: } michael@0: michael@0: nsPluginInstallerWizard.prototype.getString = function (aName){ michael@0: return document.getElementById("pluginWizardString").getString(aName); michael@0: } michael@0: michael@0: nsPluginInstallerWizard.prototype.getFormattedString = function (aName, aArray){ michael@0: return document.getElementById("pluginWizardString").getFormattedString(aName, aArray); michael@0: } michael@0: michael@0: nsPluginInstallerWizard.prototype.getOS = function (){ michael@0: var httpService = Components.classes["@mozilla.org/network/protocol;1?name=http"] michael@0: .getService(Components.interfaces.nsIHttpProtocolHandler); michael@0: return httpService.oscpu; michael@0: } michael@0: michael@0: nsPluginInstallerWizard.prototype.getChromeLocale = function (){ michael@0: var chromeReg = Components.classes["@mozilla.org/chrome/chrome-registry;1"] michael@0: .getService(Components.interfaces.nsIXULChromeRegistry); michael@0: return chromeReg.getSelectedLocale("global"); michael@0: } michael@0: michael@0: nsPluginInstallerWizard.prototype.getPrefBranch = function (){ michael@0: if (!this.prefBranch) michael@0: this.prefBranch = Components.classes["@mozilla.org/preferences-service;1"] michael@0: .getService(Components.interfaces.nsIPrefBranch); michael@0: return this.prefBranch; michael@0: } michael@0: function nsPluginRequest(aPlugRequest){ michael@0: this.mimetype = encodeURI(aPlugRequest.mimetype); michael@0: this.pluginsPage = aPlugRequest.pluginsPage; michael@0: } michael@0: michael@0: function PluginInfo(aResult) { michael@0: this.name = aResult.name; michael@0: this.pid = aResult.pid; michael@0: this.version = aResult.version; michael@0: this.IconUrl = aResult.IconUrl; michael@0: this.InstallerLocation = aResult.InstallerLocation; michael@0: this.InstallerHash = aResult.InstallerHash; michael@0: this.XPILocation = aResult.XPILocation; michael@0: this.XPIHash = aResult.XPIHash; michael@0: this.InstallerShowsUI = aResult.InstallerShowsUI; michael@0: this.manualInstallationURL = aResult.manualInstallationURL; michael@0: this.requestedMimetype = aResult.requestedMimetype; michael@0: this.licenseURL = aResult.licenseURL; michael@0: this.needsRestart = (aResult.needsRestart == "true"); michael@0: michael@0: this.error = null; michael@0: this.toBeInstalled = true; michael@0: michael@0: // no license provided, make it accepted michael@0: this.licenseAccepted = this.licenseURL ? false : true; michael@0: } michael@0: michael@0: var gPluginInstaller; michael@0: michael@0: function wizardInit(){ michael@0: gPluginInstaller = new nsPluginInstallerWizard(); michael@0: gPluginInstaller.canAdvance(false); michael@0: gPluginInstaller.getPluginData(); michael@0: } michael@0: michael@0: function wizardFinish(){ michael@0: if (gPluginInstaller.mNeedsRestart) { michael@0: // Notify all windows that an application quit has been requested. michael@0: var os = Components.classes["@mozilla.org/observer-service;1"] michael@0: .getService(Components.interfaces.nsIObserverService); michael@0: var cancelQuit = Components.classes["@mozilla.org/supports-PRBool;1"] michael@0: .createInstance(Components.interfaces.nsISupportsPRBool); michael@0: os.notifyObservers(cancelQuit, "quit-application-requested", "restart"); michael@0: michael@0: // Something aborted the quit process. michael@0: if (!cancelQuit.data) { michael@0: var nsIAppStartup = Components.interfaces.nsIAppStartup; michael@0: var appStartup = Components.classes["@mozilla.org/toolkit/app-startup;1"] michael@0: .getService(nsIAppStartup); michael@0: appStartup.quit(nsIAppStartup.eAttemptQuit | nsIAppStartup.eRestart); michael@0: return true; michael@0: } michael@0: } michael@0: michael@0: // don't refresh if no plugins were found or installed michael@0: if ((gPluginInstaller.mSuccessfullPluginInstallation > 0) && michael@0: (gPluginInstaller.mPluginInfoArray.length != 0)) { michael@0: michael@0: // reload plugins so JS detection works immediately michael@0: try { michael@0: var ph = Components.classes["@mozilla.org/plugin/host;1"] michael@0: .getService(Components.interfaces.nsIPluginHost); michael@0: ph.reloadPlugins(false); michael@0: } michael@0: catch (e) { michael@0: // reloadPlugins throws an exception if there were no plugins to load michael@0: } michael@0: michael@0: if (gPluginInstaller.mBrowser) { michael@0: // notify listeners that a plugin is installed, michael@0: // so that they can reset the UI and update the browser. michael@0: var event = document.createEvent("Events"); michael@0: event.initEvent("NewPluginInstalled", true, true); michael@0: gPluginInstaller.mBrowser.dispatchEvent(event); michael@0: } michael@0: } michael@0: michael@0: return true; michael@0: }